-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
proj-data: add proj-data package and integration support #290643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,11 @@ | ||
| { lib | ||
| , stdenv | ||
| , callPackage | ||
| , fetchFromGitHub | ||
| , fetchpatch | ||
|
|
||
| , cmake | ||
| , pkg-config | ||
| , buildPackages | ||
| , callPackage | ||
| , sqlite | ||
| , libtiff | ||
| , curl | ||
|
|
@@ -62,10 +62,27 @@ stdenv.mkDerivation (finalAttrs: { | |
|
|
||
| doCheck = true; | ||
|
|
||
| passthru.tests = { | ||
| python = python3.pkgs.pyproj; | ||
| proj = callPackage ./tests.nix { proj = finalAttrs.finalPackage; }; | ||
| }; | ||
| passthru = | ||
| let | ||
| proj = finalAttrs.finalPackage; | ||
| in | ||
| { | ||
| withProjData = gridPackages: | ||
| let | ||
| proj-data = callPackage ./proj-data.nix { gridPackages = gridPackages; }; | ||
| in | ||
| proj.overrideAttrs (final: prev: { | ||
| pname = prev.pname + "-with-grid-packages"; | ||
| postInstall = '' | ||
| cp --recursive ${proj-data}/* $out/share/proj/ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than copying the data across, would it be possible to instead install proj-data and link to it from this package? That way there's only one way to install proj-data (and only ever one copy of each version), but proj can refer to that package.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately, this is not possible because |
||
| ''; | ||
| }); | ||
|
|
||
| tests = { | ||
| python = python3.pkgs.pyproj; | ||
| proj = callPackage ./tests.nix { proj = finalAttrs.finalPackage; }; | ||
| }; | ||
| }; | ||
|
|
||
| meta = with lib; { | ||
| changelog = "https://github.com/OSGeo/PROJ/blob/${finalAttrs.src.rev}/NEWS"; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| { lib | ||
| , stdenv | ||
| , fetchFromGitHub | ||
|
|
||
| # By default, no grids packages are installed due to a large size of this | ||
| # repository. Current size of all proj-data grids is almost 1GB and will only | ||
| # 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: proj-data grid $grid does not exist." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| cp $grid/!(*.sh|*.py) $out/ | ||
| done | ||
|
|
||
| shopt -u extglob | ||
| runHook postInstall | ||
| ''; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would you mind running this through |
||
|
|
||
| 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; | ||
| }; | ||
| }) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,33 @@ | ||
| { runCommand, proj }: | ||
| { pkgs, runCommand, proj }: | ||
|
|
||
| let | ||
| inherit (proj) pname; | ||
| projWithData = pkgs.proj.withProjData [ "nz_linz" ]; | ||
|
|
||
| in | ||
| runCommand "${pname}-tests" { meta.timeout = 60; } | ||
| { | ||
| proj-no-data = runCommand "${pname}-no-data-tests" { } | ||
| '' | ||
| ${proj}/bin/projinfo EPSG:4326 \ | ||
| | grep '+proj=longlat +datum=WGS84 +no_defs +type=crs' | ||
| touch $out | ||
| ''; | ||
|
|
||
| proj-with-data = runCommand "${pname}-with-data-tests" { } | ||
| '' | ||
| set -o pipefail | ||
|
|
||
| # conversion from NZGD1949 to NZGD2000 using proj strings | ||
| echo '173 -41 0' \ | ||
| | ${projWithData}/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' | ${projWithData}/bin/cs2cs --only-best -f %.8f EPSG:4272 EPSG:4167 \ | ||
| | grep -E '[0-9\.\-]+*' | ||
|
|
||
| touch $out | ||
| ''; | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't most packages implement optional add-ons as parameters to
default.nix? That is, rather than installingpkgs.foo.overrides.withBarI'd install(pkgs.foo.override { withBar = true; }). See for example 1, 2.