コード例 #1
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;
        }
コード例 #2
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);
        }
コード例 #3
0
ファイル: WFSClient.cs プロジェクト: PedroMaitan/sharpmap
        /// <summary>
        /// Gets the features within the specified <see cref="GeoAPI.Geometries.Envelope"/>
        /// </summary>
        /// <param name="bbox"></param>
        /// <returns>Features within the specified <see cref="GeoAPI.Geometries.Envelope"/></returns>
        public Collection<IGeometry> GetGeometriesInView(Envelope bbox)
        {
            if (_featureTypeInfo == null) return null;

            var geoms = new Collection<IGeometry>();

            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
            {
                if (geomFactory != null)
                {
                    geomFactory.Dispose();
                }
            }
        }
コード例 #4
0
ファイル: WFSClient.cs プロジェクト: geobabbler/SharpMap
        /// <summary>
        /// Gets the features within the specified <see cref="GeoAPI.Geometries.Envelope"/>
        /// </summary>
        /// <param name="bbox"></param>
        /// <returns>Features within the specified <see cref="GeoAPI.Geometries.Envelope"/></returns>
        public IEnumerable<IGeometry> GetGeometriesInView(Envelope bbox, CancellationToken? cancellationToken = null)
        {
            if (_featureTypeInfo == null) return null;

            var geoms = new Collection<IGeometry>();

            string geometryTypeString = _featureTypeInfo.Geometry._GeometryType;

            GeometryFactory geomFactory = null;

            if (!string.IsNullOrEmpty(_label))
            {
                var ff = FeatureFactory.CreateInt32(GeoAPI.GeometryServiceProvider.Instance.CreateGeometryFactory(SRID),
                    new FeatureAttributeDefinition
                    {
                        AttributeName = "Label",
                        Default = string.Empty,
                        AttributeType = typeof(string),
                        IsNullable = true
                    });
                _labelInfo = new FeatureCollection<int>(ff);
                // Turn off quick geometries, if a label is applied...
                _quickGeometries = false;
            }

            // Configuration for GetFeatureByOid 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
            {
                if (geomFactory != null)
                {
                    geomFactory.Dispose();
                }
            }
        }