#1215 closed enhancement (fixed)
ST_DelaunayTriangles
Reported by: | strk | Owned by: | strk |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS 2.1.0 |
Component: | postgis | Version: | master |
Keywords: | history | Cc: | mateusz@… |
Description
Expose delaunay triangulation to postgis. Interface details to be decided. This ticket is mostly to gather use cases at this stage.
Change History (14)
comment:1 by , 13 years ago
comment:2 by , 13 years ago
Type: | defect → enhancement |
---|
JTS 1.12 has Delaunay Triangulation package which should be ported to GEOS. See http://trac.osgeo.org/geos/ticket/487
This ticket is in search of a sponsor
comment:3 by , 13 years ago
It's actually from JTS-1.11: http://lin-ear-th-inking.blogspot.com/2009/04/delaunay-triangulation-in-jts-111.html
comment:4 by , 13 years ago
Cc: | added |
---|
comment:5 by , 13 years ago
Milestone: | PostGIS Future → PostGIS 2.1.0 |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:6 by , 12 years ago
News from the GEOS side of things: the C++ port is ready in trunk (to become 3.4.0) and it's now time to expose it trough the C-API. Reading the C++ interface there are 2 possible outputs: a collection of lines or a collection of polygons. The former is smaller, and I guess you could form the latter by passing the former to ST_Polygonize.
So, what do you think would be more appropriate to return ?
comment:7 by , 12 years ago
For the record, the ticket for the C-API side of GEOS is http://trac.osgeo.org/geos/ticket/565
comment:8 by , 12 years ago
So I ended up exposing an API which allows both collection-of-polygons and multlinestring outputs, so it only needs to be decided how to access the functionality from postgis. How should the function look like to request one or the other, and what should the default be (if any).
Note that the function also accept a tolerance.
comment:9 by , 12 years ago
It seems to me that having something like:
select the_geom from delaunay_triangles(sql_for_points text, tolerance double precision, multilinestring_out boolean); select the_geom from delaunay_triangles(sql_for_points text, tolerance double precision);
where the function returns a set of geometries based on multilinestring_out flag. If true you get multilinestrings if false or absent you get polygons. You mentioned a tolerance so I tossed that in, but what is it for?
I like the set returning function because it is easy to throw ST_Collection() around it if you want a collection but much harder to explode it is you do not want that and it support your idea of pipelining.
BTW. Nice work on this!
comment:10 by , 12 years ago
Given that GEOS gives us the already-collected representation there's really no gain in a set-returning function.
The flag could be fine but maybe not a boolean but an integer, to keep the door open for more flags in the future (ala GML output functions)
r9993 adds the liblwgeom part (with an int flag)
comment:11 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Have fun with r9994 — adds SQL entry point, SQL level test and documentation.
comment:12 by , 12 years ago
Keywords: | history added |
---|
comment:13 by , 12 years ago
This is definitely a nice feature but how can I build a Delaunay triangulation from a table of, say, 1 000 000 points?
Adding some use cases for discussion that I presented on the list.
I wrote code years ago in C that would take a cloud of 3D points insert them into a Delaunay triangular surface, then slice the surface triangles with a plane(s) into intersecting edges and then composite rings from the edges. It seems like we are very close to being able to do this in PostGIS. I'm not sure if we have the Delaunay triangularization yet.
I'm thinking of something like:
So I'm thinking of something like this is the use case, where this would create contour rings for Z at 2, 4, 6, 8, and 10 based on the triangulated surface created from the points. My SQL is probably broken, but it is only to present the idea.
This use case is very broad in its applicability to real world cases. Think of the points as XY as in location of a sensor or some other point of measurement and the Z as the measurement value. Creating a 3D triangulated surface and cutting it with z-planes creates contours of equal value results. Create a vertical plane(s) and you are generating elevation profiles. and if you have 2d path like a bicycle route, a GPS track, etc and extrude that into a vertical panel the intersects the surface, you intersection becomes the measurement profile of the path. If the surface is elevation, then you have an elevation profile, if the measurement was chemical concentrations in a water body and the track is fish, then the profile because an exposure profile for the fish.
So some use cases of this are:
And I think that being able to build a pipeline of functions like I offered above would be extremely useful. in all of these use cases.
While I do not need it specifically at the moment, anyone trying to render 3D landscapes might want to be able to extract the triangles or might want to be able to apply hillshading to the the triangulated surface and create a postGIS raster as a result. For the hillshading task I believe they would like to get the average normal at the each triangle node, this is needed for both Gouraud and Phong shading algorithms, being able to extract that might be of interest in the future.