[postgis-users] line_interpolate_point does not return a point that intersects the line

strk strk at keybit.net
Mon May 3 00:53:32 PDT 2010


On Mon, May 03, 2010 at 04:41:09PM +1000, Francis Markham wrote:
> Hi all,
> 
> I think I've got a bit of a problem with snapping points to lines.  I had
> thought that using line_interpolate_point(..., line_locate_point(...)) would
> do the trick, but this seems not to be the case:

Francis,
thing is that the constructive functions have to deal with representability
of numbers which means you won't always get the exact point of intersection
but rather the best approximation of it.
Instead the predicates (like ST_Intersects) give you the exact answer.
You may try the distance functions to see how much the intersection point
is off the line, should be a really low number.

--strk;

> gis=# SELECT ST_AsText(v.the_geom), ST_SRID(v.the_geom),
> ST_AsText(r.the_geom), ST_SRID(r.the_geom) FROM road_segments AS r, venues
> AS v WHERE v.venue_id = 29 AND r.gid = 100982;
> 
>                 st_astext                 | st_srid
> |
> st_astext                                    | st_srid
> ------------------------------------------+---------+---------------------------------------------------------------------------------+---------
>  POINT(415185.606066865 7827721.52951473) |   28353 |
> LINESTRING(415250.679102704 7827994.85292521,415218.694181662
> 7827642.44920486) |   28353
> (1 row)
> 
> gis=# SELECT ST_Intersects(ST_line_interpolate_point(r.the_geom,
> ST_line_locate_point(r.the_geom, v.the_geom)), r.the_geom) FROM
> road_segments AS r, venues AS v WHERE v.venue_id = 29 AND r.gid = 100982;
> 
>  st_intersects
> ---------------
>  f
> (1 row)
> 
> gis=# SELECT postgis_full_version();
> 
> 
> postgis_full_version
> ----------------------------------------------------------------------------------------
>  POSTGIS="1.4.1" GEOS="3.2.1-CAPI-1.6.1" PROJ="Rel. 4.7.1, 23 September
> 2009" USE_STATS
> (1 row)
> 
> 
> 
> Any assistance would be much appreciated.
> 
> Thanks,
> 
> -Francis Markham

> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users


-- 

  ()   Free GIS & Flash consultant/developer
  /\   http://strk.keybit.net/services.html



More information about the postgis-users mailing list