Skip to content
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

allow and wrap PROJ 9.3 #95

Merged
merged 2 commits into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading