/// <summary>
        /// This method produces instances of type <see cref="Mapsui.Geometries.LineString"/>.
        /// </summary>
        /// <returns>The created geometries</returns>
        internal override Collection <Geometry> CreateGeometries(Features features)
        {
            IPathNode lineStringNode = new PathNode(Gmlns, "LineString", (NameTable)XmlReader.NameTable);
            var       labelValue     = new string[1];
            bool      geomFound      = false;

            try
            {
                // Reading the entire feature's node makes it possible to collect label values that may appear before or after the geometry property
                while ((FeatureReader = GetSubReaderOf(XmlReader, null, FeatureNode)) != null)
                {
                    while (
                        (GeomReader = GetSubReaderOf(FeatureReader, labelValue, lineStringNode, CoordinatesNode)) !=
                        null)
                    {
                        Geoms.Add(new LineString(ParseCoordinates(GeomReader)));
                        geomFound = true;
                    }
                    if (geomFound)
                    {
                        features.Add(CreateFeature(Geoms[Geoms.Count - 1], FeatureTypeInfo.LableField, labelValue[0]));
                    }
                    geomFound = false;
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("An exception occured while parsing a line geometry string: " + ex.Message);
                throw;
            }

            return(Geoms);
        }
Exemple #2
0
        /// <summary>
        /// This method produces instances of type <see cref="Point"/>.
        /// </summary>
        /// <returns>The created geometries</returns>
        internal override Collection <Geometry> CreateGeometries(List <IFeature> features)
        {
            IPathNode pointNode   = new PathNode(Gmlns, "Point", (NameTable)XmlReader.NameTable);
            var       labelValues = new Dictionary <string, string>();
            var       geomFound   = false;

            try
            {
                // Reading the entire feature's node makes it possible to collect label values that may appear before or after the geometry property
                while ((FeatureReader = GetSubReaderOf(XmlReader, null, FeatureNode)) != null)
                {
                    while ((GeomReader = GetSubReaderOf(FeatureReader, labelValues, pointNode, CoordinatesNode)) != null)
                    {
                        Geoms.Add(ParseCoordinates(GeomReader)[0].ToPoint());
                        geomFound = true;
                    }
                    if (geomFound)
                    {
                        features.Add(AddLabel(labelValues, Geoms[Geoms.Count - 1]));
                    }
                    geomFound = false;
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("An exception occurred while parsing a point geometry string: " + ex.Message);
                throw;
            }

            return(Geoms);
        }
        /// <summary>
        /// This method produces instances of type <see cref="Mapsui.Geometries.Polygon"/>.
        /// </summary>
        /// <returns>The created geometries</returns>
        internal override Collection <Geometry> CreateGeometries(Features features)
        {
            IPathNode polygonNode          = new PathNode(Gmlns, "Polygon", (NameTable)XmlReader.NameTable);
            IPathNode outerBoundaryNode    = new PathNode(Gmlns, "outerBoundaryIs", (NameTable)XmlReader.NameTable);
            IPathNode exteriorNode         = new PathNode(Gmlns, "exterior", (NameTable)XmlReader.NameTable);
            IPathNode outerBoundaryNodeAlt = new AlternativePathNodesCollection(outerBoundaryNode, exteriorNode);
            IPathNode innerBoundaryNode    = new PathNode(Gmlns, "innerBoundaryIs", (NameTable)XmlReader.NameTable);
            IPathNode interiorNode         = new PathNode(Gmlns, "interior", (NameTable)XmlReader.NameTable);
            IPathNode innerBoundaryNodeAlt = new AlternativePathNodesCollection(innerBoundaryNode, interiorNode);
            IPathNode linearRingNode       = new PathNode(Gmlns, "LinearRing", (NameTable)XmlReader.NameTable);
            var       labelValue           = new string[1];
            bool      geomFound            = false;

            try
            {
                // Reading the entire feature's node makes it possible to collect label values that may appear before or after the geometry property
                while ((FeatureReader = GetSubReaderOf(XmlReader, null, FeatureNode)) != null)
                {
                    while ((GeomReader = GetSubReaderOf(FeatureReader, labelValue, polygonNode)) != null)
                    {
                        var polygon = new Polygon();

                        XmlReader outerBoundaryReader;
                        if (
                            (outerBoundaryReader =
                                 GetSubReaderOf(GeomReader, null, outerBoundaryNodeAlt, linearRingNode, CoordinatesNode)) !=
                            null)
                        {
                            polygon.ExteriorRing = new LinearRing(ParseCoordinates(outerBoundaryReader));
                        }

                        XmlReader innerBoundariesReader;
                        while (
                            (innerBoundariesReader =
                                 GetSubReaderOf(GeomReader, null, innerBoundaryNodeAlt, linearRingNode, CoordinatesNode)) !=
                            null)
                        {
                            polygon.InteriorRings.Add(new LinearRing(ParseCoordinates(innerBoundariesReader)));
                        }

                        Geoms.Add(polygon);
                        geomFound = true;
                    }
                    if (geomFound)
                    {
                        features.Add(CreateFeature(Geoms[Geoms.Count - 1], FeatureTypeInfo.LableField, labelValue[0]));
                    }
                    geomFound = false;
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("An exception occured while parsing a polygon geometry: " + ex.Message);
                throw;
            }

            return(Geoms);
        }
Exemple #4
0
        /// <summary>
        /// This method produces instances of type <see cref="Mapsui.Geometries.MultiPolygon"/>.
        /// </summary>
        /// <returns>The created geometries</returns>
        internal override Collection <Geometry> CreateGeometries(Features features)
        {
            IPathNode multiPolygonNode     = new PathNode(Gmlns, "MultiPolygon", (NameTable)XmlReader.NameTable);
            IPathNode multiSurfaceNode     = new PathNode(Gmlns, "MultiSurface", (NameTable)XmlReader.NameTable);
            IPathNode multiPolygonNodeAlt  = new AlternativePathNodesCollection(multiPolygonNode, multiSurfaceNode);
            IPathNode polygonMemberNode    = new PathNode(Gmlns, "polygonMember", (NameTable)XmlReader.NameTable);
            IPathNode surfaceMemberNode    = new PathNode(Gmlns, "surfaceMember", (NameTable)XmlReader.NameTable);
            IPathNode polygonMemberNodeAlt = new AlternativePathNodesCollection(polygonMemberNode, surfaceMemberNode);
            IPathNode linearRingNode       = new PathNode(Gmlns, "LinearRing", (NameTable)XmlReader.NameTable);
            var       labelValues          = new Dictionary <string, string>();
            bool      geomFound            = false;

            try
            {
                // Reading the entire feature's node makes it possible to collect label values that may appear before or after the geometry property
                while ((FeatureReader = GetSubReaderOf(XmlReader, null, FeatureNode)) != null)
                {
                    while (
                        (GeomReader =
                             GetSubReaderOf(FeatureReader, labelValues, multiPolygonNodeAlt, polygonMemberNodeAlt)) != null)
                    {
                        var             multiPolygon = new MultiPolygon();
                        GeometryFactory geomFactory  = new PolygonFactory(GeomReader, FeatureTypeInfo)
                        {
                            AxisOrder = AxisOrder
                        };
                        Collection <Geometry> polygons = geomFactory.CreateGeometries(features);

                        foreach (var geometry in polygons)
                        {
                            var polygon = (Polygon)geometry;
                            multiPolygon.Polygons.Add(polygon);
                        }

                        Geoms.Add(multiPolygon);
                        geomFound = true;
                    }
                    if (geomFound)
                    {
                        features.Add(AddLabel(labelValues, Geoms[Geoms.Count - 1]));
                    }
                    geomFound = false;
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("An exception occured while parsing a multi-polygon geometry: " + ex.Message);
                throw;
            }

            return(Geoms);
        }
        /// <summary>
        /// This method produces instances of type <see cref="Mapsui.Geometries.MultiLineString"/>.
        /// </summary>
        /// <returns>The created geometries</returns>
        internal override Collection <Geometry> CreateGeometries(Features features)
        {
            IPathNode multiLineStringNode     = new PathNode(Gmlns, "MultiLineString", (NameTable)XmlReader.NameTable);
            IPathNode multiCurveNode          = new PathNode(Gmlns, "MultiCurve", (NameTable)XmlReader.NameTable);
            IPathNode multiLineStringNodeAlt  = new AlternativePathNodesCollection(multiLineStringNode, multiCurveNode);
            IPathNode lineStringMemberNode    = new PathNode(Gmlns, "lineStringMember", (NameTable)XmlReader.NameTable);
            IPathNode curveMemberNode         = new PathNode(Gmlns, "curveMember", (NameTable)XmlReader.NameTable);
            IPathNode lineStringMemberNodeAlt = new AlternativePathNodesCollection(lineStringMemberNode, curveMemberNode);
            var       labelValue = new string[1];
            bool      geomFound  = false;

            try
            {
                // Reading the entire feature's node makes it possible to collect label values that may appear before or after the geometry property
                while ((FeatureReader = GetSubReaderOf(XmlReader, null, FeatureNode)) != null)
                {
                    while (
                        (GeomReader =
                             GetSubReaderOf(FeatureReader, labelValue, multiLineStringNodeAlt, lineStringMemberNodeAlt)) !=
                        null)
                    {
                        var                   multiLineString = new MultiLineString();
                        GeometryFactory       geomFactory     = new LineStringFactory(GeomReader, FeatureTypeInfo);
                        Collection <Geometry> lineStrings     = geomFactory.CreateGeometries(features);

                        foreach (var geometry in lineStrings)
                        {
                            var lineString = (LineString)geometry;
                            multiLineString.LineStrings.Add(lineString);
                        }

                        Geoms.Add(multiLineString);
                        geomFound = true;
                    }
                    if (geomFound)
                    {
                        features.Add(CreateFeature(Geoms[Geoms.Count - 1], FeatureTypeInfo.LableField, labelValue[0]));
                    }
                    geomFound = false;
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("An exception occured while parsing a multi-lineString geometry: " + ex.Message);
                throw;
            }

            return(Geoms);
        }
Exemple #6
0
        /// <summary>
        /// This method produces instances of type <see cref="MultiLineString"/>.
        /// </summary>
        /// <returns>The created geometries</returns>
        internal override Collection <Geometry> CreateGeometries(List <IFeature> features)
        {
            IPathNode multiLineStringNode     = new PathNode(Gmlns, "MultiLineString", (NameTable)XmlReader.NameTable);
            IPathNode multiCurveNode          = new PathNode(Gmlns, "MultiCurve", (NameTable)XmlReader.NameTable);
            IPathNode multiLineStringNodeAlt  = new AlternativePathNodesCollection(multiLineStringNode, multiCurveNode);
            IPathNode lineStringMemberNode    = new PathNode(Gmlns, "lineStringMember", (NameTable)XmlReader.NameTable);
            IPathNode curveMemberNode         = new PathNode(Gmlns, "curveMember", (NameTable)XmlReader.NameTable);
            IPathNode lineStringMemberNodeAlt = new AlternativePathNodesCollection(lineStringMemberNode, curveMemberNode);
            var       labelValues             = new Dictionary <string, string>();
            var       geomFound = false;

            try
            {
                // Reading the entire feature's node makes it possible to collect label values that may appear before or after the geometry property
                while ((FeatureReader = GetSubReaderOf(XmlReader, null, FeatureNode)) != null)
                {
                    while (
                        (GeomReader =
                             GetSubReaderOf(FeatureReader, labelValues, multiLineStringNodeAlt, lineStringMemberNodeAlt)) !=
                        null)
                    {
                        using GeometryFactory geomFactory = new LineStringFactory(GeomReader, FeatureTypeInfo)
                              {
                                  AxisOrder = AxisOrder
                              };

                        var lineStrings = geomFactory.CreateGeometries(features).Cast <LineString>();
                        Geoms.Add(new MultiLineString(lineStrings.ToArray()));
                        geomFound = true;
                    }
                    if (geomFound)
                    {
                        features.Add(AddLabel(labelValues, Geoms[Geoms.Count - 1]));
                    }
                    geomFound = false;
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("An exception occurred while parsing a multi-lineString geometry: " + ex.Message);
                throw;
            }

            return(Geoms);
        }
        /// <summary>
        /// This method produces instances of type <see cref="Mapsui.Geometries.MultiPoint"/>.
        /// </summary>
        /// <returns>The created geometries</returns>
        internal override Collection <Geometry> CreateGeometries(Features features)
        {
            IPathNode multiPointNode  = new PathNode(Gmlns, "MultiPoint", (NameTable)XmlReader.NameTable);
            IPathNode pointMemberNode = new PathNode(Gmlns, "pointMember", (NameTable)XmlReader.NameTable);
            var       labelValue      = new string[1];
            bool      geomFound       = false;

            try
            {
                // Reading the entire feature's node makes it possible to collect label values that may appear before or after the geometry property
                while ((FeatureReader = GetSubReaderOf(XmlReader, null, FeatureNode)) != null)
                {
                    while (
                        (GeomReader = GetSubReaderOf(FeatureReader, labelValue, multiPointNode, pointMemberNode)) !=
                        null)
                    {
                        var                   multiPoint  = new MultiPoint();
                        GeometryFactory       geomFactory = new PointFactory(GeomReader, FeatureTypeInfo);
                        Collection <Geometry> points      = geomFactory.CreateGeometries(features);

                        foreach (var geometry in points)
                        {
                            var point = (Point)geometry;
                            multiPoint.Points.Add(point);
                        }

                        Geoms.Add(multiPoint);
                        geomFound = true;
                    }
                    if (geomFound)
                    {
                        features.Add(CreateFeature(Geoms[Geoms.Count - 1], FeatureTypeInfo.LableField, labelValue[0]));
                    }
                    geomFound = false;
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("An exception occured while parsing a multi-point geometry: " + ex.Message);
                throw;
            }

            return(Geoms);
        }
Exemple #8
0
 public void AddGeom(Geom geom)
 {
     Geoms.Add(geom);
 }
Exemple #9
0
        /// <summary>
        /// This method produces instances of type <see cref="Polygon"/>.
        /// </summary>
        /// <returns>The created geometries</returns>
        internal override Collection <Geometry> CreateGeometries(List <IFeature> features)
        {
            IPathNode polygonNode          = new PathNode(Gmlns, "Polygon", (NameTable)XmlReader.NameTable);
            IPathNode outerBoundaryNode    = new PathNode(Gmlns, "outerBoundaryIs", (NameTable)XmlReader.NameTable);
            IPathNode exteriorNode         = new PathNode(Gmlns, "exterior", (NameTable)XmlReader.NameTable);
            IPathNode outerBoundaryNodeAlt = new AlternativePathNodesCollection(outerBoundaryNode, exteriorNode);
            IPathNode innerBoundaryNode    = new PathNode(Gmlns, "innerBoundaryIs", (NameTable)XmlReader.NameTable);
            IPathNode interiorNode         = new PathNode(Gmlns, "interior", (NameTable)XmlReader.NameTable);
            IPathNode innerBoundaryNodeAlt = new AlternativePathNodesCollection(innerBoundaryNode, interiorNode);
            IPathNode linearRingNode       = new PathNode(Gmlns, "LinearRing", (NameTable)XmlReader.NameTable);
            var       labelValues          = new Dictionary <string, string>();
            var       geomFound            = false;

            try
            {
                // Reading the entire feature's node makes it possible to collect label values that may appear before or after the geometry property
                while ((FeatureReader = GetSubReaderOf(XmlReader, null, FeatureNode)) != null)
                {
                    while ((GeomReader = GetSubReaderOf(FeatureReader, labelValues, polygonNode)) != null)
                    {
                        LinearRing?exteriorRing = null;
                        XmlReader? outerBoundaryReader;
                        if ((outerBoundaryReader = GetSubReaderOf(
                                 GeomReader, null, outerBoundaryNodeAlt, linearRingNode, CoordinatesNode)) != null)
                        {
                            exteriorRing = new LinearRing(ParseCoordinates(outerBoundaryReader).ToArray());
                        }

                        var       holes = new List <LinearRing>();
                        XmlReader?innerBoundariesReader;
                        while ((innerBoundariesReader = GetSubReaderOf(
                                    GeomReader, null, innerBoundaryNodeAlt, linearRingNode, CoordinatesNode)) != null)
                        {
                            holes.Add(
                                new LinearRing(ParseCoordinates(innerBoundariesReader).ToArray()));
                        }

                        if (exteriorRing is not null)
                        {
                            if (holes.Any())
                            {
                                Geoms.Add(new Polygon(exteriorRing, holes.ToArray()));
                            }
                            else
                            {
                                Geoms.Add(new Polygon(exteriorRing));
                            }
                            geomFound = true;
                        }
                    }
                    if (geomFound)
                    {
                        features.Add(AddLabel(labelValues, Geoms[Geoms.Count - 1]));
                    }
                    geomFound = false;
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("An exception occured while parsing a polygon geometry: " + ex.Message);
                throw;
            }

            return(Geoms);
        }