Forum OpenACS Q&A: Re: gps to zipcode query: postgres or postgresql + postgis or how?

point_distance is the function I am looking for. Hmm, near as I can tell, point_distance and most of the functions listed by \df are not documented anywhere.... Well, the price is right.

Given the table above, the following non ANSI query will find the zipcode closest to your location ($X, $Y).

  select code from (select code, point_distance(loc, '$X, $Y) as dist
                      from zip
                  order by dist
                     limit 1) as tbl;
It's still not clear what the best indices to build are or how much faster or slower the typical C function to do this would be. Future exercise....