Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
gdal: add ecw driver support
Browse files Browse the repository at this point in the history
  • Loading branch information
imincik committed Aug 1, 2024
1 parent 8a88450 commit c265c2e
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 1 deletion.
5 changes: 4 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,21 @@
# Core libs
gdal = pkgs.callPackage ./pkgs/gdal {
inherit geos libgeotiff libspatialite proj tiledb;
ecw-sdk = ecw-sdk;
useJava = false;
};
gdal-minimal = pkgs.callPackage ./pkgs/gdal {
inherit geos libgeotiff libspatialite proj tiledb;
ecw-sdk = ecw-sdk;
useMinimalFeatures = true;
};
gdal-master = (pkgs.callPackage ./pkgs/gdal/master.nix {
inherit gdal;
}).master;
_gdal = gdal;

ecw-sdk = pkgs.callPackage ./pkgs/gdal/ecw.nix { };

geos = pkgs.callPackage ./pkgs/geos { };

libgeotiff = pkgs.callPackage ./pkgs/libgeotiff {
Expand All @@ -113,7 +117,6 @@

proj = pkgs.callPackage ./pkgs/proj { };


# Python packages
python-packages = forAllPythonVersions (python:
let
Expand Down
15 changes: 15 additions & 0 deletions pkgs/gdal/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
, useNetCDF ? (!useMinimalFeatures)
, useArmadillo ? (!useMinimalFeatures)
, useJava ? (!useMinimalFeatures)
, useECW ? false

, ant
, bison
Expand Down Expand Up @@ -75,6 +76,8 @@
, xercesc
, zlib
, zstd

, ecw-sdk
}:

stdenv.mkDerivation (finalAttrs: {
Expand Down Expand Up @@ -117,6 +120,8 @@ stdenv.mkDerivation (finalAttrs: {
# This is not strictly needed as the Java bindings wouldn't build anyway if
# ant/jdk were not available.
"-DBUILD_JAVA_BINDINGS=OFF"
] ++ lib.optionals (useECW) [
"-DECW_ROOT=${ecw-sdk}"
];

buildInputs =
Expand Down Expand Up @@ -144,6 +149,7 @@ stdenv.mkDerivation (finalAttrs: {
];
netCdfDeps = lib.optionals useNetCDF [ netcdf ];
armadilloDeps = lib.optionals useArmadillo [ armadillo ];
ecwDeps = lib.optionals useECW [ ecw-sdk ];

darwinDeps = lib.optionals stdenv.isDarwin [ libiconv ];
nonDarwinDeps = lib.optionals (!stdenv.isDarwin) ([
Expand Down Expand Up @@ -195,6 +201,7 @@ stdenv.mkDerivation (finalAttrs: {
++ hdfDeps
++ netCdfDeps
++ armadilloDeps
++ ecwDeps
++ darwinDeps
++ nonDarwinDeps;

Expand Down Expand Up @@ -266,6 +273,14 @@ stdenv.mkDerivation (finalAttrs: {
"test_ogr_parquet_write_crs_without_id_in_datum_ensemble_members"
] ++ lib.optionals (!usePoppler) [
"test_pdf_jpx_compression"
] ++ lib.optionals (useECW) [
# requires internet connection
"test_ecw_online_6"
# tests are failing
# see: https://github.com/OSGeo/gdal/issues/10526
"test_ecw_22"
"test_ecw_25"
"test_ecw_26"
];
postCheck = ''
popd # autotest
Expand Down
81 changes: 81 additions & 0 deletions pkgs/gdal/ecw.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{ lib
, stdenv
, requireFile
, autoPatchelfHook

, getent
, unzip

, libz
}:

let
downloadUrl = "https://supportsi.hexagon.com/help/s/article/ERDAS-ECW-JP2-SDK-Read-Only-Redistributable-download";
version = "5.5.0.2268-Update4";

in
stdenv.mkDerivation {
pname = "ecw-sdk";
version = version;

src = requireFile rec {
name = "ECWJP2SDKSetup_${version}-Linux.zip";
hash = "sha256-4Uarru1XTcL/Coomy4PwOPyOvCliiZa7Z+sww8lac5k=";

message = ''
In order to use ECW SDK, you need to comply with the Hexagon EULA and
download the installer file '${name}' from:
${downloadUrl}
Once you have downloaded the file, please use the following command and
re-run the installation:
nix store prefetch-file file://\$PWD/${name}
'';
};

unpackPhase = ''
unzip $src
'';

patchPhase = ''
chmod +x *.bin
patchShebangs .
'';

dontBuild = true;
dontConfigure = true;
sourceRoot = ".";
preferLocalBuild = true;

nativeBuildInputs = [
autoPatchelfHook
getent
unzip
];

buildInputs = [
libz
];

runtimeDependencies = [
];

installPhase = ''
HOME=$PWD
bash $PWD/ECWJP2SDKSetup_5.5.0.2268.bin --accept-eula=yes --install-type=1
mkdir $out
cp -a hexagon/ERDAS-ECW*/Desktop_Read-Only/* $out
'';

meta = with lib; {
description = "ECW Compression - shrink big data with Enhanced Compression Wavelet (ECW)";
homepage = "https://hexagon.com";
# license = licenses.unfree; # FIXME: enable license
maintainers = with maintainers; teams.geospatial.members;
platforms = platforms.linux;
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
};
}

0 comments on commit c265c2e

Please sign in to comment.