Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error dealing with Multipolygons #48

Open
ericboucher opened this issue Mar 13, 2024 · 1 comment
Open

Error dealing with Multipolygons #48

ericboucher opened this issue Mar 13, 2024 · 1 comment

Comments

@ericboucher
Copy link

I get the following error TypeError: Cannot assign to read only property 'type' of object '#<Object>'

TypeError: Cannot assign to read only property 'type' of object '#<Object>'
GeoJSONUtils.fixMultiPoly
node_modules/max-inscribed-circle/utils/geojson-utils.js:21
  18 | fixMultiPoly(polygon) {
  19 |     if(polygon.geometry.type === 'MultiPolygon' && polygon.geometry.coordinates[0].length === 1) {
  20 |         // Handle a Polygon in the form of a MultiPolygon
> 21 |         polygon.geometry.type = 'Polygon';
     | ^  22 |         polygon.geometry.coordinates = polygon.geometry.coordinates[0];
  23 | 
  24 |         return polygon;
View compiled
maxInscribedCircle
node_modules/max-inscribed-circle/max-inscribed-circle.js:50
  47 | const numSegments = options.numSegments;
  48 | const units = options.units;
  49 | 
> 50 | polygon = GeoJSONUtils.fixMultiPoly(polygon);
     | ^  51 | const polySites = GeoJSONUtils.sites(polygon, numSegments, decimalPlaces);
  52 | const diagram = voronoi.compute(polySites.sites, polySites.bbox);
  53 | const vertices = {

Here is an example of a failing Multipolygon. I have tried to create a new copy of the object to allow mutations but without any luck.

Screenshot 2024-03-13 at 11 33 16 AM
@PieceMaker
Copy link
Owner

Do you have a sample GeoJSON MultiPolygon you can provide that throws this error? I looked at the tests and there already exist tests for MultiPolygons, albeit simple ones, that are passing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants