Unverified Commit 7442b7f8 authored by Maximilian Bosch's avatar Maximilian Bosch Committed by GitHub
Browse files

Merge: postgis: add sfcgal support (#366650)

parents 745df266 007496f7
Loading
Loading
Loading
Loading
+34 −10
Original line number Diff line number Diff line
@@ -26,6 +26,8 @@
  automake,
  libtool,
  which,
  sfcgal,
  withSfcgal ? false,
}:

let
@@ -47,7 +49,8 @@ buildPostgresqlExtension (finalAttrs: {
    hash = "sha256-wh7Lav2vnKzGWuSvvMFvAaGV7ynD+KgPsFUgujdtzlA=";
  };

  buildInputs = [
  buildInputs =
    [
      libxml2
      geos
      proj
@@ -55,7 +58,9 @@ buildPostgresqlExtension (finalAttrs: {
      json_c
      protobufc
      pcre2.dev
  ] ++ lib.optional stdenv.hostPlatform.isDarwin libiconv;
    ]
    ++ lib.optional stdenv.hostPlatform.isDarwin libiconv
    ++ lib.optional withSfcgal sfcgal;
  nativeBuildInputs = [
    autoconf
    automake
@@ -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"
@@ -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);
      '';
  };