public void BeginGeometry(OpenGisGeometryType type) { if (_geomCollection == null) { _geomCollection = new SinkGeometryCollection <OpenGisGeometryType>(type); if (type == OpenGisGeometryType.GeometryCollection) { _isGeometryCollection = true; } } _currentGeometry = new SinkGeometry <OpenGisGeometryType>(type); if (_isGeometryCollection && _nestLevel > 0) { if (_nestLevel == 1) { _geomCollection.SubItems.Add(new SinkGeometryCollection <OpenGisGeometryType>(type)); } _geomCollection.SubItems.Last().Add(_currentGeometry); } else { _geomCollection.Add(_currentGeometry); } _nestLevel++; }
private IGeometryObject ConstructGeometryPart(SinkGeometry <OpenGisGeometryType> geomPart) { IGeometryObject geometry = null; switch (geomPart.GeometryType) { case OpenGisGeometryType.Point: geometry = new Point(geomPart[0][0]); break; case OpenGisGeometryType.MultiPoint: MultiPoint mp = new MultiPoint(geomPart.Select(g => new Point(g[0])).ToList()); geometry = mp; break; case OpenGisGeometryType.LineString: geometry = new LineString(geomPart[0]); break; case OpenGisGeometryType.MultiLineString: geometry = new MultiLineString(geomPart.Select(line => new LineString(line)) .ToList() ); break; case OpenGisGeometryType.Polygon: geometry = new Polygon(geomPart.Select(line => new LineString(line)) .ToList() ); break; case OpenGisGeometryType.MultiPolygon: //geometry = new MultiPolygon(geomPart.Skip(1) // .Select(g => (Polygon)ConstructGeometryPart(g)) // .ToList()); geometry = new MultiPolygon(); break; default: throw new NotSupportedException("Geometry type " + geomPart.GeometryType.ToString() + " is not supported yet."); } return(geometry); }
public void EndGeometry() { _nestLevel--; _currentGeometry = null; }