By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,369 Members | 1,246 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,369 IT Pros & Developers. It's quick & easy.

gps to zipcode query: postgres or postgresql + postgis or how?

P: n/a
I would like to map from GPS coordinates to US Zipcode for US
Continental based needs.

(Yes, I am excluding perhaps Hawaii and Alaska for now, and I am also
assuming that a simple 2D geometry, assuming the GPS coordinates are
Euclidean and not spherically based will be good enough to find the
closest zip code.)

So assuming something simple like

create table zipcode (
zcode integer primary key,
loc point
);

I have the zipcode data from the postoffice and it contains lat, lon.
(As I'm sure you guys know....)

I notice that Postgresql already supports the point type. And I
figured how to enter points into the db.

What I haven't figured out how is to make a query that selects other
rows that are closed to my target.

select zcode from zipcode where loc ## 'userx, usery';

That seems to fail.

Can someone tell me:

A) Can I do this in postgresql without using postgis,
and if so, how? (and what indices should I create?)
B) Where a good reference to making queries with the
postgres native geometric types can be found?

I'm happy to use postgis, I just don't want to toss an a-bomb after a
fly. If I implement postgis and do this in postgis, would it be
faster than the "native" postgres query, and if so, why?

And how would I do this postgis and what sort of index would I need to
create?

And hell, all I need is a mapping the fastest way possible. Given
that I have the zipcode => (lat, lon) data, anyone know of any C code
to do a spatial search?

Thanks,
Jerry Asher
Jul 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.