コード例 #1
0
        /// <summary>
        /// This method produces instances of type <see cref="MultiLineString"/>.
        /// </summary>
        /// <returns>The created geometries</returns>
        internal override Collection<SimpleGisShape> createGeometries()
        {
            SimpleGisShape shp = null;

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

            try
            {
                ParseBoundingBox();

                // 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, null, _propertyNode)) != null)
                    {
                        bool isSelected;
                        int uid;
                        List<string> ll = ParseProperties(_geomReader, out isSelected, out uid);

                        _geomReader = GetSubReaderOf(_featureReader, labelValue, multiLineStringNodeAlt, lineStringMemberNodeAlt);

                        GeometryFactory geomFactory = new LineStringFactory(_geomReader, _featureTypeInfo, _fieldNames);
                        Collection<SimpleGisShape> shpLineStrings = geomFactory.createGeometries();

                        var lineStrings = new List<ILineString>();

                        foreach (var lineString in shpLineStrings)
                        {
                            lineStrings.Add(lineString.Geometry as ILineString);
                        }
                        
                        MultiLineString multiLineString = new MultiLineString(lineStrings.ToArray());
                        shp = new SimpleGisShape(multiLineString);
                        shp.IsSelected = isSelected;
                        shp.UID = uid;

                        _shapes.Add(shp);
                        FillShapeFields(shp, ll);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return _shapes;
        }
コード例 #2
0
        /// <summary>
        /// This method detects the geometry type from 'GetFeature' response and uses a geometry factory to create the 
        /// appropriate geometries.
        /// </summary>
        /// <returns>Collection of GIS elements</returns>
        internal override Collection<SimpleGisShape> 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(_xmlReader, _featureTypeInfo, _fieldNames);
                            geometryTypeString = "MultiPointPropertyType";
                            break;
                        }
                        if (multiLineStringNodeAlt.Matches(_xmlReader))
                        {
                            geomFactory = new MultiLineStringFactory(_xmlReader, _featureTypeInfo, _fieldNames);
                            geometryTypeString = "MultiLineStringPropertyType";
                            break;
                        }
                        if (multiPolygonNodeAlt.Matches(_xmlReader))
                        {
                            geomFactory = new MultiPolygonFactory(_xmlReader, _featureTypeInfo, _fieldNames);
                            geometryTypeString = "MultiPolygonPropertyType";
                            break;
                        }
                    }

                    if (pointNode.Matches(_xmlReader))
                    {
                        geomFactory = new PointFactory(_xmlReader, _featureTypeInfo, _fieldNames);
                        geometryTypeString = "PointPropertyType";
                        _featureTypeInfo.Geometry._GeometryType = "PointPropertyType";
                        break;
                    }
                    if (lineStringNode.Matches(_xmlReader))
                    {
                        geomFactory = new LineStringFactory(_xmlReader, _featureTypeInfo, _fieldNames);
                        geometryTypeString = "LineStringPropertyType";
                        break;
                    }
                    if (polygonNode.Matches(_xmlReader))
                    {
                        geomFactory = new PolygonFactory(_xmlReader, _featureTypeInfo, _fieldNames);
                        geometryTypeString = "PolygonPropertyType";
                        break;
                    }
                    if (_serviceExceptionNode.Matches(_xmlReader))
                    {
                        serviceException = _xmlReader.ReadInnerXml();
                        throw new Exception("A service exception occured: " + serviceException);
                    }
                }
            }

            _featureTypeInfo.Geometry._GeometryType = geometryTypeString;

            if (geomFactory != null)
                return geomFactory.createGeometries();
            return _shapes;
        }