this is my first post for asking help.. while developing a shapefile reading software I encountered following error:
Property or indexer 'ShapeRange.Parts' cannot be assigned to -- it is read only
Snippet of my code where the error is given below .
var shx = new DSShapeRange(featureType) { Extent = geometry.EnvelopeInternal.ToDotSpatial() };
shx.Parts = new List<DSPartRange>();
The function where the line are is :
private static DSShapeRange ShapeRangeFromGeometry(IGeometry geometry, double[] vertices, int offset)
{
var featureType = geometry.OgcGeometryType.ToDotSpatial();
var shx = new DSShapeRange(featureType) { Extent = geometry.EnvelopeInternal.ToDotSpatial() };
shx.Parts = new List<DSPartRange>();
var vIndex = offset / 2;
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;
}