Skip to content

Commit

Permalink
Allow WellKnownText input to Proj.Transformation (#111)
Browse files Browse the repository at this point in the history
* Allow WellKnownText{CRS} in Transformation constructor

* Bump version

* test
  • Loading branch information
asinghvi17 authored Oct 8, 2024
1 parent ff376fe commit b596c9b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion 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.7.1"
version = "1.7.2"

[deps]
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
Expand Down
4 changes: 2 additions & 2 deletions src/coord.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ function Transformation(
end

function Transformation(
source_crs::GFT.CoordinateReferenceSystemFormat,
target_crs::GFT.CoordinateReferenceSystemFormat;
source_crs::Union{GFT.CoordinateReferenceSystemFormat,GFT.MixedFormat{<:MaybeGFTCRS}},
target_crs::Union{GFT.CoordinateReferenceSystemFormat,GFT.MixedFormat{<:MaybeGFTCRS}};
always_xy::Bool = false,
direction::PJ_DIRECTION = PJ_FWD,
area::Ptr{PJ_AREA} = C_NULL,
Expand Down
18 changes: 14 additions & 4 deletions test/libproj.jl
Original file line number Diff line number Diff line change
Expand Up @@ -203,19 +203,29 @@ end
source_crs = GFT.EPSG("EPSG:4326")
target_crs = GFT.EPSG("EPSG:32628")

trans = Proj.Transformation(source_crs, target_crs, always_xy = false)
trans = Proj.Transformation(source_crs, target_crs, always_xy = true)
info = Proj.proj_pj_info(trans.pj)
description1 = unsafe_string(info.definition)

# crs as WellKnownText{CRS}
# verbose to work around the lack of a GFT blessed implementation in Proj
source_crs = GFT.WellKnownText(GFT.CRS(), GFT.val(GFT.ESRIWellKnownText(Proj.CRS("EPSG:4326"))))
target_crs = GFT.WellKnownText(GFT.CRS(), GFT.val(GFT.ESRIWellKnownText(Proj.CRS("EPSG:32628"))))

trans = Proj.Transformation(source_crs, target_crs, always_xy = true)
info = Proj.proj_pj_info(trans.pj)
description2 = unsafe_string(info.definition)

#crs as txt
source_crs = "EPSG:4326"
target_crs = "EPSG:32628"

trans = Proj.Transformation(source_crs, target_crs, always_xy = false)
trans = Proj.Transformation(source_crs, target_crs, always_xy = true)
info = Proj.proj_pj_info(trans.pj)
description2 = unsafe_string(info.definition)
description_true = unsafe_string(info.definition)

@test description1 == description2
@test description1 == description_true
@test description2 == description_true
end

@testset "bounds" begin
Expand Down

2 comments on commit b596c9b

@asinghvi17
Copy link
Member Author

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/116834

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

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.7.2 -m "<description of version>" b596c9b636c27fbc187a3de070ae8a067f128387
git push origin v1.7.2

Please sign in to comment.