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

Can not construct Prepared Geometries. #479

Open
motto76 opened this issue Oct 6, 2022 · 4 comments
Open

Can not construct Prepared Geometries. #479

motto76 opened this issue Oct 6, 2022 · 4 comments
Milestone

Comments

@motto76
Copy link

motto76 commented Oct 6, 2022

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 (node_modules/jsts/org/locationtech/jts/geom/prep/PreparedPolygon.js:13:5)

Testcase

it(' Fail PreparedPolygon' ,() => {
const gf = new GeometryFactory()
const reader = new WKTReader(gf)
const poly = reader.read('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))')
PreparedGeometryFactory.prepare(geom)
}

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:

constructor() {
    super(arguments[0])
    PreparedPolygon.constructor_.apply(this, arguments)
}
@bjornharrtell
Copy link
Owner

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.

@motto76
Copy link
Author

motto76 commented Oct 7, 2022

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.

@bjornharrtell
Copy link
Owner

Ok so then I'll leave it as a possbible future nice to have. ;)

@bjornharrtell bjornharrtell added this to the Future milestone Oct 13, 2022
@bjornharrtell bjornharrtell reopened this Oct 13, 2022
@MikkoSteerpath
Copy link

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.

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

3 participants