I have some geometry in cgal that I would like to export to postgis. The kernel I'm using is the same as what sfcgal uses (exact predicate exact construction), but I'm encountering some errors in postgis when I use the standard float output for the cgal points with ST_GeomFromText
. For instance when I try to use ST_3DIntersection
with a polygon I get an error that the polygon points aren't coplanar, but I have confirmed that that the points are coplanar in my cgal program.
What I'm hoping for is a way to construct the postgis geometry using the exact fraction output from point().exact()
in cgal, e.g. ST_ExactGeomFromText('PointZ(0, 0, 8676011023327629/4611686018427387904)')
. I haven't been able to find a function like this in the docs though. If there isn't such a function does anyone have some suggestions on how I can get valid geometry from cgal to postgis?
EDIT:
I've now tried building postgis and sfcgal from source with SFCGAL_CHECK_VALIDITY=OFF as well as a couple other things, but nothing seems to be working. Here's a reproduction:
You'll notice IsPlanar
is true, but ST_3DArea
raises an error saying the points aren't coplanar.
CREATE TABLE polygon_test();
SELECT AddGeometryColumn('polygon_test', 'geom', 4326, 'POLYGONZ', 3);
INSERT INTO polygon_test (geom) VALUES(ST_GeomFromText('POLYGON Z ((-2456.65849662024 -494.251393883276 412,-2486.7786660429 -413.696999618586 412,-2486.77945264572 -413.696623334753 354,-2456.65889152129 -494.252065179804 354,-2456.65849662024 -494.251393883276 412))', 4326));
SELECT ST_IsPlanar(geom) FROM polygon_test;
SELECT ST_3DArea(geom) FROM polygon_test;