Closed motto76 closed 2 years ago
Hmm interesting that this is not caught by existing tests. Perhaps you are the first to use equalsNorm.. ;)
Reproduced with https://github.com/bjornharrtell/jsts/pull/485.
This regressed in version 2.2.2 due to commit https://github.com/bjornharrtell/jsts/commit/fb3c89b8bb2339ce6692c795e41a957fa17f19f9 back in 2017. I guess it's not that common that people try and compare different geometry types.
I believe this is fixed now and released as 2.9.3
Thanks for the quick troubleshooting. We have tested it successfully.
Hello,
we have a problem with equalsNorm().
In the following test case:
the following error occurs:
TypeError: Cannot read properties of undefined (reading 'length'). Stack: _at MultiPolygon.call (node_modules/jsts/org/locationtech/jts/geom/GeometryCollection.js:76:67) at MultiPolygon.equalsExact (node_modules/jsts/org/locationtech/jts/geom/MultiPolygon.js:27:32) at MultiPolygon.apply (node_modules/jsts/org/locationtech/jts/geom/Geometry.js:33:35) at MultiPolygon.apply (node_modules/jsts/org/locationtech/jts/geom/GeometryCollection.js:86:32) at MultiPolygon.equalsExact (node_modules/jsts/org/locationtech/jts/geom/MultiPolygon.js:29:32) at MultiPolygon.equalsNorm (nodemodules/jsts/org/locationtech/jts/geom/Geometry.js:46:24)
If you swap the geometries you get another error:
RangeError: Maximum call stack size exceeded at Function.[Symbol.hasInstance] ()
Stack:
_at LinearRing.equalsExact (node_modules/jsts/org/locationtech/jts/geom/LineString.js:43:72)
at LinearRing.apply (node_modules/jsts/org/locationtech/jts/geom/Geometry.js:33:35)
at LinearRing.equalsExact (node_modules/jsts/org/locationtech/jts/geom/LineString.js:59:32)
at LinearRing.apply (node_modules/jsts/org/locationtech/jts/geom/Geometry.js:33:35)
at LinearRing.equalsExact (node_modules/jsts/org/locationtech/jts/geom/LineString.js:59:32)
at LinearRing.apply (node_modules/jsts/org/locationtech/jts/geom/Geometry.js:33:35)
at LinearRing.equalsExact (nodemodules/jsts/org/locationtech/jts/geom/LineString.js:59:32)
...
Cause for case 1: The check in MultiPolygon if (!this.isEquivalentClass(other)) returns true, because the call getClass() returns [class Geometry] for both geometries. (#getClass is implemented only in Geometry and therefore returns
possible Solution: Each geometry class implements getClass Alternative: Instead of getClass, getGeometryType is checked.