Esempio n. 1
0
 public GISFeature SelectPolygonByVertex(GISVertex vertex)
 {
     for (int i = 0; i < Features.Count; i++)
     {
         if (Features[i].spatialpart.extent.WithInDistance(vertex, 0) == false)
         {
             continue;
         }
         GISPolygon polygon = (GISPolygon)(Features[i].spatialpart);
         if (polygon.Include(vertex))
         {
             return(Features[i]);
         }
     }
     return(null);
 }
Esempio n. 2
0
        static void WriteFeatures(GISLayer layer, BinaryWriter bw)
        {
            for (int featureindex = 0; featureindex < layer.Features.Count; featureindex++)
            {
                GISFeature feature = layer.Features[featureindex];
                if (layer.ShapeType == SHAPETYPE.POINT)
                {
                    WriteVertex(((GISPoint)feature.spatialpart).Location, bw);
                }
                else if (layer.ShapeType == SHAPETYPE.LINE)
                {
                    GISLine line = (GISLine)(feature.spatialpart);
                    bw.Write(line.Vertexes.Count);
                    for (int vc = 0; vc < line.Vertexes.Count; vc++)
                    {
                        WriteVertex(line.Vertexes[vc], bw);
                    }
                }
                else if (layer.ShapeType == SHAPETYPE.POLYGON)
                {
                    GISPolygon polygon = (GISPolygon)(feature.spatialpart);
                    bw.Write(polygon.Vertexes.Count);
                    for (int vc = 0; vc < polygon.Vertexes.Count; vc++)
                    {
                        WriteVertex(polygon.Vertexes[vc], bw);
                    }
                }

                for (int fieldindex = 0; fieldindex < layer.Fields.Count; fieldindex++)
                {
                    GISField field = layer.Fields[fieldindex];
                    int      tint  = TypeToInt(field.datatype);
                    if (tint == 1)
                    {
                        bw.Write((int)(feature.getAttributeValue(fieldindex)));
                    }
                    else if (tint == 2)
                    {
                        bw.Write(Convert.ToDouble(feature.getAttributeValue(fieldindex)));
                    }
                    else if (tint == 3)
                    {
                        WriteString(feature.getAttributeValue(fieldindex).ToString(), bw);
                    }
                }
            }
        }