[postgis-users] Re: line_interpolate_point problem

Rhys Stewart rhys.stewart at gmail.com
Tue Sep 25 06:01:02 PDT 2007


could be a bug in line_interpolate_point.... or is it just an issue of
precision:
__________________________________________________________
create table i_line with oids as
 select '1'::int as id, 'LINESTRING(771506.725716163
646453.825076099,771505.036534646 646406.933509383,771503.086976331
646380.965177421,771500.326900536 646353.906144305)'::geometry as geo;
create table i_point with oids as
 select 'POINT(771504.510685672 646399.929142997)'::geometry as geo;

select distance(a.geo,b.geo) from i_line a,i_point b;
	5.02465728524363e-010
 select intersects(a.geo,b.geo) from i_line a,i_point b;
	f
 select line_locate_point(a.geo,b.geo) from i_line a,i_point b;
	0.538583631015939
 select astext(line_interpolate_point(a.geo,line_locate_point(a.geo,b.geo)))
from i_line a,i_point b;
	'POINT(771504.510685672 646399.929142997)'
_______________________________________________________

so it returns the same point that I started with, would snaptogrid
solve the problem? or anything else for that matter.
On 9/24/07, Rhys Stewart <rhys.stewart at gmail.com> wrote:
> Hi all,
>
> I'm (trying) to use line_interpolate_point to essentially 'snap' some
> point features to the nearest line feature. the following is the query
> i cobbled together:
>
> select b.*,distance(geo,geom) as dist0,
> line_interpolate_point(geom,(line_locate_point(geom,geo)::numeric(30,24)))
> as pgeo,
> from switch_fix a
> inner join today.feeder b on a.geo && b.geom
> where distance(geo,geom) < 5
> limit 50
>
> I was under the impression that line_interpolate_point would give me a
> point on the line, however when i get the distance between the
> interpolated point and the line, it is never 0, doesnt intersect, but
> visually it appears to intersect the line.
>
> any suggestions?
>



More information about the postgis-users mailing list