I put together a quick project to try and understand some of the trade-offs for prepared vs. non-prepared geometries (when to use a prepared geometry, when not to, etc.)
The readme has a summary of the tests and results, with graphics https://github.com/chrisbennight/intersection-test Probably the best summary is this chart: https://raw.githubusercontent.com/chrisbennight/intersection-test/master/src/main/resources/difference%20-%20prepared%20vs%20non%20prepared%20-%20chart.png which shows the difference of (prepared geometry intersection time - regular geometry intersection time) as a function of the number of points in each geometry. My big takeaway is that once the target geometry starts getting around 10k or more points, using a regular geometry intersection may be faster than using a prepared geometry intersection. (Not saying 10k is a magic number, just using that as a rough estimate of when I might need to start caring) I think a typically use case of a query window (think typically WMS, WFS, etc. BBOX query) with 5 points matching against complex geometries in the database might very easily see worse performance by creating a new PreparedGeometry instance of that 5 point geometry. Which is completely fair - just trying to understand the trade-offs and heuristics for using it. Other strategies - such as in the case above, preparing the target geometry and flipping the intersection test (since in testing preparing the geometry was orders of magnitude faster than the intersection) are also things I'm interested in. Probably my big request is a little review from the experts - have I missed something obvious, done something horribly wrong, or is this a reasonable outcome? I'd also be curious if there are any guidelines for how/when people use a prepared geometry. It looks like PostGIS might employ some heuristics in what and when to prepared the geometry? Anyway, just looking for a quick vector check as well as any thoughts/guidance. Overall I'd like to come up with a heuristic for when to used prepared geometry against arbitrary sets of polygons.
------------------------------------------------------------------------------
_______________________________________________ Jts-topo-suite-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jts-topo-suite-user
