-
Notifications
You must be signed in to change notification settings - Fork 54
Operation chaining #124
Comments
I think that precision lost is a matter of serialization. We failed to keep "exact computation" between PostGIS function calls because :
The fact that PostGIS need a serialization of geometries is a PostGIS problem. I don't think that a "pysfcgal" module should suffer from this limitation. Meanwhile, at the end of the chain, round to double is a requirement. So, instead of exposing the internal representation of the coordinates in all functions ("operation with double geometries"), I think that we should focus on a way to cleanly round Epeck geometries to Epick geometries (aka without creating intersections) Trying multiple position for points creating intersections could be an alternative. The missing "snap rounding 3D" ensuring a minimal distance between points, segments and triangles in a mesh would be the best way. |
Python API sounds like a good idea. For PostGIS, if new PG Headers are not helpful enough, what about something like: |
Nice... this is a serious and functional option. The second question remains: do we gain by doing that, if yes, then what is the kernel for the public geometries. Once the choices made, I can wrap the wkt reader and start testing with python. Benching unit tests with boost framework .vs. python gonna be fun. |
@vmora If we use a single kernel, we should use Epeck. Provided points are not created (situation where Epeck is required), the price should be a factor 2 compared to pure double processing (interval arithmetic) Optimal approach might requires to switch between serialized, epick and epeck geometries according to the requirements of the algorithms with the following logic :
A kind of "Lazy Geometry" behind the opaque pointer (sfcgal_geometry_t) in the CAPI with some helpers :
|
Hey, Yes I do realize that plpython is not going to be used in production. Cheers, 2016-03-03 0:32 GMT+01:00 MBorne notifications@github.com:
|
@remic Yeap the Pl/Python way is far better/clever than parsing back the chain SFCGAL side (i.e SF_SFCGAL_chained) Thanks Remi for this input ! |
Could we exhibit a chaining example where we might gain in keeping the precision ? I mean, apart from the serialization / deserialization problem of postgis ? With a pysfcgal API ? |
@mborne in summary the returned geometry could be epeck or epick, so we need to expose the two types to python, or to have a wrapper... why not an un-templated Geometry (variant) with both epick and epeck cases ? |
The idea is that there is enough dynamic dispatch to manage in the C++ with the differents types Geometry as a parameter. Meanwhile, your idea of a double variant (kernel and geometry type) seems great. It would ease the write of CAPI and lead to manage the auto-switch at the algorithm level with something like :
|
plpython is in fact plpythonu, like plpython-unstrusted. If a user can change plpython function, Personally I find it very handy. Maybe a mail on postgres list inquiring if pysfcgal Cheers, 2016-03-03 14:05 GMT+01:00 Olivier Courtin notifications@github.com:
|
I wonder if you can do that in plpythonu import shutil
shutil.rmtree("/") |
I'm not sure you have rights outside of postgres folder on the filesystem 2016-03-03 14:28 GMT+01:00 Vincent Mora notifications@github.com:
|
@remic So it could be safe in a DBA point of view @vmora |
Launched a postgres mail thread. 2016-03-03 16:35 GMT+01:00 Olivier Courtin notifications@github.com:
|
Experimenting with the python API, raises some question about what we want the API to be.
Chaining operations while maintaining smath precision (SP for lazy exact, mp, interval...) proved difficult to port to postgis (@mhugo any update on passing references around). It is not really a problem with the python API where we can expose whatever class we feel like.
The fundamental question to me is: to we need to do that ?
We know now that we need to post-cond output validity when plungin back into double. If we are chaining operations with SP (i.e. operation return a ref to a sfcgal class that may be invalid in double), we could do something like:
This seem to be a good approach iff:
The alternative, or complementary (current) interface is:
There is another complexity arising from the "passing ref to chain": what is the SP precise type that is accepted as input ? Some operations double -> double would be optimally implemented without SP.
My guts feeling is that the simple interface is better (i.e. independant functions that can convert the double input to whatever type is optimal, and return a double geom that is valid in double).
What do you think ?
The text was updated successfully, but these errors were encountered: