[postgis-users] Distances from geometries other than points

strk at refractions.net strk at refractions.net
Fri Apr 15 01:58:19 PDT 2005


On Fri, Apr 15, 2005 at 08:52:16AM +0100, Julian Scarfe wrote:
> >I have a table of worldwide objects with a WGS84 latitude-longitude 
> >location as a POINT with SRID=4326.
> >
> >To find objects within specified earth-surface distances of a POINT seems 
> >straightforward using e.g.:
> >
> >distance_spheroid(
> >   object.location,
> >   PointFromText('POINT (0.5 52.5)', 4326),
> >   'SPHEROID["WGS_1984", 3444.0, 298.257223563]'
> >)
> >
> >to calculate, for example, the distance in nautical miles.
> >
> >But I'd like to be able to find all those objects within specified 
> >earth-surface distances (different for each object) of other geometries, 
> >for example a line or rectangle.
> >
> >How can I do that, please? distance_spheroid(geometry, geometry) seems to 
> >support only points and distance(geometry, geometry) returns a 
> >"flat-earth" distance.
> 
> OK, so if no one will bite on that one, let me ask a slightly different 
> question.
> 
> Can I extend PostGIS to incorporate functions that allow me to find, e.g. 
> shortest distances on a sphere between a point and a line (great circle), 
> and if so, where should I look to find out how to do that?  [I'm not asking 
> for algorithms, which I have, I'm wondering how to add functions that 
> accept geometries as parameters, and for examples.]

Take a look at lwgeom/measures.c for examples of working with LWGEOM
types, then look at lwgeom/lwgeom_functions_basic.c to see how to 
make wrappers for postgresql. Feel free to ask me if you encounter
any problem.

--strk;

> 
> Thanks
> 
> Julian Scarfe 
> 
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users



More information about the postgis-users mailing list