pgrouting icon indicating copy to clipboard operation
pgrouting copied to clipboard

SRID of alphashape geometry

Open jolauer opened this issue 10 years ago • 3 comments

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

jolauer avatar Aug 05 '15 15:08 jolauer

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.

dkastl avatar Aug 06 '15 08:08 dkastl

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:

  • One could add the SRID as a further parameter to the pgr_pointsAsPolygon function and write the resulting polygon with this SRID as result.
  • The input can be done as a multipoint geometry (instead of the integrated SQL text with id, x, y) and the output can easily use the multipoint's SRID for the resulting (multi)polygon.

jolauer avatar Aug 06 '15 09:08 jolauer

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

dkastl avatar Aug 06 '15 09:08 dkastl