示例#1
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);
        }
示例#2
0
        public Features ExecuteIntersectionQuery(BoundingBox bbox)
        {
            if (_featureTypeInfo == null)
            {
                return(null);
            }

            var features = new Features();

            string geometryTypeString = _featureTypeInfo.Geometry.GeometryType;

            GeometryFactory geomFactory = null;

            if (!string.IsNullOrEmpty(_label))
            {
                _featureTypeInfo.LableField = _label;
                _quickGeometries            = false;
            }

            // Configuration for GetFeature request */
            var config = new WFSClientHttpConfigurator(_textResources);

            config.ConfigureForWfsGetFeatureRequest(_httpClientUtil, _featureTypeInfo, _label, bbox, _ogcFilter,
                                                    _getFeatureGetRequest);

            try
            {
                switch (geometryTypeString)
                {
                /* Primitive geometry elements */

                // GML2
                case "PointPropertyType":
                    geomFactory = new PointFactory(_httpClientUtil, _featureTypeInfo);
                    break;

                // GML2
                case "LineStringPropertyType":
                    geomFactory = new LineStringFactory(_httpClientUtil, _featureTypeInfo);
                    break;

                // GML2
                case "PolygonPropertyType":
                    geomFactory = new PolygonFactory(_httpClientUtil, _featureTypeInfo);
                    break;

                // GML3
                case "CurvePropertyType":
                    geomFactory = new LineStringFactory(_httpClientUtil, _featureTypeInfo);
                    break;

                // GML3
                case "SurfacePropertyType":
                    geomFactory = new PolygonFactory(_httpClientUtil, _featureTypeInfo);
                    break;

                /* Aggregate geometry elements */

                // GML2
                case "MultiPointPropertyType":
                    if (_multiGeometries)
                    {
                        geomFactory = new MultiPointFactory(_httpClientUtil, _featureTypeInfo);
                    }
                    else
                    {
                        geomFactory = new PointFactory(_httpClientUtil, _featureTypeInfo);
                    }
                    break;

                // GML2
                case "MultiLineStringPropertyType":
                    if (_multiGeometries)
                    {
                        geomFactory = new MultiLineStringFactory(_httpClientUtil, _featureTypeInfo);
                    }
                    else
                    {
                        geomFactory = new LineStringFactory(_httpClientUtil, _featureTypeInfo);
                    }
                    break;

                // GML2
                case "MultiPolygonPropertyType":
                    if (_multiGeometries)
                    {
                        geomFactory = new MultiPolygonFactory(_httpClientUtil, _featureTypeInfo);
                    }
                    else
                    {
                        geomFactory = new PolygonFactory(_httpClientUtil, _featureTypeInfo);
                    }
                    break;

                // GML3
                case "MultiCurvePropertyType":
                    if (_multiGeometries)
                    {
                        geomFactory = new MultiLineStringFactory(_httpClientUtil, _featureTypeInfo);
                    }
                    else
                    {
                        geomFactory = new LineStringFactory(_httpClientUtil, _featureTypeInfo);
                    }
                    break;

                // GML3
                case "MultiSurfacePropertyType":
                    if (_multiGeometries)
                    {
                        geomFactory = new MultiPolygonFactory(_httpClientUtil, _featureTypeInfo);
                    }
                    else
                    {
                        geomFactory = new PolygonFactory(_httpClientUtil, _featureTypeInfo);
                    }
                    break;

                // .e.g. 'gml:GeometryAssociationType' or 'GeometryPropertyType'
                //It's better to set the geometry type manually, if it is known...
                default:
                    geomFactory = new UnspecifiedGeometryFactory_WFS1_0_0_GML2(_httpClientUtil, _featureTypeInfo,
                                                                               _multiGeometries, _quickGeometries);
                    break;
                }

                var geoms = geomFactory.CreateGeometries(features);
                geomFactory.Dispose();
                return(features);
            }
            // Free resources (net connection of geometry factory)
            finally
            {
                if (geomFactory != null)
                {
                    geomFactory.Dispose();
                }
            }
        }
示例#3
0
        public System.Collections.ObjectModel.Collection <SharpMap.Geometries.Geometry> GetGeometriesInView(SharpMap.Geometries.BoundingBox bbox)
        {
            if (_FeatureTypeInfo == null)
            {
                return(null);
            }

            System.Collections.ObjectModel.Collection <Geometry> geoms = new System.Collections.ObjectModel.Collection <Geometry>();

            string geometryTypeString = _FeatureTypeInfo.Geometry._GeometryType;

            GeometryFactory geomFactory = null;

            if (!string.IsNullOrEmpty(_Label))
            {
                _LabelInfo = new FeatureDataTable();
                _LabelInfo.Columns.Add(_Label);
                // Turn off quick geometries, if a label is applied...
                _QuickGeometries = false;
            }

            // Configuration for GetFeature request */
            WFSClientHTTPConfigurator config = new WFSClientHTTPConfigurator(_TextResources);

            config.configureForWfsGetFeatureRequest(_HttpClientUtil, _FeatureTypeInfo, _Label, bbox, _OGCFilter, _GetFeatureGETRequest);

            try
            {
                switch (geometryTypeString)
                {
                /* Primitive geometry elements */

                // GML2
                case "PointPropertyType":
                    geomFactory = new PointFactory(_HttpClientUtil, _FeatureTypeInfo, _LabelInfo);
                    break;

                // GML2
                case "LineStringPropertyType":
                    geomFactory = new LineStringFactory(_HttpClientUtil, _FeatureTypeInfo, _LabelInfo);
                    break;

                // GML2
                case "PolygonPropertyType":
                    geomFactory = new PolygonFactory(_HttpClientUtil, _FeatureTypeInfo, _LabelInfo);
                    break;

                // GML3
                case "CurvePropertyType":
                    geomFactory = new LineStringFactory(_HttpClientUtil, _FeatureTypeInfo, _LabelInfo);
                    break;

                // GML3
                case "SurfacePropertyType":
                    geomFactory = new PolygonFactory(_HttpClientUtil, _FeatureTypeInfo, _LabelInfo);
                    break;

                /* Aggregate geometry elements */

                // GML2
                case "MultiPointPropertyType":
                    if (_MultiGeometries)
                    {
                        geomFactory = new MultiPointFactory(_HttpClientUtil, _FeatureTypeInfo, _LabelInfo);
                    }
                    else
                    {
                        geomFactory = new PointFactory(_HttpClientUtil, _FeatureTypeInfo, _LabelInfo);
                    }
                    break;

                // GML2
                case "MultiLineStringPropertyType":
                    if (_MultiGeometries)
                    {
                        geomFactory = new MultiLineStringFactory(_HttpClientUtil, _FeatureTypeInfo, _LabelInfo);
                    }
                    else
                    {
                        geomFactory = new LineStringFactory(_HttpClientUtil, _FeatureTypeInfo, _LabelInfo);
                    }
                    break;

                // GML2
                case "MultiPolygonPropertyType":
                    if (_MultiGeometries)
                    {
                        geomFactory = new MultiPolygonFactory(_HttpClientUtil, _FeatureTypeInfo, _LabelInfo);
                    }
                    else
                    {
                        geomFactory = new PolygonFactory(_HttpClientUtil, _FeatureTypeInfo, _LabelInfo);
                    }
                    break;

                // GML3
                case "MultiCurvePropertyType":
                    if (_MultiGeometries)
                    {
                        geomFactory = new MultiLineStringFactory(_HttpClientUtil, _FeatureTypeInfo, _LabelInfo);
                    }
                    else
                    {
                        geomFactory = new LineStringFactory(_HttpClientUtil, _FeatureTypeInfo, _LabelInfo);
                    }
                    break;

                // GML3
                case "MultiSurfacePropertyType":
                    if (_MultiGeometries)
                    {
                        geomFactory = new MultiPolygonFactory(_HttpClientUtil, _FeatureTypeInfo, _LabelInfo);
                    }
                    else
                    {
                        geomFactory = new PolygonFactory(_HttpClientUtil, _FeatureTypeInfo, _LabelInfo);
                    }
                    break;

                // .e.g. 'gml:GeometryAssociationType' or 'GeometryPropertyType'
                //It's better to set the geometry type manually, if it is known...
                default:
                    geomFactory = new UnspecifiedGeometryFactory_WFS1_0_0_GML2(_HttpClientUtil, _FeatureTypeInfo, _MultiGeometries, _QuickGeometries, _LabelInfo);
                    geoms       = geomFactory.createGeometries();
                    return(geoms);
                }

                geoms = _QuickGeometries ? geomFactory.createQuickGeometries(geometryTypeString) : geomFactory.createGeometries();
                geomFactory.Dispose();

                return(geoms);
            }
            // Free resources (net connection of geometry factory)
            finally
            {
                geomFactory.Dispose();
            }
        }
示例#4
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(List <IFeature> features)
        {
            GeometryFactory?geomFactory = null;

            var 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?.Dispose();
                            geomFactory        = new MultiPointFactory(_httpClientUtil, FeatureTypeInfo);
                            geometryTypeString = "MultiPointPropertyType";
                            break;
                        }
                        if (multiLineStringNodeAlt.Matches(XmlReader))
                        {
                            geomFactory?.Dispose();
                            geomFactory        = new MultiLineStringFactory(_httpClientUtil, FeatureTypeInfo);
                            geometryTypeString = "MultiLineStringPropertyType";
                            break;
                        }
                        if (multiPolygonNodeAlt.Matches(XmlReader))
                        {
                            geomFactory?.Dispose();
                            geomFactory        = new MultiPolygonFactory(_httpClientUtil, FeatureTypeInfo);
                            geometryTypeString = "MultiPolygonPropertyType";
                            break;
                        }
                    }

                    if (pointNode.Matches(XmlReader))
                    {
                        geomFactory?.Dispose();
                        geomFactory        = new PointFactory(_httpClientUtil, FeatureTypeInfo);
                        geometryTypeString = "PointPropertyType";
                        break;
                    }
                    if (lineStringNode.Matches(XmlReader))
                    {
                        geomFactory?.Dispose();
                        geomFactory        = new LineStringFactory(_httpClientUtil, FeatureTypeInfo);
                        geometryTypeString = "LineStringPropertyType";
                        break;
                    }
                    if (polygonNode.Matches(XmlReader))
                    {
                        geomFactory?.Dispose();
                        geomFactory        = new PolygonFactory(_httpClientUtil, FeatureTypeInfo);
                        geometryTypeString = "PolygonPropertyType";
                        break;
                    }
                    if (ServiceExceptionNode?.Matches(XmlReader) ?? false)
                    {
                        var 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);
        }