/// <summary> /// This method produces instances of type <see cref="Mapsui.Geometries.MultiLineString"/>. /// </summary> /// <returns>The created geometries</returns> internal override Collection <Geometry> createGeometries() { 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(); foreach (LineString lineString in lineStrings) { multiLineString.LineStrings.Add(lineString); } _Geoms.Add(multiLineString); geomFound = true; } if (geomFound) { AddLabel(labelValue[0], _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); }
/// <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) { return(_QuickGeometries ? geomFactory.createQuickGeometries(geometryTypeString) : geomFactory.createGeometries()); } return(_Geoms); }
/// <summary> /// This method produces instances of type <see cref="Mapsui.Geometries.MultiLineString"/>. /// </summary> /// <returns>The created geometries</returns> internal override Collection<Geometry> createGeometries() { 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(); foreach (LineString lineString in lineStrings) multiLineString.LineStrings.Add(lineString); _Geoms.Add(multiLineString); geomFound = true; } if (geomFound) AddLabel(labelValue[0], _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; }
/// <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) return _QuickGeometries ? geomFactory.createQuickGeometries(geometryTypeString) : geomFactory.createGeometries(); return _Geoms; }
public Collection<Geometry> GetGeometriesInView(BoundingBox bbox) { if (_FeatureTypeInfo == null) return null; Collection<Geometry> geoms = new Collection<Geometry>(); 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 { geomFactory.Dispose(); } }