Skip to content

Commit

Permalink
Merge: postgis: add sfcgal support (#366650)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ma27 authored Jan 17, 2025
2 parents 745df26 + 007496f commit 7442b7f
Showing 1 changed file with 34 additions and 10 deletions.
44 changes: 34 additions & 10 deletions pkgs/servers/sql/postgresql/ext/postgis.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
automake,
libtool,
which,
sfcgal,
withSfcgal ? false,
}:

let
Expand All @@ -47,15 +49,18 @@ buildPostgresqlExtension (finalAttrs: {
hash = "sha256-wh7Lav2vnKzGWuSvvMFvAaGV7ynD+KgPsFUgujdtzlA=";
};

buildInputs = [
libxml2
geos
proj
gdal
json_c
protobufc
pcre2.dev
] ++ lib.optional stdenv.hostPlatform.isDarwin libiconv;
buildInputs =
[
libxml2
geos
proj
gdal
json_c
protobufc
pcre2.dev
]
++ lib.optional stdenv.hostPlatform.isDarwin libiconv
++ lib.optional withSfcgal sfcgal;
nativeBuildInputs = [
autoconf
automake
Expand Down Expand Up @@ -87,7 +92,7 @@ buildPostgresqlExtension (finalAttrs: {
"--with-gdalconfig=${gdal}/bin/gdal-config"
"--with-jsondir=${json_c.dev}"
"--disable-extension-upgrades-install"
];
] ++ lib.optional withSfcgal "--with-sfcgal=${sfcgal}/bin/sfcgal-config";

makeFlags = [
"PERL=${perl}/bin/perl"
Expand Down Expand Up @@ -130,6 +135,25 @@ buildPostgresqlExtension (finalAttrs: {
end$$;
-- st_makepoint goes through c code
select st_makepoint(1, 1);
''
+ lib.optionalString withSfcgal ''
CREATE EXTENSION postgis_sfcgal;
do $$
begin
if postgis_sfcgal_version() <> '${sfcgal.version}' then
raise '"%" does not match "${sfcgal.version}"', postgis_sfcgal_version();
end if;
end$$;
CREATE TABLE geometries (
name varchar,
geom geometry(PolygonZ) NOT NULL
);
INSERT INTO geometries(name, geom) VALUES
('planar geom', 'PolygonZ((1 1 0, 1 2 0, 2 2 0, 2 1 0, 1 1 0))'),
('nonplanar geom', 'PolygonZ((1 1 1, 1 2 -1, 2 2 2, 2 1 0, 1 1 1))');
SELECT name from geometries where cg_isplanar(geom);
'';
};

Expand Down

0 comments on commit 7442b7f

Please sign in to comment.