Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#209 closed patch (fixed)

Discrete Hausdorff distance implementation (through GEOS)

Reported by: vincentp Owned by: pramsey
Priority: medium Milestone: PostGIS 1.5.0
Component: postgis Version: trunk
Keywords: hausdorff distance geos Cc:

Description

JTS and GEOS have a discrete Hausdorff distance algorithm. It is currently not exposed in GEOS C API, nor in PostGIS. A patch for GEOS is available to expose these functions : http://trac.osgeo.org/geos/ticket/264

Please find attached a patch to PostGIS trunk (at rev 4206) that implements Hausdorff distance calculation using the GEOS C API provided by this patch :

ST_HausdorffDistance(geometry, geometry) and its variant with segment densification ST_HausdorffDistance(geometry, geometry, float)

Documentation (from JTS) and unit test are included.

As the GEOS patch has still not been commited, you'll have to patch and recompile geos to test it. The GEOS version test in postgis.sql.in.c are made on GEOS 31 so as to be able to test. It should be changed to the GEOS version patch #264 will be commited to.

This is my first patch for PostGIS, please be indulgent :) I'll be waiting for a review to fix or improve the patch so that it can be commited.

Attachments (1)

hausdorff.patch (9.7 KB) - added by vincentp 10 years ago.
Hausdorff distance in postgis (with right geos version check)

Download all attachments as: .zip

Change History (5)

comment:1 Changed 10 years ago by vincentp

Type: defectpatch

comment:2 Changed 10 years ago by pramsey

I find this line in the patch confusing :)

#if POSTGIS_GEOS_VERSION >= 31 
-- Requires GEOS >= 3.2.0 

Your comment correctly indicates your GEOS requirement, but your macro test does not. I think you'll want to fix all those macro tests.

Changed 10 years ago by vincentp

Attachment: hausdorff.patch added

Hausdorff distance in postgis (with right geos version check)

comment:3 Changed 10 years ago by pramsey

Resolution: fixed
Status: newclosed

Applied to trunk at r4208.

comment:4 Changed 10 years ago by pramsey

And thanks! Good first contribution. Documented, tests included, you put me to shame.

Note: See TracTickets for help on using tickets.