Exemplo n.º 1
0
        /// <summary>
        /// This method produces instances of type <see cref="GeoAPI.Geometries.IMultiPolygon"/>.
        /// </summary>
        /// <returns>The created geometries</returns>
        internal override Collection <IGeometry> createGeometries()
        {
            //IMultiPolygon multiPolygon = null;

            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);

            string[] 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)
                    {
                        GeometryFactory geomFactory = new PolygonFactory(_GeomReader, _FeatureTypeInfo)
                        {
                            AxisOrder = AxisOrder
                        };
                        var polygons = geomFactory.createGeometries();

                        var polygonArray = new IPolygon[polygons.Count];
                        var i            = 0;
                        foreach (IPolygon polygon in polygons)
                        {
                            polygonArray[i++] = polygon;
                        }

                        _Geoms.Add(Factory.CreateMultiPolygon(polygonArray));
                        geomFound = true;
                    }
                    if (geomFound)
                    {
                        AddLabel(labelValue[0], _Geoms[_Geoms.Count - 1]);
                    }
                    geomFound = false;
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("An exception occured while parsing a multi-polygon geometry: " + ex.Message);
                throw ex;
            }

            return(_Geoms);
        }
Exemplo n.º 2
0
        /// <summary>
        /// This method produces instances of type <see cref="SharpMap.Geometries.Polygon"/>.
        /// </summary>
        /// <returns>The created geometries</returns>
        internal override Collection <Geometry> createGeometries()
        {
            Polygon   polygon               = null;
            XmlReader outerBoundaryReader   = null;
            XmlReader innerBoundariesReader = null;

            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);

            string[] 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)
                    {
                        polygon = new Polygon();

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

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

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

            return(_Geoms);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        /// <summary>
        /// This method produces instances of type <see cref="GeoAPI.Geometries.IMultiLineString"/>.
        /// </summary>
        /// <returns>The created geometries</returns>
        internal override Collection <IGeometry> createGeometries()
        {
            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);

            string[] 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)
                    {
                        GeometryFactory geomFactory = new LineStringFactory(_GeomReader, _FeatureTypeInfo)
                        {
                            AxisOrder = AxisOrder
                        };
                        Collection <IGeometry> lineStrings = geomFactory.createGeometries();

                        var lineStringArray = new ILineString[lineStrings.Count];
                        var i = 0;
                        foreach (ILineString lineString in lineStrings)
                        {
                            lineStringArray[i++] = lineString;
                        }

                        _Geoms.Add(Factory.CreateMultiLineString(lineStringArray));
                        geomFound = true;
                    }
                    if (geomFound)
                    {
                        AddLabel(labelValue[0], _Geoms[_Geoms.Count - 1]);
                    }
                    geomFound = false;
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("An exception occured while parsing a multi-lineString geometry: " + ex.Message);
                throw ex;
            }

            return(_Geoms);
        }
Exemplo n.º 5
0
        /// <summary>
        /// This method detects the geometry type from 'GetFeatureByOid' response and uses a geometry factory to create the 
        /// appropriate geometries.
        /// </summary>
        /// <returns></returns>
        internal override Collection<IGeometry> createGeometries()
        {
            GeometryFactory geomFactory = null;

            string geometryTypeString = string.Empty;
            string serviceException = null;

            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, _LabelInfo);
                            geometryTypeString = "MultiPointPropertyType";
                            break;
                        }
                        if (multiLineStringNodeAlt.Matches(_XmlReader))
                        {
                            geomFactory = new MultiLineStringFactory(_HttpClientUtil, _FeatureTypeInfo, _LabelInfo);
                            geometryTypeString = "MultiLineStringPropertyType";
                            break;
                        }
                        if (multiPolygonNodeAlt.Matches(_XmlReader))
                        {
                            geomFactory = new MultiPolygonFactory(_HttpClientUtil, _FeatureTypeInfo, _LabelInfo);
                            geometryTypeString = "MultiPolygonPropertyType";
                            break;
                        }
                    }

                    if (pointNode.Matches(_XmlReader))
                    {
                        geomFactory = new PointFactory(_HttpClientUtil, _FeatureTypeInfo, _LabelInfo);
                        geometryTypeString = "PointPropertyType";
                        break;
                    }
                    if (lineStringNode.Matches(_XmlReader))
                    {
                        geomFactory = new LineStringFactory(_HttpClientUtil, _FeatureTypeInfo, _LabelInfo);
                        geometryTypeString = "LineStringPropertyType";
                        break;
                    }
                    if (polygonNode.Matches(_XmlReader))
                    {
                        geomFactory = new PolygonFactory(_HttpClientUtil, _FeatureTypeInfo, _LabelInfo);
                        geometryTypeString = "PolygonPropertyType";
                        break;
                    }
                    if (_ServiceExceptionNode.Matches(_XmlReader))
                    {
                        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 _QuickGeometries
                           ? geomFactory.createQuickGeometries(geometryTypeString)
                           : geomFactory.createGeometries();
            return _Geoms;
        }
Exemplo n.º 6
0
        /// <summary>
        /// This method produces instances of type <see cref="GeoAPI.Geometries.IPolygon"/>.
        /// </summary>
        /// <returns>The created geometries</returns>
        internal override Collection<IGeometry> createGeometries()
        {
            XmlReader outerBoundaryReader = null;
            XmlReader innerBoundariesReader = null;

            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);
            string[] 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)
                {
                    ILinearRing shell = null;
                    var holes = new List<ILinearRing>();
                    while ((_GeomReader = GetSubReaderOf(_FeatureReader, labelValue, polygonNode)) != null)
                    {
                        //polygon = new Polygon();

                        if (
                            (outerBoundaryReader =
                             GetSubReaderOf(_GeomReader, null, outerBoundaryNodeAlt, linearRingNode, _CoordinatesNode)) !=
                            null)
                            shell = Factory.CreateLinearRing(ParseCoordinates(outerBoundaryReader));

                        while (
                            (innerBoundariesReader =
                             GetSubReaderOf(_GeomReader, null, innerBoundaryNodeAlt, linearRingNode, _CoordinatesNode)) !=
                            null)
                            holes.Add(Factory.CreateLinearRing(ParseCoordinates(innerBoundariesReader)));

                        _Geoms.Add(Factory.CreatePolygon(shell, holes.ToArray()));
                        geomFound = true;
                    }
                    if (geomFound) AddLabel(labelValue[0], _Geoms[_Geoms.Count - 1]);
                    geomFound = false;
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("An exception occured while parsing a polygon geometry: " + ex.Message);
                throw ex;
            }

            return _Geoms;
        }
Exemplo n.º 7
0
        /// <summary>
        /// This method produces instances of type <see cref="GeoAPI.Geometries.IMultiPolygon"/>.
        /// </summary>
        /// <returns>The created geometries</returns>
        internal override Collection<IGeometry> createGeometries()
        {
            //IMultiPolygon multiPolygon = null;

            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);
            string[] 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)
                    {
                        GeometryFactory geomFactory = new PolygonFactory(_GeomReader, _FeatureTypeInfo);
                        var polygons = geomFactory.createGeometries();

                        var polygonArray = new IPolygon[polygons.Count];
                        var i = 0;
                        foreach (IPolygon polygon in polygons)
                            polygonArray[i++] = polygon;

                        _Geoms.Add(Factory.CreateMultiPolygon(polygonArray));
                        geomFound = true;
                    }
                    if (geomFound) AddLabel(labelValue[0], _Geoms[_Geoms.Count - 1]);
                    geomFound = false;
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("An exception occured while parsing a multi-polygon geometry: " + ex.Message);
                throw ex;
            }

            return _Geoms;
        }
Exemplo n.º 8
0
        /// <summary>
        /// This method produces instances of type <see cref="GeoAPI.Geometries.IMultiLineString"/>.
        /// </summary>
        /// <returns>The created geometries</returns>
        internal override Collection<IGeometry> createGeometries()
        {
            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);
            string[] 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)
                    {
                        GeometryFactory geomFactory = new LineStringFactory(_GeomReader, _FeatureTypeInfo);
                        Collection<IGeometry> lineStrings = geomFactory.createGeometries();

                        var lineStringArray = new ILineString[lineStrings.Count];
                        var i = 0;
                        foreach (ILineString lineString in lineStrings)
                            lineStringArray[i++] = lineString;

                        _Geoms.Add(Factory.CreateMultiLineString(lineStringArray));
                        geomFound = true;
                    }
                    if (geomFound) AddLabel(labelValue[0], _Geoms[_Geoms.Count - 1]);
                    geomFound = false;
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("An exception occured while parsing a multi-lineString geometry: " + ex.Message);
                throw ex;
            }

            return _Geoms;
        }
Exemplo n.º 9
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 posNode = new PathNode("http://www.opengis.net/gml", "pos",
                                          (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, posNode);
     _ServiceExceptionNode = new AlternativePathNodesCollection(ogcServiceExceptionNode, exceptionTextNode,
                                                                serviceExceptionNode);
     _FeatureNode = new PathNode(_FeatureTypeInfo.FeatureTypeNamespace, _FeatureTypeInfo.Name,
                                 (NameTable) _XmlReader.NameTable);
 }
Exemplo n.º 10
0
        /// <summary>
        /// This method produces instances of type <see cref="NetTopologySuite.Geometries.Polygon"/>.
        /// </summary>
        /// <returns>The created geometries</returns>
        internal override Collection <Geometry> createGeometries()
        {
            XmlReader outerBoundaryReader   = null;
            XmlReader innerBoundariesReader = null;

            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>();
            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)
                {
                    LinearRing shell = null;
                    var        holes = new List <LinearRing>();
                    while ((_GeomReader = GetSubReaderOf(_FeatureReader, labelValues, polygonNode)) != null)
                    {
                        //polygon = new Polygon();

                        if (
                            (outerBoundaryReader =
                                 GetSubReaderOf(_GeomReader, null, outerBoundaryNodeAlt, linearRingNode, _CoordinatesNode)) !=
                            null)
                        {
                            shell = Factory.CreateLinearRing(ParseCoordinates(outerBoundaryReader));
                        }

                        while (
                            (innerBoundariesReader =
                                 GetSubReaderOf(_GeomReader, null, innerBoundaryNodeAlt, linearRingNode, _CoordinatesNode)) !=
                            null)
                        {
                            holes.Add(Factory.CreateLinearRing(ParseCoordinates(innerBoundariesReader)));
                        }

                        _Geoms.Add(Factory.CreatePolygon(shell, holes.ToArray()));
                        geomFound = true;
                    }
                    if (geomFound)
                    {
                        AddLabel(labelValues, _Geoms[_Geoms.Count - 1]);
                    }
                    geomFound = false;
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("An exception occured while parsing a polygon geometry: " + ex.Message);
                throw ex;
            }

            return(_Geoms);
        }
Exemplo n.º 11
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()
        {
            GeometryFactory geomFactory = null;

            string geometryTypeString = string.Empty;
            string serviceException   = null;

            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, _LabelInfo);
                            geometryTypeString = "MultiPointPropertyType";
                            break;
                        }
                        if (MultiLineStringNodeAlt.Matches(_XmlReader))
                        {
                            geomFactory        = new MultiLineStringFactory(_HttpClientUtil, _FeatureTypeInfo, _LabelInfo);
                            geometryTypeString = "MultiLineStringPropertyType";
                            break;
                        }
                        if (MultiPolygonNodeAlt.Matches(_XmlReader))
                        {
                            geomFactory        = new MultiPolygonFactory(_HttpClientUtil, _FeatureTypeInfo, _LabelInfo);
                            geometryTypeString = "MultiPolygonPropertyType";
                            break;
                        }
                    }

                    if (pointNode.Matches(_XmlReader))
                    {
                        geomFactory        = new PointFactory(_HttpClientUtil, _FeatureTypeInfo, _LabelInfo);
                        geometryTypeString = "PointPropertyType";
                        break;
                    }
                    if (lineStringNode.Matches(_XmlReader))
                    {
                        geomFactory        = new LineStringFactory(_HttpClientUtil, _FeatureTypeInfo, _LabelInfo);
                        geometryTypeString = "LineStringPropertyType";
                        break;
                    }
                    if (polygonNode.Matches(_XmlReader))
                    {
                        geomFactory        = new PolygonFactory(_HttpClientUtil, _FeatureTypeInfo, _LabelInfo);
                        geometryTypeString = "PolygonPropertyType";
                        break;
                    }
                    if (_ServiceExceptionNode.Matches(_XmlReader))
                    {
                        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)
            {
                geomFactory.AxisOrder = AxisOrder;

                var res = _QuickGeometries
                    ? geomFactory.createQuickGeometries(geometryTypeString)
                    : geomFactory.createGeometries();

                geomFactory.Dispose();
                return(res);
            }


            return(_Geoms);
        }