/// <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; }
/// <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; }
/// <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; }
/// <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; }
protected void FillShapeFields(SimpleGisShape shp, List<string> fieldvalues) { for (int i = 0; i < fieldvalues.Count; i++) { shp[_fieldNames[i]] = fieldvalues[i]; } }