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

            IPathNode polygonNode = new PathNode(_GMLNS, "Polygon", (NameTable)_xmlReader.NameTable);
            IPathNode outerBoundaryNode = new PathNode(_GMLNS, "outerBoundaryIs", (NameTable)_xmlReader.NameTable);
            IPathNode exteriorNode = new PathNode(_GMLNS, "exterior", (NameTable)_xmlReader.NameTable);
            IPathNode outerBoundaryNodeAlt = new AlternativePathNodesCollection(outerBoundaryNode, exteriorNode);
            IPathNode innerBoundaryNode = new PathNode(_GMLNS, "innerBoundaryIs", (NameTable)_xmlReader.NameTable);
            IPathNode interiorNode = new PathNode(_GMLNS, "interior", (NameTable)_xmlReader.NameTable);
            IPathNode innerBoundaryNodeAlt = new AlternativePathNodesCollection(innerBoundaryNode, interiorNode);
            IPathNode linearRingNode = new PathNode(_GMLNS, "LinearRing", (NameTable)_xmlReader.NameTable);
            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, polygonNode);

                        ILinearRing shell = null;
                        List<ILinearRing> holes = new List<ILinearRing>();

                        if (
                            (outerBoundaryReader =
                                GetSubReaderOf(_geomReader, null, outerBoundaryNodeAlt, linearRingNode, _CoordinatesNode)) !=
                            null)
                            shell = new LinearRing(ParseCoordinates(outerBoundaryReader));

                        while (
                            (innerBoundariesReader =
                                GetSubReaderOf(_geomReader, null, innerBoundaryNodeAlt, linearRingNode, _CoordinatesNode)) !=
                            null)
                            holes.Add(new LinearRing(ParseCoordinates(innerBoundariesReader)));

                        Polygon polygon = new Polygon(shell, holes.ToArray());
                        shp = new SimpleGisShape(polygon);
                        shp.IsSelected = isSelected;
                        shp.UID = uid;
                        
                        _shapes.Add(shp);
                        FillShapeFields(shp, ll);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

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

            IPathNode multiPolygonNode = new PathNode(_GMLNS, "MultiPolygon", (NameTable)_xmlReader.NameTable);
            IPathNode multiSurfaceNode = new PathNode(_GMLNS, "MultiSurface", (NameTable)_xmlReader.NameTable);
            IPathNode multiPolygonNodeAlt = new AlternativePathNodesCollection(multiPolygonNode, multiSurfaceNode);
            IPathNode polygonMemberNode = new PathNode(_GMLNS, "polygonMember", (NameTable)_xmlReader.NameTable);
            IPathNode surfaceMemberNode = new PathNode(_GMLNS, "surfaceMember", (NameTable)_xmlReader.NameTable);
            IPathNode polygonMemberNodeAlt = new AlternativePathNodesCollection(polygonMemberNode, surfaceMemberNode);
            IPathNode linearRingNode = new PathNode(_GMLNS, "LinearRing", (NameTable)_xmlReader.NameTable);
            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, multiPolygonNodeAlt, polygonMemberNodeAlt);

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

                        var polygons = new List<IPolygon>();

                        foreach (var shp1 in shpPolygons)
                        {
                            polygons.Add(shp1.Geometry as IPolygon);                            
                        }

                        MultiPolygon multiPolygon = new MultiPolygon(polygons.ToArray());
                        shp = new SimpleGisShape(multiPolygon);
                        shp.IsSelected = isSelected;
                        shp.UID = uid;

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

            return _shapes;
        }
コード例 #3
0
        /// <summary>
        /// This method produces instances of type <see cref="LineString"/>.
        /// </summary>
        /// <returns>The created geometries</returns>
        internal override Collection<SimpleGisShape> createGeometries()
        {
            IPathNode lineStringNode = new PathNode(_GMLNS, "LineString", (NameTable)_xmlReader.NameTable);
            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, lineStringNode, _CoordinatesNode);

                        LineString l = new LineString(ParseCoordinates(_geomReader));
                        var shp = new SimpleGisShape(l);
                        shp.IsSelected = isSelected;
                        shp.UID = uid;
                        _shapes.Add(shp);
                        FillShapeFields(shp, ll);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return _shapes;
        }
コード例 #4
0
        /// <summary>
        /// This method produces instances of type collection of <see cref="GIS_Shape"/>.
        /// </summary>
        /// <returns>The created geometries</returns>
        internal override Collection<SimpleGisShape> createGeometries()
        {
            IPathNode pointNode = new PathNode(_GMLNS, "Point", (NameTable)_xmlReader.NameTable);
            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, pointNode, _CoordinatesNode);
                        if (_geomReader == null)
                        {
                            throw new Exception("Geometry of type point not found (if this is a ttkls file, please check the shapetype field)");
                        }

                        Coordinate c = ParseCoordinates(_geomReader)[0];
                        var shp = new SimpleGisShape(new Point(c));
                        shp.IsSelected = isSelected;
                        shp.UID = uid;
                        _shapes.Add(shp);

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

            return _shapes;
        }
コード例 #5
0
        /// <summary>
        /// This method initializes path nodes needed by the derived classes.
        /// </summary>
        private void initializePathNodes()
        {
            IPathNode coordinatesNode = new PathNode("http://www.opengis.net/gml", "coordinates",
                                                        (NameTable)_xmlReader.NameTable);
            IPathNode posListNode = new PathNode("http://www.opengis.net/gml", "posList",
                                                    (NameTable)_xmlReader.NameTable);
            IPathNode ogcServiceExceptionNode = new PathNode("http://www.opengis.net/ogc", "ServiceException",
                                                                (NameTable)_xmlReader.NameTable);
            IPathNode serviceExceptionNode = new PathNode("", "ServiceException", (NameTable)_xmlReader.NameTable);
            //ServiceExceptions without ogc prefix are returned by deegree. PDD.
            IPathNode exceptionTextNode = new PathNode("http://www.opengis.net/ows", "ExceptionText",
                                                        (NameTable)_xmlReader.NameTable);
            _CoordinatesNode = new AlternativePathNodesCollection(coordinatesNode, posListNode);
            _serviceExceptionNode = new AlternativePathNodesCollection(ogcServiceExceptionNode, exceptionTextNode,
                                                                        serviceExceptionNode);
            _featureNode = new PathNode(_featureTypeInfo.FeatureTypeNamespace, _featureTypeInfo.Name,
                                        (NameTable)_xmlReader.NameTable);

            _propertyNode = new PathNode("http://www.itacasoft.com/GML", "PROPERTIES",
                                                        (NameTable)_xmlReader.NameTable);

            _boundedByNode = new PathNode("http://www.opengis.net/gml", "boundedBy",
                                                        (NameTable)_xmlReader.NameTable);
        }
コード例 #6
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;
        }
コード例 #7
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;
        }