Ejemplo n.º 1
0
        internal string DetectGeometryType()
        {
            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))
                        {
                            geometryTypeString = "MultiPointPropertyType";
                            break;
                        }
                        if (multiLineStringNodeAlt.Matches(_xmlReader))
                        {
                            geometryTypeString = "MultiLineStringPropertyType";
                            break;
                        }
                        if (multiPolygonNodeAlt.Matches(_xmlReader))
                        {
                            geometryTypeString = "MultiPolygonPropertyType";
                            break;
                        }
                    }

                    if (pointNode.Matches(_xmlReader))
                    {
                        geometryTypeString = "PointPropertyType";
                        break;
                    }
                    if (lineStringNode.Matches(_xmlReader))
                    {
                        geometryTypeString = "LineStringPropertyType";
                        break;
                    }
                    if (polygonNode.Matches(_xmlReader))
                    {
                        geometryTypeString = "PolygonPropertyType";
                        break;
                    }
                    if (_serviceExceptionNode.Matches(_xmlReader))
                    {
                        serviceException = _xmlReader.ReadInnerXml();
                        throw new Exception("A service exception occured: " + serviceException);
                    }
                }
            }

            return geometryTypeString;
        }
Ejemplo n.º 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;
        }