Skip to content

Commit

Permalink
allow and wrap PROJ 9.3 (#95)
Browse files Browse the repository at this point in the history
* allow and wrap PROJ 9.3

The C API didn't change, so we might as well still allow PROJ 9.2.

Bumping the minor version for release with the new geodesics of #77.

* stop testing deprecated JLLWrappers do-syntax
  • Loading branch information
visr authored Sep 23, 2023
1 parent 28bd7c9 commit ee9ccb5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 46 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Proj"
uuid = "c94c279d-25a6-4763-9509-64d165bea63e"
version = "1.5.0"
version = "1.6.0"

[deps]
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
Expand All @@ -15,7 +15,7 @@ CEnum = "0.2, 0.3, 0.4"
CoordinateTransformations = "0.6"
GeoFormatTypes = "0.4"
GeoInterface = "1.3"
PROJ_jll = "900.100"
PROJ_jll = "900.100, 901"
julia = "1.6"

[extras]
Expand Down
4 changes: 2 additions & 2 deletions src/libproj.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2974,9 +2974,9 @@ end

const PROJ_VERSION_MAJOR = 9

const PROJ_VERSION_MINOR = 2
const PROJ_VERSION_MINOR = 3

const PROJ_VERSION_PATCH = 1
const PROJ_VERSION_PATCH = 0

const PROJ_VERSION_NUMBER =
PROJ_COMPUTE_VERSION(PROJ_VERSION_MAJOR, PROJ_VERSION_MINOR, PROJ_VERSION_PATCH)
Expand Down
74 changes: 32 additions & 42 deletions test/applications.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Test
using StaticArrays
using Proj
import PROJ_jll
using PROJ_jll
using NetworkOptions: ca_roots

function read_cmd(cmd)
Expand All @@ -14,21 +14,18 @@ function read_cmd(cmd)
end

# https://proj.org/apps/cs2cs.html#using-epsg-crs-codes
@test PROJ_jll.cs2cs() do cs2cs
read_cmd(pipeline(IOBuffer("45N 2E"), `$cs2cs EPSG:4326 EPSG:32631`))
end == "421184.70 4983436.77 0.00"
@test read_cmd(pipeline(IOBuffer("45N 2E"), `$(cs2cs()) EPSG:4326 EPSG:32631`)) ==
"421184.70 4983436.77 0.00"

# https://proj.org/usage/transformation.html?#grid-based-datum-adjustments
@test PROJ_jll.cs2cs() do cs2cs
withenv("PROJ_NETWORK" => "ON", "PROJ_CURL_CA_BUNDLE" => ca_roots()) do
read_cmd(
pipeline(
IOBuffer("-111 50"),
`$cs2cs +proj=latlong +ellps=clrk66 +nadgrids=ca_nrc_ntv1_can.tif
+to +proj=latlong +ellps=GRS80 +datum=NAD83`,
),
)
end
@test withenv("PROJ_NETWORK" => "ON", "PROJ_CURL_CA_BUNDLE" => ca_roots()) do
read_cmd(
pipeline(
IOBuffer("-111 50"),
`$(cs2cs()) +proj=latlong +ellps=clrk66 +nadgrids=ca_nrc_ntv1_can.tif
+to +proj=latlong +ellps=GRS80 +datum=NAD83`,
),
)
end == "111d0'3.006\"W 50d0'0.125\"N 0.000"

function xyzt_transform_cli(point::AbstractVector; network::Bool = false)
Expand All @@ -39,10 +36,8 @@ end

function xyzt_transform_cli(point::String; network::Bool = false)
proj_network = network ? "ON" : "OFF"
PROJ_jll.cs2cs() do cs2cs
withenv("PROJ_NETWORK" => proj_network) do
read_cmd(pipeline(IOBuffer(point), `$cs2cs -d 6 EPSG:4326+5773 EPSG:7856+5711`))
end
withenv("PROJ_NETWORK" => proj_network) do
read_cmd(pipeline(IOBuffer(point), `$(cs2cs()) -d 6 EPSG:4326+5773 EPSG:7856+5711`))
end
end

Expand Down Expand Up @@ -88,30 +83,25 @@ p = xyzt_transform(SA_F64[151, -33, 5, 2020])
p = xyzt_transform(SA_F64[151, -33, 5, floatmax()*2])
@test is_approx(p, (x, y, z, Inf))

PROJ_jll.cs2cs() do cs2cs
withenv("PROJ_NETWORK" => "OFF") do
@test read_cmd(
pipeline(IOBuffer("-33 151 5 0"), `$cs2cs -d 8 EPSG:4326+5773 EPSG:7856+5711`),
) == "313152.77721375 6346936.49580996 5.00000000 0"
end
withenv("PROJ_NETWORK" => "ON") do
@test read_cmd(
pipeline(IOBuffer("-33 151 5 0"), `$cs2cs -d 8 EPSG:4326+5773 EPSG:7856+5711`),
) == "313152.77721375 6346936.49580996 5.28064728 0"
end
end
@test withenv("PROJ_NETWORK" => "OFF") do
read_cmd(
pipeline(IOBuffer("-33 151 5 0"), `$(cs2cs()) -d 8 EPSG:4326+5773 EPSG:7856+5711`),
)
end == "313152.77721375 6346936.49580996 5.00000000 0"

@test withenv("PROJ_NETWORK" => "ON") do
read_cmd(
pipeline(IOBuffer("-33 151 5 0"), `$(cs2cs()) -d 8 EPSG:4326+5773 EPSG:7856+5711`),
)
end == "313152.77721375 6346936.49580996 5.28064728 0"

@test PROJ_jll.projinfo() do projinfo
read_cmd(`$projinfo -o PROJ EPSG:25832`)
end == """PROJ.4 string:
@test read_cmd(`$(projinfo()) -o PROJ EPSG:25832`) == """PROJ.4 string:
+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs"""

PROJ_jll.projinfo() do projinfo
n_candidate_ops = "Candidate operations found: 3"
grid_not_found =
"Grid us_nga_egm96_15.tif needed but not found on the system." *
" Can be obtained at https://cdn.proj.org/us_nga_egm96_15.tif"
info = read_cmd(`$projinfo -s EPSG:4326+5773 -t EPSG:7856+5711`)
@test occursin(n_candidate_ops, info)
@test occursin(grid_not_found, info)
end
n_candidate_ops = "Candidate operations found: 3"
grid_not_found =
"Grid us_nga_egm96_15.tif needed but not found on the system." *
" Can be obtained at https://cdn.proj.org/us_nga_egm96_15.tif"
info = read_cmd(`$(projinfo()) -s EPSG:4326+5773 -t EPSG:7856+5711`)
@test occursin(n_candidate_ops, info)
@test occursin(grid_not_found, info)

2 comments on commit ee9ccb5

@visr
Copy link
Member Author

@visr visr commented on ee9ccb5 Sep 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/92071

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.6.0 -m "<description of version>" ee9ccb5bc73cb8807f98891245c1f4ac1bb568e1
git push origin v1.6.0

Please sign in to comment.