pgRouting / pgrouting

Repository contains pgRouting library. Development branch is "develop", stable branch is "master"
https://pgrouting.org
GNU General Public License v2.0
1.17k stars 368 forks source link

SRID of alphashape geometry #390

Open jolauer opened 9 years ago

jolauer commented 9 years ago

The SRID of the input point set which is used for creating the alpha shape should be set for the resulting alpha shape.

dkastl commented 9 years ago

Which function are you referring to? pgr_pointsAsPolygon or pgr_drivingDistance? In general pgRouting does not check the SRID or does not do CRS transformations. It will take the values from the network table as it is.

So if you have a good idea how to improve this, could you provide more details? Maybe I didn't fully understand it.

jolauer commented 9 years ago

I used the pgr_pointsAsPolygon function. The usage of spherical coordinates for distance calculations causes accuracy problems. Hence it is better to use a map projection with a Cartesian coordinate system (e.g. UTM) to be sure that distances are calculated properly. Using the souce geometry SRID as a further input parameter allows the setting of the resulting geometry SRID. The geometry and its coordinates are then specified correct which allows further processing without assumptions on the coordinates (hence they are specified and the distance measure is clear). Two ideas to solve this issue:

dkastl commented 9 years ago

Thanks for the details!

Right now the easiest way would be to write another function, that would handle an SRID parameter and a geometry instead of x,y and handle the transformation within the function. This will not be faster than the "core" function, but users may find it more comfortable to work with. The advantage of the SQL though is, that you can limit or modify data easier.

Right now the function is written in a way, that it fetches data similar to how the alpha shape algorithm (CGAL) requires it. It does not care about projections, so we let the user handle this and only provide the core tools.

I'm a bit hesitant to introduce too many functions, that make use of core functions internally, because they need to be tested and maintained. Some time ago we created this "pgrouting-contrib" repository (https://github.com/pgRouting/pgrouting-contrib) to collect additional functions and make them available to the community. Another approach is to publish useful functions as Gist: https://github.com/pgRouting/pgrouting/wiki/Third-Party-Resources-and-Writing-functions