2626 automake ,
2727 libtool ,
2828 which ,
29+ sfcgal ,
30+ withSfcgal ? false ,
2931} :
3032
3133let
@@ -47,15 +49,18 @@ buildPostgresqlExtension (finalAttrs: {
4749 hash = "sha256-wh7Lav2vnKzGWuSvvMFvAaGV7ynD+KgPsFUgujdtzlA=" ;
4850 } ;
4951
50- buildInputs = [
51- libxml2
52- geos
53- proj
54- gdal
55- json_c
56- protobufc
57- pcre2 . dev
58- ] ++ lib . optional stdenv . hostPlatform . isDarwin libiconv ;
52+ buildInputs =
53+ [
54+ libxml2
55+ geos
56+ proj
57+ gdal
58+ json_c
59+ protobufc
60+ pcre2 . dev
61+ ]
62+ ++ lib . optional stdenv . hostPlatform . isDarwin libiconv
63+ ++ lib . optional withSfcgal sfcgal ;
5964 nativeBuildInputs = [
6065 autoconf
6166 automake
@@ -87,7 +92,7 @@ buildPostgresqlExtension (finalAttrs: {
8792 "--with-gdalconfig=${ gdal } /bin/gdal-config"
8893 "--with-jsondir=${ json_c . dev } "
8994 "--disable-extension-upgrades-install"
90- ] ;
95+ ] ++ lib . optional withSfcgal "--with-sfcgal= ${ sfcgal } /bin/sfcgal-config" ;
9196
9297 makeFlags = [
9398 "PERL=${ perl } /bin/perl"
@@ -130,6 +135,25 @@ buildPostgresqlExtension (finalAttrs: {
130135 end$$;
131136 -- st_makepoint goes through c code
132137 select st_makepoint(1, 1);
138+ ''
139+ + lib . optionalString withSfcgal ''
140+ CREATE EXTENSION postgis_sfcgal;
141+ do $$
142+ begin
143+ if postgis_sfcgal_version() <> '${ sfcgal . version } ' then
144+ raise '"%" does not match "${ sfcgal . version } "', postgis_sfcgal_version();
145+ end if;
146+ end$$;
147+ CREATE TABLE geometries (
148+ name varchar,
149+ geom geometry(PolygonZ) NOT NULL
150+ );
151+
152+ INSERT INTO geometries(name, geom) VALUES
153+ ('planar geom', 'PolygonZ((1 1 0, 1 2 0, 2 2 0, 2 1 0, 1 1 0))'),
154+ ('nonplanar geom', 'PolygonZ((1 1 1, 1 2 -1, 2 2 2, 2 1 0, 1 1 1))');
155+
156+ SELECT name from geometries where cg_isplanar(geom);
133157 '' ;
134158 } ;
135159
0 commit comments