[postgis-users] finding whether an object lies in vicinity of another object
Tom van Tilburg
tom.van.tilburg at gmail.com
Mon Oct 8 06:02:54 PDT 2012
Hi Tasneem,
You will have to create a geometry first before you can use postgis
functions. Just 2 columns with coordinates are not enough (you're very
close though).
I would recommend to do some reading in the manual, especially here:
http://postgis.refractions.net/documentation/manual-2.0/PostGIS_FAQ.html#id605751
It boils down to adding a column with
SELECT AddGeometryColumn('', 'yourtable','geom',-1,'POINT',2);
and then filling the column with
UPDATE yourtable SET geom = ST_SetSrid(ST_MakePoint(xcolumn,
ycolumn),4326)
(see:
http://postgis.refractions.net/documentation/manual-2.0/ST_MakePoint.html)
Besides that: most likely you want to use ST_DWithin, it's supposed to
be faster than ST_Within.
Cheers,
Tom
On 8-10-2012 14:40, tasneem dewaswala wrote:
> Hello,
>
> I am developing an application to find whether two cars are in each
> other communication range or not.
> I have two tables like receiver and transmitter. i would like to know
> if receiver is in 100 meters range of transmitter or not.
> Since i am using PostgreSQL first time, i donno much about its
> functions and commands, but i have found that there is ST_Within(),
> which can be used for my work. I tried but it gives me lot of errors,
> probably because of data types of my latitude and longitude. they are
> in two different columns with datatype as double precision.
>
> please tell me what is wrong, and how should i use ST_WITHIN for my
> work. Or tell me any other way of knowing if two objects are in range
> of each other.
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20121008/f01cfaea/attachment.html>
More information about the postgis-users
mailing list