[postgis-users] Why aren't ST_ClosestPoints to polylines ST_Contained in those polylines?

Sandro Santilli strk at keybit.net
Mon Mar 26 02:06:37 PDT 2012

On Sat, Mar 24, 2012 at 01:54:37PM -0600, Hilton Long wrote:

> I created a table of ST_ClosestPoint()s to polylines.  I assumed that if the
> closest points were on the line the queries below would give equal results,
> but that's not happening.

Projected points are constrained to floating point grid, so they don't
necessarely fall _exactly_ on the line (might be impossible to).

Things are somewhat harder to verify in that ST_Distance itself
uses a tolerance thus hiding you the fact taht the projected
point isn't really on the line.

GEOS robust predicates can instead reveal that.

HINT: try ST_DWithin() to check for containment with a "tolerance"


  |   __/  |    Delivering high quality PostGIS 2.0 !
  |  / 2.0 |    http://strk.keybit.net - http://vizzuality.com

More information about the postgis-users mailing list