Re: Earth distance

From: Tad Marko <tad(at)tadland(dot)net>
To: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Earth distance
Date: 2003-03-27 16:07:28
Message-ID: 1048781248.4358.7.camel@behemoth.tadland.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 2003-03-27 at 08:40, Stephan Szabo wrote:
> On Thu, 27 Mar 2003, Bruno Wolff III wrote:
>
> > On Wed, Mar 26, 2003 at 18:29:42 -0600,
> > Tad Marko <tad(at)tadland(dot)net> wrote:
> > > Bruno,
> > >
> > > I aplogize for bothering you direclty, but I'm having some difficulty with
> > > some syntax using the earth distance functions. Every single example I can
> > > find is using hard coded constants for the latitude and longitude, but I'm
> > > trying to use a join to get these values. Basically, what I'm trying to do
> > > is:
> > >
> > > select up.first_name, up.last_name, up.city, zip_code from user_primary as
> > > up, ziplocs as zl where zl.zip=up.zip_code::integer and '(33.0, 97.1)'::point
> > > <@> '(zl.lat, zl.lon)'::point < 50;
> > >
> > > But this fails with a
> > >
> > > ERROR: Bad point external representation '(zl.lat, zl.lon)'
> > >
> > > message. I simply cannot figure out how to specify the lat and lon values
> > > from the joined table. Can you offer any suggestions?
>
> That'd attempt to make a point from the string literal given, not what you
> want. I think point(zl.lat, zl.lon) might work (there's a point function
> that takes two doubles and returns a point).

Excellent! That's all I needed. I just hadn't come across the point
function in the documentation (searching on point yields quite a pile of
responses at the Postgres site), and I'm starting to doubt the value the
O'Reilly book on Postgres.

Now all I have to do is figure out how to deal with the issue of
canadian zip codes that we have mixed in.

Thanks!

Tad

--
Tad Marko <tad(at)tadland(dot)net>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gavin M. Roy 2003-03-27 16:23:57 Re: PostgreSQL + IDS load/latency help
Previous Message Jeff Eckermann 2003-03-27 16:02:13 Re: transaction blocking inserts in postgresql 7.3