I just read from GEOS 3.7 documentation that there is a new IndexedFacetDistance imported from JTS. Reading from the JTS link, I cannot tell what the new distance metric does except that it's taking advantage of R-tree index in computing something.

So, what does the distance compute functionally?

Is its result going to be the same as ST_HausdorffDistance or another existing distance measure in PostGIS, or is the distance for two given geometries going to be a different number from any existing distance?

  • 1
    From the source code I would say it is simply computing the closest distance between two geometries, but doing it in an optimized way, using R-tree and branch and bound. – John Powell Jul 4 '18 at 13:22

IndexedFacetDistance builds a spatial index over portions ("facets") of a geometry and uses that index to optimize standard Cartesian distance calculations. It is to distance calculations what PreparedGeometry is to spatial predicates (intersects, touches, etc.).

Unlike PreparedGeometry, the implementation exposed in GEOS' C API doesn't allow you to re-use the index for multiple distance calculations. So it's of a bit limited use, except for very large geometries (where it can make an enormous distance.)

IndexedFacetDistance won't be used in PostGIS, because PostGIS has its own native implementation of the same concept that is much faster.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.