[postgis-users] Distances from geometries other than points
Markus Schaber
schabi at logix-tt.com
Fri Apr 15 02:02:39 PDT 2005
Hi, Julian,
Julian Scarfe schrieb:
>> 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.
If all your objects are in a relatively small area and not distributed
over the whole planet, you can project() them into a projection that
gives you (nearly) karthesian coordinates, and then use distance().
It may also be feasible to create some of your own projections and add
them to spatial_ref_sys (maybe by using negative SRIDs to avoid
collisions) and then choose the best one depending on your target object.
To speed up the query, you can still use the && operator on the lat/long
GIST indices.
> 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.]
Well, the best doc should be the PostgreSQL documentation about writing
C functions, and the best examples should be the PostGIS sourcecode itsself.
You can either patch the PostGIS code itsself to contain those
additional functions, or create your own .so library and .sql file to
add those functions. But you should have good C knowledge.
Of course, as soon as you distribute your modifications, even in-house,
you have to comply to the GPL. Probably the best way to do this is by
distributing your modified source together with the binaries. I also
invite you to submit your changes back to the PostGIS project for
inclusion. :-)
Gruss,
Schabi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 256 bytes
Desc: OpenPGP digital signature
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20050415/9ef28b70/attachment.pgp>
More information about the postgis-users
mailing list