Open motto76 opened 2 years ago
Interesting. But is there an actual use case for PreparedPolygon in JSTS? They are a performance enchantment for some usage in the original JTS but I would not assume those carry over in the transpilation.
Actually there is no use case. We are just porting good old java Code and stumpling across this. We haven't done any performance testing yet either.
Ok so then I'll leave it as a possbible future nice to have. ;)
I noticed the lack of perpared geometries as well trying to use the intersects() method. For what its worth, it looks like the prepared polygon's intersects() uses two spatial indexes, one for checking if the other geometrys points are inside or outside the polygon, as well as a spatial segment index for finding intersections that touch the the polygon. I would imagine the performance advantages of using the spatial indexes would also carry over to this transpiled version.
Each of the 3 Subclasses of BasicPreparedGeometry throw an Error if you call the constructor.
_TypeError: Cannot read properties of undefined (reading 'apply') at Function.getCoordinates (node_modules/jsts/org/locationtech/jts/geom/util/ComponentCoordinateExtracter.js:16:10) at PreparedPolygon.apply (node_modules/jsts/org/locationtech/jts/geom/prep/BasicPreparedGeometry.js:13:60) at new BasicPreparedGeometry (node_modules/jsts/org/locationtech/jts/geom/prep/BasicPreparedGeometry.js:6:40) at new PreparedPolygon (nodemodules/jsts/org/locationtech/jts/geom/prep/PreparedPolygon.js:13:5)
Testcase
If you put a LineString or a Point in it, it fails as well.
To fix it simply call the super constructor with the given geometry.
PreparedPolygon: