diff options
| author | Ivan Mincik <ivan.mincik@gmail.com> | 2024-01-10 16:41:51 +0100 |
|---|---|---|
| committer | Ivan Mincik <ivan.mincik@gmail.com> | 2024-01-18 10:42:14 +0100 |
| commit | 0b896418c3bb05ac8f78e17c5a402713f0e58dc1 (patch) | |
| tree | 0a9cfd7124ccfc15addbe8c27020b171bc58ae47 | |
| parent | Merge pull request #279882 from r-ryantm/auto-update/grafana-agent (diff) | |
| download | nixpkgs-0b896418c3bb05ac8f78e17c5a402713f0e58dc1.tar.gz | |
proj-data: init at 1.16.0
| -rw-r--r-- | pkgs/by-name/pr/proj-data/package.nix | 73 | ||||
| -rw-r--r-- | pkgs/by-name/pr/proj-data/tests.nix | 25 |
2 files changed, 98 insertions, 0 deletions
diff --git a/pkgs/by-name/pr/proj-data/package.nix b/pkgs/by-name/pr/proj-data/package.nix new file mode 100644 index 000000000000..fc12f61946b7 --- /dev/null +++ b/pkgs/by-name/pr/proj-data/package.nix @@ -0,0 +1,73 @@ +{ lib +, stdenv +, callPackage +, fetchFromGitHub + + # proj-data grid directories to install (ex.: "nz_linz"). + # By default, no grids are installed due to the large size (size of all proj- + # data grids is nearly 1GB and will grow over the time). +, gridPackages ? [ ] +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "proj-data"; + version = "1.16.0"; + + src = fetchFromGitHub { + owner = "OSGeo"; + repo = "PROJ-data"; + rev = finalAttrs.version; + hash = "sha256-/EgDeWy2+KdcI4DLsRfWi5OWcGwO3AieEJQ5Zh+wdYE="; + }; + + installPhase = '' + runHook preInstall + shopt -s extglob + + mkdir -p $out + cp README.DATA $out/README-PROJ-DATA.md + + for grid in ${builtins.toString gridPackages}; do + if [ ! -d $grid ]; then + echo "ERROR: Grid ($grid) does not exist." >&2 + exit 1 + fi + + cp $grid/!(*.sh|*.py) $out/ + done + + shopt -u extglob + runHook postInstall + ''; + + passthru.tests = + let + # build custom package containing `nz_linz` grids + projDataWithGrid = finalAttrs.finalPackage.overrideAttrs (_: { + postInstall = "cp nz_linz/* $out/"; + }); + in + { + proj-data = callPackage ./tests.nix { + proj-data = projDataWithGrid; + }; + }; + + meta = with lib; { + description = "Repository for proj datum grids (for use by PROJ 7 or later)"; + homepage = "https://proj4.org"; + # Licensing note: + # All grids in the package are released under permissive licenses. New grids + # are accepted into the package as long as they are released under a license that + # is compatible with the Open Source Definition and the source of the grid is + # clearly stated and verifiable. Suitable licenses include: + # Public domain + # X/MIT + # BSD 2/3/4 clause + # CC0 + # CC-BY (v3.0 or later) + # CC-BY-SA (v3.0 or later) + license = licenses.mit; + maintainers = teams.geospatial.members; + }; +}) diff --git a/pkgs/by-name/pr/proj-data/tests.nix b/pkgs/by-name/pr/proj-data/tests.nix new file mode 100644 index 000000000000..09ac84a72ec2 --- /dev/null +++ b/pkgs/by-name/pr/proj-data/tests.nix @@ -0,0 +1,25 @@ +{ runCommand, proj, proj-data }: + +let + inherit (proj-data) pname; +in +runCommand "${pname}-tests" { meta.timeout = 60; } + '' + set -o pipefail + + # add proj-data files to proj resources search path + export PROJ_DATA=${proj}/share/proj:${proj-data} + + # conversion from NZGD1949 to NZGD2000 using proj strings + echo '173 -41 0' \ + | ${proj}/bin/cs2cs --only-best -f %.8f \ + +proj=longlat +ellps=intl +datum=nzgd49 +nadgrids=nz_linz_nzgd2kgrid0005.tif \ + +to +proj=longlat +ellps=GRS80 +towgs84=0,0,0 \ + | grep -E '[0-9\.\-]+*' + + # conversion from NZGD1949 to NZGD2000 using EPSG codes + echo '-41 173 0' | ${proj}/bin/cs2cs --only-best -f %.8f EPSG:4272 EPSG:4167 \ + | grep -E '[0-9\.\-]+*' + + touch $out + '' |
