This class produces instances of type Mapsui.Geometries.LineString. The base class is GeometryFactory.
상속: GeometryFactory
예제 #1
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       labelValues             = new Dictionary <string, string>();
            bool      geomFound = false;

            try
            {
                // Reading the entire feature's node makes it possible to collect label values that may appear before or after the geometry property
                while ((FeatureReader = GetSubReaderOf(XmlReader, null, FeatureNode)) != null)
                {
                    while (
                        (GeomReader =
                             GetSubReaderOf(FeatureReader, labelValues, multiLineStringNodeAlt, lineStringMemberNodeAlt)) !=
                        null)
                    {
                        var             multiLineString = new MultiLineString();
                        GeometryFactory geomFactory     = new LineStringFactory(GeomReader, FeatureTypeInfo)
                        {
                            AxisOrder = AxisOrder
                        };
                        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(AddLabel(labelValues, Geoms[Geoms.Count - 1]));
                    }
                    geomFound = false;
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError("An exception occured while parsing a multi-lineString geometry: " + ex.Message);
                throw;
            }

            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(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);
        }
예제 #3
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 UnspecifiedGeometryFactoryWfs100Gml2(_httpClientUtil, _featureTypeInfo,
                                                                                   _multiGeometries, _quickGeometries);
                        break;
                }

                geomFactory.CreateGeometries(features);
                geomFactory.Dispose();
                return features;
            }
                // 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(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;
        }
예제 #5
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 (LineString lineString in lineStrings)
                            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;
        }