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

Create Transformation with a single pipeline projection #69

Closed
evetion opened this issue Aug 30, 2022 · 2 comments · Fixed by #73
Closed

Create Transformation with a single pipeline projection #69

evetion opened this issue Aug 30, 2022 · 2 comments · Fixed by #73

Comments

@evetion
Copy link
Member

evetion commented Aug 30, 2022

Now to setup a pipeline, we need to handle the C API:

julia> pipe = Proj.proj_create("+proj=pipeline +step +proj=unitconvert +xy_in=deg +z_in=m +xy_out=rad +z_out=m +step +inv +proj=longlat +a=6378136.3 +rf=298.257 +e=0.08181922146 +step +proj=cart +a=6378136.3 +rf=298.257 +step +inv +proj=cart +ellps=WGS84 +step +proj=unitconvert +xy_in=rad +z_in=m +xy_out=deg +z_out=m +step +proj=axisswap +order=2,1")
Ptr{Nothing} @0x00000001254061d0

julia> Proj.proj_trans(pipe, Proj.PJ_FWD, (0,0,0))
4-element Proj.Coord:
  0.0
  0.0
 -0.7000000001862645
 Inf
@evetion
Copy link
Member Author

evetion commented Aug 30, 2022

We can also create a new struct, such as Pipeline?

@visr
Copy link
Member

visr commented Sep 6, 2022

I'd prefer to support this as part of the Proj.Transformation API. It secretly already works:

julia> using Proj

julia> pipe = Proj.proj_create("+proj=pipeline +step +proj=unitconvert +xy_in=deg +z_in=m +xy_out=rad +z_out=m +step +inv +proj=longlat +a=6378136.3 +rf=298.257 +e=0.08181922146 +step +proj=cart +a=6378136.3 +rf=298.257 +step +inv +proj=cart +ellps=WGS84 +step +proj=unitconvert +xy_in=rad +z_in=m +xy_out=deg +z_out=m +step +proj=axisswap +order=2,1")
Ptr{Nothing} @0x0000000066f7aee0

julia> trans = Proj.Transformation(pipe, PJ_FWD);

julia> trans(0, 0, 0)
(0.0, 0.0, -0.7000000001862645)

Though that hides the rough edges, since some of the code, like, show don't work:

julia> trans = Proj.Transformation(pipe, PJ_FWD)
Error showing value of type Proj.Transformation:
ERROR: ArgumentError: cannot convert NULL to string
Stacktrace:
  [1] unsafe_string
    @ .\strings\string.jl:70 [inlined]
  [2] unsafe_string
    @ .\c.jl:193 [inlined]
  [3] show(io::IOContext{Base.TTY}, trans::Proj.Transformation)
    @ Proj D:\visser_mn\.julia\dev\Proj\src\coord.jl:104

And we'd probably want a constructor that takes a single string, rather than passing the pointer to the pipeline created by proj_create.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants