Forum OpenACS Q&A: Re: Closest Address Calculation

Collapse
Posted by russ m on
Sam - no worries...

the point_distance function takes 2 arguments of type point. What you have there is 3 arguments where the first is indeed a point but the other two are plain numbers - what you need to do is tell Postgres that the 2 real numbers are actually the coordinates of a single point. The way to do this is to enclose the pair on numbers in single quote marks. So what you actually want is this -


select
str_num ||' '|| name AS full_address,
point_distance(the_geom, '2227284.1963667543,1435389.6730164126') as dist
from address order by dist limit 1
note the quote marks!

hope this helps you out...