Forum OpenACS Q&A: Re: Closest Address Calculation

Collapse
Posted by Sam Dau on
hi Russell,

I believe you are referring this code:

  select code from (select code, point_distance(loc, '$X, $Y) as dist
                      from zip
                  order by dist
                    limit 1) as tbl;

I saw that but what is confusing and the same confusion I ran into with Tom's code is that I didn't know that OpenACS is actually a tool used to writing codes such as this.

Rather, I am using postgres and I am having problem translating this bit(point_distance(loc, '$X, $Y) as dist

For instance, since my table layout looks like this:

table name: address
str_num --street number
name --street name

the_geom -- this holds the value for x/y point.

I know they are variables and need translating but I am not quite sure how to translate $X, $Y given that I will be using a query rather than a function?

Any suggestion would be appreciated.