[postgis-users] spheroid bounding box calculation

2009-07-22 Thread Jeff Davis
I would like to query my latitude/longitude points for distance in a way that uses the index. The points are in lat/lon, so st_dwithin(g1, g2, [meters]) makes no sense. What is the recommended way to do this? I think what I need is a function that takes a point in lat/lon, and a distance in meter

Re: [postgis-users] spheroid bounding box calculation

2009-07-22 Thread Paul Ramsey
http://trac.osgeo.org/postgis/wiki/UsersWikiExamplesFindNearbyLatLon On Wed, Jul 22, 2009 at 11:19 PM, Jeff Davis wrote: > I would like to query my latitude/longitude points  for distance in a > way that uses the index. The points are in lat/lon, so st_dwithin(g1, > g2, [meters]) makes no sense. >

Re: [postgis-users] spheroid bounding box calculation

2009-07-22 Thread Jeff Davis
On Wed, 2009-07-22 at 23:37 -0700, Paul Ramsey wrote: > http://trac.osgeo.org/postgis/wiki/UsersWikiExamplesFindNearbyLatLon > Ok, that looks like it will work. It seems like there should be some calculation that gives a tight bounding box for any point, is there a reason that's hard to find? R

Re: [postgis-users] spheroid bounding box calculation

2009-07-23 Thread Stephen Frost
Jeff, * Jeff Davis (pg...@j-davis.com) wrote: > I would like to query my latitude/longitude points for distance in a > way that uses the index. The points are in lat/lon, so st_dwithin(g1, > g2, [meters]) makes no sense. > > What is the recommended way to do this? I think what I need is a > func

Re: [postgis-users] spheroid bounding box calculation

2009-07-23 Thread Jeff Davis
On Thu, 2009-07-23 at 07:06 -0400, Stephen Frost wrote: > Why do you care about it being in meters..? Well, all I care about is that it's in some kind of linear length units. Queries might take the form of "what else is within 3 miles of this lat/lon point?". > Just make sure that > st_expand wi

Re: [postgis-users] spheroid bounding box calculation

2009-07-23 Thread Paul Ramsey
Just isn't such a thing, is all. I guess an st_expand_sphere() would be what you wanted, but does not exist. Hopefully GEOGRAPHY will retire all these requirements once and for all :) P On Thu, Jul 23, 2009 at 8:49 AM, Jeff Davis wrote: > On Thu, 2009-07-23 at 07:06 -0400, Stephen Frost wrote: >>

Re: [postgis-users] spheroid bounding box calculation

2009-07-23 Thread Jeff Davis
On Thu, 2009-07-23 at 08:58 -0700, Paul Ramsey wrote: > Hopefully GEOGRAPHY will retire all these requirements once and for > all :) Is that something under development? I'm new to these lists, so I haven't been following. Regards, Jeff Davis _

Re: [postgis-users] spheroid bounding box calculation

2009-07-23 Thread steve enzer
I'm facing a similar issue; a huge postgis database with a point column, trying to find a clean query to bring back the nearest n results to a point. Why isn't that easy? Or is it? I'm using georuby and spatial adapter. Steve On Thu, Jul 23, 2009 at 10:01 AM, Jeff Davis wrote: > On Thu, 2009-07

Re: [postgis-users] spheroid bounding box calculation

2009-07-23 Thread Stephen Woodbridge
steve enzer wrote: I'm facing a similar issue; a huge postgis database with a point column, trying to find a clean query to bring back the nearest n results to a point. Why isn't that easy? Or is it? The problem is that the nearest n points is not well defined in spatial terms. For example th

Re: [postgis-users] spheroid bounding box calculation

2009-07-23 Thread Paul Ramsey
Nearest neighbor, as Stephen notes in the followup is not something that is necessarily easy in general. However! Another development on-stream for PostgreSQL 8.5 will allow us to both (a) use k-d tree indexes for points, which are much more efficient and (b) to do nearest-neighbor searching using

Re: [postgis-users] spheroid bounding box calculation

2009-07-23 Thread Paul Ramsey
Yes, under development, with a client delivery date in November and hopefully rolled into a new numbered release (postgis 1.5) before the new year. P. On Thu, Jul 23, 2009 at 10:01 AM, Jeff Davis wrote: > On Thu, 2009-07-23 at 08:58 -0700, Paul Ramsey wrote: >> Hopefully GEOGRAPHY will retire all

Re: [postgis-users] spheroid bounding box calculation

2009-07-23 Thread Stephen Woodbridge
Oh, and the basic sql query would be: select * from poi_table where st_within(setsrid(makepoint(x,y),4326), the_geom, radius) order by st_distance(setsrid( makepoint(x,y),4326), the_geom) asc limit n; (x,y) == (lon, lat) radius == is your initial search radius n == is your limit on results -

Re: [postgis-users] spheroid bounding box calculation

2009-07-24 Thread Stephen Woodbridge
Whooops, you are right. Change that query to be: select * from poi_table where st_within(the_geom, st_expand(setsrid(makepoint(x,y),4326), radius)) order by st_distance(setsrid( makepoint(x,y),4326), the_geom) asc limit n; or to explicitly specify the index usage select * from poi_table