Forum OpenACS Q&A: Re: Closest Address Calculation

Collapse
Posted by Sam Dau on
Please allow me one more question on this topic.

I ran this code per russell's script.

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

I got the following error.

ERROR:  function point_distance(geometry, numeric, numeric) does not exist
HINT:  No function matches the given name and argument types. You may need to add explicit type casts.

Does anyone know what it means and how to resolve it?
Thanks again for all the help

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...