Exemplo n.º 1
0
 private void GetGeometry()
 {
     if (fields[Geometry] == "gml:PointPropertyType")
     {
         typeGeometry = DotSpatial.Topology.FeatureType.Point;
     }
     if (fields[Geometry] == "gml:MultiSurfacePropertyType")
     {
         typeGeometry = DotSpatial.Topology.FeatureType.Polygon;
     }
     if (fields[Geometry] == "gml:MultiLineStringPropertyType")
     {
         typeGeometry = DotSpatial.Topology.FeatureType.Line;
     }
 }
        /// <summary>
        /// Mapping of DotSpatial topology types to WKB geometry types as used by OGR
        /// </summary>
        /// <param name="pFeatureType">A DotSpatial feature type</param>
        /// <returns>A WKB geometry type as defined by OGR</returns>
        public static wkbGeometryType DSGeomTypeToOgrGeomType(DotSpatial.Topology.FeatureType pFeatureType)
        {
            switch (pFeatureType)
            {
            case DotSpatial.Topology.FeatureType.Point:
                return(wkbGeometryType.wkbPoint);

            case DotSpatial.Topology.FeatureType.Line:
                return(wkbGeometryType.wkbLineString);

            case DotSpatial.Topology.FeatureType.Polygon:
                return(wkbGeometryType.wkbPolygon);

            default:
                return(wkbGeometryType.wkbNone);
            }
        }
Exemplo n.º 3
0
        private XPathNodeIterator CreateFields(XPathNavigator nav, DotSpatial.Topology.FeatureType type)
        {
            string            exp      = @"/wfs:FeatureCollection/child::*[name() = 'gml:featureMember' or name() = 'gml:featureMembers']/child::*";
            XPathNodeIterator iterator = nav.Select(exp, _nsmgr);

            fea = new FeatureSet(type);
            if (iterator.Count > 0)
            {
                foreach (string fieldName in fields.Keys)
                {
                    if (fieldName != Geometry)
                    {
                        fea.DataTable.Columns.Add(new DataColumn(fieldName, GetType(fieldName)));
                    }
                }
            }
            return(iterator);
        }
Exemplo n.º 4
0
 private void GetGeometry()
 {
     if (fields[Geometry] == "gml:PointPropertyType")
         typeGeometry = DotSpatial.Topology.FeatureType.Point;
     if (fields[Geometry] == "gml:MultiSurfacePropertyType")
         typeGeometry = DotSpatial.Topology.FeatureType.Polygon;
     if (fields[Geometry] == "gml:MultiLineStringPropertyType")
         typeGeometry = DotSpatial.Topology.FeatureType.Line;
 }
Exemplo n.º 5
0
        private bool TryCreateFeatureSet(string pathToFile, DotSpatial.Topology.FeatureType type, out DotSpatial.Data.FeatureSet set)
        {
            char[] splitChars = new char[] { ' ', '\t' };
            set = new FeatureSet(type);

            if (!File.Exists(pathToFile))
            {
                return(false);
            }

            StreamReader sr = null;

            try
            {
                sr = new StreamReader(pathToFile);

                List <Coordinate> coords = new List <Coordinate>();

                string line = "";
                while ((line = sr.ReadLine()) != null)
                {
                    if (line.StartsWith("RMTEXT"))
                    {
                        continue;
                    }

                    string[] parts = line.Split(splitChars, StringSplitOptions.RemoveEmptyEntries);

                    if (parts.Length < 2)
                    {
                        continue;
                    }

                    double x;
                    if (!double.TryParse(parts[0], out x))
                    {
                        continue;
                    }

                    double y;
                    if (!double.TryParse(parts[1], out y))
                    {
                        continue;
                    }

                    coords.Add(new Coordinate(x, y));
                }

                set.AddFeature(new LineString(coords));

                return(true);
            }
            catch
            {
                return(false);
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                }
            }
        }