[postgis-users] Nearby result set ordered by proximity

2010-05-08 Thread Ilya Sterin
I can't seem to figure out how I'd order a nearby result set by proximity.

SELECT ST_AsGeoJSON(location), title, description
FROM event
WHERE ST_DWithin(location::geography,
ST_GeogFromText('POINT(-82.914349 42.391138)'),4000);

Above searches for everything in the vicinity of 40 km, but I want the
result set in order of proximity to location.

Thanks.

Ilya
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] Nearby result set ordered by proximity

2010-05-08 Thread Ilya Sterin
Actually, I figured it out...

ORDER BY ST_Distance(location,
ST_GeomFromText('SRID=4326;POINT(-83.359752 42.5212687)'))

Unless there is a better way?

Ilya


On Sat, May 8, 2010 at 8:40 PM, Ilya Sterin  wrote:
> I can't seem to figure out how I'd order a nearby result set by proximity.
>
> SELECT ST_AsGeoJSON(location), title, description
> FROM event
> WHERE ST_DWithin(location::geography,
> ST_GeogFromText('POINT(-82.914349 42.391138)'),4000);
>
> Above searches for everything in the vicinity of 40 km, but I want the
> result set in order of proximity to location.
>
> Thanks.
>
> Ilya
>
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


Re: [postgis-users] st_dwithin

2010-05-11 Thread Ilya Sterin
Would something like this be inefficient?  I store data in a geometry
type, as I don't really care about the spheroid accuracy, as my
location queries are mostly less than 30 km apart.  So...

SELECT ST_AsGeoJSON(location), title, description
FROM event
WHERE ST_DWithin(location::geography,
ST_GeogFromText('POINT(-83.359752 42.5212687)'),4000)
ORDER BY ST_Distance(location,
ST_GeomFromText('SRID=4326;POINT(-83.359752 42.5212687)'))

I cast geom to geog and perform st_dwithin and order by proximity.

Ilya

On Tue, May 11, 2010 at 8:37 AM, Emilie Laffray
 wrote:
>
>
> On 11 May 2010 07:34, Malm Paul  wrote:
>>
>> Hi,
>> I have a database stored in WGS84 EPSG:4326
>> I would like ti find objects within a distance from a lat/lon point.
>> 1) If i use 1 degree as the distance, will I then get an eliptic search
>> area?
>> 2) Will i find objects on the other side of the Datum shift border if I
>> enter a point like lat=60°, lon= -179,5° with a distance of 1°?
>> 3) Hov do I enter a lat/lon point and a distance in meters?
>>
>
> If you want to do something that works but is relatively inefficient for 3,
> you can do the following:
>
> ST_DWithin() AND ST_DistanceSphere() < distance in meters
>
> Of course, you would have to make sure that the search radius is big enough
> to correspond to your search in meters. Of course, it works only for points
> due to ST_DistanceSphere.
> If you want to perform something with any geometry, look at postgis 1.5 and
> the new geography type.
>
> Emilie Laffray
>
> ___
> postgis-users mailing list
> postgis-users@postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
>
___
postgis-users mailing list
postgis-users@postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users