Esempio n. 1
0
        static List <GISFeature> ReadFeatures(BinaryReader br, SHAPETYPE ShapeType, List <GISField> Fields, int FeatureCount)
        {
            List <GISFeature> Features = new List <GISFeature>();

            for (int featureindex = 0; featureindex < FeatureCount; featureindex++)
            {
                GISFeature feature = new GISFeature(null, null);
                if (ShapeType == SHAPETYPE.POINT)
                {
                    GISVertex _location = ReadVertex(br);
                    feature.spatialpart = new GISPoint(_location);
                }
                else if (ShapeType == SHAPETYPE.LINE)
                {
                    List <GISVertex> vs = new List <GISVertex>();
                    int vcount          = br.ReadInt32();
                    for (int vc = 0; vc < vcount; vc++)
                    {
                        vs.Add(ReadVertex(br));
                    }
                    feature.spatialpart = new GISLine(vs);
                }
                else if (ShapeType == SHAPETYPE.POLYGON)
                {
                    List <GISVertex> vs = new List <GISVertex>();
                    int vcount          = br.ReadInt32();
                    for (int vc = 0; vc < vcount; vc++)
                    {
                        vs.Add(ReadVertex(br));
                    }
                    feature.spatialpart = new GISPolygon(vs);
                }
                GISAttribute ga = new GISAttribute();
                for (int fieldindex = 0; fieldindex < Fields.Count; fieldindex++)
                {
                    GISField field = Fields[fieldindex];
                    if (field.datatype == typeof(int))
                    {
                        ga.AddValue(br.ReadInt32());
                    }
                    else if (field.datatype == typeof(double))
                    {
                        ga.AddValue(br.ReadDouble());
                    }
                    else if (field.datatype == typeof(string))
                    {
                        ga.AddValue(ReadString(br));
                    }
                }
                feature.attributepart = ga;
                Features.Add(feature);
            }
            return(Features);
        }
Esempio n. 2
0
        static GISAttribute ReadAttribute(DataTable table, int RowIndex)
        {
            GISAttribute attribute = new GISAttribute();
            DataRow      row       = table.Rows[RowIndex];

            for (int i = 0; i < table.Columns.Count; i++)
            {
                attribute.AddValue(row[i]);
            }
            return(attribute);
        }