summaryrefslogtreecommitdiff
path: root/pkgs/servers/sql/postgresql/ext/pointcloud/package.nix
blob: 021f4041b4dde971ad2920d5cd03832c02f3b702 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
{
  autoconf,
  automake,
  cunit,
  fetchFromGitHub,
  fetchpatch,
  installShellFiles,
  lib,
  libtool,
  libxml2,
  perl,
  postgresql,
  postgresqlBuildExtension,
  postgresqlTestExtension,
  postgresqlTestHook,
  sphinx,
  stdenv,
  which,
  zlib,
}:
postgresqlBuildExtension (finalAttrs: {
  pname = "pointcloud";
  version = "1.2.5";

  outputs = [
    "out"
    "man"
  ];

  src = fetchFromGitHub {
    owner = "pgpointcloud";
    repo = "pointcloud";
    tag = "v${finalAttrs.version}";
    hash = "sha256-uFbScxq21kt0jOjjyfMeO3i+bG2/kWS/Rrt3ZpOqEns=";
  };

  nativeBuildInputs = [
    autoconf
    automake
    installShellFiles
    libtool
    perl
    # for doc
    sphinx
    # needed by the configure phase
    which
  ];

  buildInputs = [
    zlib
  ];

  doCheck = lib.meta.availableOn stdenv.buildPlatform postgresqlTestHook;

  checkInputs = [
    cunit
  ];

  nativeCheckInputs = [
    postgresql
    postgresqlTestHook
  ];

  preConfigure = ''
    ./autogen.sh
  '';

  configureFlags = [
    (lib.withFeatureAs true "xml2config" (lib.getExe' (lib.getDev libxml2) "xml2-config"))
    "CFLAGS=-std=gnu17"
  ];

  postInstall = ''
    cd doc
    make man
    installManPage build/man/pgpointcloud.1
  '';

  passthru.tests = {
    extension = postgresqlTestExtension {
      inherit (finalAttrs) finalPackage;
      # see https://pgpointcloud.github.io/pointcloud/concepts/schemas.html
      withPackages = [ "postgis" ];
      sql = builtins.readFile ./tests.sql;
      asserts = [
        {
          query = "pc_version()";
          expected = "'${lib.versions.major finalAttrs.version}.${lib.versions.minor finalAttrs.version}.${lib.versions.patch finalAttrs.version}'";
          description = "pc_version() returns correct values.";
        }
        {
          query = "pc_postgis_version()";
          expected = "'${lib.versions.major finalAttrs.version}.${lib.versions.minor finalAttrs.version}.${lib.versions.patch finalAttrs.version}'";
          description = "pc_postgis_version() returns correct values.";
        }
        # these tests are taken from the documentation of respective methods
        {
          query = "SELECT PC_AsText('010100000064CEFFFF94110000703000000400'::pcpoint)";
          expected = "'{\"pcid\":1,\"pt\":[-127,45,124,4]}'";
          description = "Creating a point and displaying as text returns correct string";
        }
        {
          query = "SELECT ST_AsText(PC_MakePoint(1, ARRAY[-127, 45, 124.0, 4.0])::geometry)";
          expected = "'POINT Z (-127 45 124)'";
          description = "Casting a pcpoint to a postgis geometry works";
        }
      ];
    };
  };

  meta = {
    description = "PostgreSQL extension for storing point cloud (LIDAR) data";
    longDescription = ''
      # pgPointcloud - A PostgreSQL extension for storing point cloud (LIDAR) data.

      LIDAR point cloud are becoming more and more available. Devices are easy to get, not too expensive, and provide very accurate 3D points. pgPointCLoud is an open source PostgreSQL extension for storing point cloud data and use it with PostGIS. It is very easy to use, robust and efficient.

      By storing LIDAR points in a PostgreSQL database, pgPointcloud eases many problems and allows a good integration with other geo-spatial data (vector, raster) into one common framework : PostGIS.
    '';
    homepage = "https://pgpointcloud.github.io/pointcloud/";
    changelog = "https://github.com/pgpointcloud/pointcloud/blob/v${finalAttrs.version}/NEWS";
    license = lib.licenses.bsd3;
    teams = [ lib.teams.geospatial ];
    inherit (postgresql.meta) platforms;
  };
})