/// <summary> /// Create a ShapeRange from a Geometry to use in constructing a Shape /// </summary> /// <param name="geometry"></param> /// <param name="vertices"></param> /// <param name="offset">offset into vertices array where this feature starts</param> /// <returns></returns> private static DSShapeRange ShapeRangeFromGeometry(IGeometry geometry, double[] vertices, int offset) { var featureType = geometry.OgcGeometryType.ToDotSpatial(); var shx = new DSShapeRange(featureType) { Extent = geometry.EnvelopeInternal.ToDotSpatial(), }; var vIndex = offset / 2; #if DS16 shx.Parts = new List <DSPartRange>(); #endif var shapeStart = vIndex; for (var part = 0; part < geometry.NumGeometries; part++) { var prtx = new DSPartRange(vertices, shapeStart, vIndex - shapeStart, featureType); var bp = geometry.GetGeometryN(part) as IPolygon; if (bp != null) { // Account for the Shell prtx.NumVertices = bp.Shell.NumPoints; vIndex += bp.Shell.NumPoints; // The part range should be adjusted to no longer include the holes foreach (var hole in bp.Holes) { var holex = new DSPartRange(vertices, shapeStart, vIndex - shapeStart, featureType) { NumVertices = hole.NumPoints }; shx.Parts.Add(holex); vIndex += hole.NumPoints; } } else { int numPoints = geometry.GetGeometryN(part).NumPoints; // This is not a polygon, so just add the number of points. vIndex += numPoints; prtx.NumVertices = numPoints; } shx.Parts.Add(prtx); } return(shx); }
/// <summary> /// Create a ShapeRange from a Geometry to use in constructing a Shape /// </summary> /// <param name="geometry"></param> /// <param name="vertices"></param> /// <param name="offset">offset into vertices array where this feature starts</param> /// <returns></returns> private static DSShapeRange ShapeRangeFromGeometry(IGeometry geometry, double[] vertices, int offset) { var featureType = geometry.OgcGeometryType.ToDotSpatial(); var shx = new DSShapeRange(featureType) { Extent = geometry.EnvelopeInternal.ToDotSpatial() }; var vIndex = offset / 2; shx.Parts = new List<DSPartRange>(); var shapeStart = vIndex; for (var part = 0; part < geometry.NumGeometries; part++) { var prtx = new DSPartRange(vertices, shapeStart, vIndex - shapeStart, featureType); var bp = geometry.GetGeometryN(part) as IPolygon; if (bp != null) { // Account for the Shell prtx.NumVertices = bp.Shell.NumPoints; vIndex += bp.Shell.NumPoints; // The part range should be adjusted to no longer include the holes foreach (var hole in bp.Holes) { var holex = new DSPartRange(vertices, shapeStart, vIndex - shapeStart, featureType) { NumVertices = hole.NumPoints }; shx.Parts.Add(holex); vIndex += hole.NumPoints; } } else { int numPoints = geometry.GetGeometryN(part).NumPoints; // This is not a polygon, so just add the number of points. vIndex += numPoints; prtx.NumVertices = numPoints; } shx.Parts.Add(prtx); } return shx; }