This class represents an element-node in an XML document
Inheritance: IPathNode
示例#1
0
        /// <summary>
        /// This method detects the geometry type from 'GetFeature' response and uses a geometry factory to create the 
        /// appropriate geometries.
        /// </summary>
        /// <returns></returns>
        internal override Collection<Geometry> CreateGeometries(Features features)
        {
            GeometryFactory geomFactory = null;

            string geometryTypeString = string.Empty;

            if (_quickGeometries) _multiGeometries = false;

            IPathNode pointNode = new PathNode(Gmlns, "Point", (NameTable) XmlReader.NameTable);
            IPathNode lineStringNode = new PathNode(Gmlns, "LineString", (NameTable) XmlReader.NameTable);
            IPathNode polygonNode = new PathNode(Gmlns, "Polygon", (NameTable) XmlReader.NameTable);
            IPathNode multiPointNode = new PathNode(Gmlns, "MultiPoint", (NameTable) XmlReader.NameTable);
            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 multiPolygonNode = new PathNode(Gmlns, "MultiPolygon", (NameTable) XmlReader.NameTable);
            IPathNode multiSurfaceNode = new PathNode(Gmlns, "MultiSurface", (NameTable) XmlReader.NameTable);
            IPathNode multiPolygonNodeAlt = new AlternativePathNodesCollection(multiPolygonNode, multiSurfaceNode);

            while (XmlReader.Read())
            {
                if (XmlReader.NodeType == XmlNodeType.Element)
                {
                    if (_multiGeometries)
                    {
                        if (multiPointNode.Matches(XmlReader))
                        {
                            geomFactory = new MultiPointFactory(_httpClientUtil, FeatureTypeInfo);
                            geometryTypeString = "MultiPointPropertyType";
                            break;
                        }
                        if (multiLineStringNodeAlt.Matches(XmlReader))
                        {
                            geomFactory = new MultiLineStringFactory(_httpClientUtil, FeatureTypeInfo);
                            geometryTypeString = "MultiLineStringPropertyType";
                            break;
                        }
                        if (multiPolygonNodeAlt.Matches(XmlReader))
                        {
                            geomFactory = new MultiPolygonFactory(_httpClientUtil, FeatureTypeInfo);
                            geometryTypeString = "MultiPolygonPropertyType";
                            break;
                        }
                    }

                    if (pointNode.Matches(XmlReader))
                    {
                        geomFactory = new PointFactory(_httpClientUtil, FeatureTypeInfo);
                        geometryTypeString = "PointPropertyType";
                        break;
                    }
                    if (lineStringNode.Matches(XmlReader))
                    {
                        geomFactory = new LineStringFactory(_httpClientUtil, FeatureTypeInfo);
                        geometryTypeString = "LineStringPropertyType";
                        break;
                    }
                    if (polygonNode.Matches(XmlReader))
                    {
                        geomFactory = new PolygonFactory(_httpClientUtil, FeatureTypeInfo);
                        geometryTypeString = "PolygonPropertyType";
                        break;
                    }
                    if (ServiceExceptionNode.Matches(XmlReader))
                    {
                        string serviceException = XmlReader.ReadInnerXml();
                        Trace.TraceError("A service exception occured: " + serviceException);
                        throw new Exception("A service exception occured: " + serviceException);
                    }
                }
            }

            FeatureTypeInfo.Geometry.GeometryType = geometryTypeString;

            if (geomFactory == null) return Geoms;
            geomFactory.CreateGeometries(features);
            return Geoms;
        }
示例#2
0
        /// <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;
        }
示例#3
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 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, multiPolygonNodeAlt, polygonMemberNodeAlt)) != null)
                    {
                        var multiPolygon = new MultiPolygon();
                        GeometryFactory geomFactory = new PolygonFactory(GeomReader, FeatureTypeInfo);
                        Collection<Geometry> polygons = geomFactory.CreateGeometries(features);

                        foreach (Polygon polygon in polygons)
                            multiPolygon.Polygons.Add(polygon);

                        Geoms.Add(multiPolygon);
                        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-polygon geometry: " + ex.Message);
                throw;
            }

            return Geoms;
        }
示例#4
0
        /// <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;
        }
示例#5
0
 /// <summary>
 /// This method initializes path nodes needed by the derived classes.
 /// </summary>
 private void InitializePathNodes()
 {
     IPathNode coordinatesNode = new PathNode("http://www.opengis.net/gml", "coordinates",
                                              (NameTable) XmlReader.NameTable);
     IPathNode posListNode = new PathNode("http://www.opengis.net/gml", "posList",
                                          (NameTable) XmlReader.NameTable);
     IPathNode ogcServiceExceptionNode = new PathNode("http://www.opengis.net/ogc", "ServiceException",
                                                      (NameTable) XmlReader.NameTable);
     IPathNode serviceExceptionNode = new PathNode("", "ServiceException", (NameTable) XmlReader.NameTable);
         //ServiceExceptions without ogc prefix are returned by deegree. PDD.
     IPathNode exceptionTextNode = new PathNode("http://www.opengis.net/ows", "ExceptionText",
                                                (NameTable) XmlReader.NameTable);
     CoordinatesNode = new AlternativePathNodesCollection(coordinatesNode, posListNode);
     ServiceExceptionNode = new AlternativePathNodesCollection(ogcServiceExceptionNode, exceptionTextNode,
                                                                serviceExceptionNode);
     FeatureNode = new PathNode(FeatureTypeInfo.FeatureTypeNamespace, FeatureTypeInfo.Name,
                                 (NameTable) XmlReader.NameTable);
 }
示例#6
0
        /// <summary>
        /// This method detects the geometry type from 'GetFeature' response and uses a geometry factory to create the
        /// appropriate geometries.
        /// </summary>
        /// <returns></returns>
        internal override Collection <Geometry> CreateGeometries(Features features)
        {
            GeometryFactory geomFactory = null;

            string geometryTypeString = string.Empty;

            if (_quickGeometries)
            {
                _multiGeometries = false;
            }

            IPathNode pointNode              = new PathNode(Gmlns, "Point", (NameTable)XmlReader.NameTable);
            IPathNode lineStringNode         = new PathNode(Gmlns, "LineString", (NameTable)XmlReader.NameTable);
            IPathNode polygonNode            = new PathNode(Gmlns, "Polygon", (NameTable)XmlReader.NameTable);
            IPathNode multiPointNode         = new PathNode(Gmlns, "MultiPoint", (NameTable)XmlReader.NameTable);
            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 multiPolygonNode       = new PathNode(Gmlns, "MultiPolygon", (NameTable)XmlReader.NameTable);
            IPathNode multiSurfaceNode       = new PathNode(Gmlns, "MultiSurface", (NameTable)XmlReader.NameTable);
            IPathNode multiPolygonNodeAlt    = new AlternativePathNodesCollection(multiPolygonNode, multiSurfaceNode);

            while (XmlReader.Read())
            {
                if (XmlReader.NodeType == XmlNodeType.Element)
                {
                    if (_multiGeometries)
                    {
                        if (multiPointNode.Matches(XmlReader))
                        {
                            geomFactory        = new MultiPointFactory(_httpClientUtil, FeatureTypeInfo);
                            geometryTypeString = "MultiPointPropertyType";
                            break;
                        }
                        if (multiLineStringNodeAlt.Matches(XmlReader))
                        {
                            geomFactory        = new MultiLineStringFactory(_httpClientUtil, FeatureTypeInfo);
                            geometryTypeString = "MultiLineStringPropertyType";
                            break;
                        }
                        if (multiPolygonNodeAlt.Matches(XmlReader))
                        {
                            geomFactory        = new MultiPolygonFactory(_httpClientUtil, FeatureTypeInfo);
                            geometryTypeString = "MultiPolygonPropertyType";
                            break;
                        }
                    }

                    if (pointNode.Matches(XmlReader))
                    {
                        geomFactory        = new PointFactory(_httpClientUtil, FeatureTypeInfo);
                        geometryTypeString = "PointPropertyType";
                        break;
                    }
                    if (lineStringNode.Matches(XmlReader))
                    {
                        geomFactory        = new LineStringFactory(_httpClientUtil, FeatureTypeInfo);
                        geometryTypeString = "LineStringPropertyType";
                        break;
                    }
                    if (polygonNode.Matches(XmlReader))
                    {
                        geomFactory        = new PolygonFactory(_httpClientUtil, FeatureTypeInfo);
                        geometryTypeString = "PolygonPropertyType";
                        break;
                    }
                    if (ServiceExceptionNode.Matches(XmlReader))
                    {
                        string serviceException = XmlReader.ReadInnerXml();
                        Trace.TraceError("A service exception occured: " + serviceException);
                        throw new Exception("A service exception occured: " + serviceException);
                    }
                }
            }

            FeatureTypeInfo.Geometry.GeometryType = geometryTypeString;

            if (geomFactory == null)
            {
                return(Geoms);
            }

            geomFactory.AxisOrder = AxisOrder;
            geomFactory.CreateGeometries(features);
            return(Geoms);
        }
示例#7
0
        /// <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;
        }
示例#8
0
        /// <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;
        }