2 use,
INTRINSIC :: iso_c_binding
11 REAL(kind=c_double) :: x(4), y(4), z(4), xorig(4), yorig(4)
13 CHARACTER(len=512) :: proj_string
16 '+proj=utm +zone=32 +ellps=WGS84 +datum=WGS84 +units=m +no_defs +towgs84=0,0,0' 18 print*,trim(proj_string)
22 print*,
'Geographic:',pj_is_latlong(pj)
25 print*,
'Corresponding latlon projection' 26 pjll = pj_latlong_from_proj(pj)
29 print*,
'Geographic:',pj_is_latlong(pjll)
32 proj_string =
strtofchar(pj_get_def(pjll, 0), len(proj_string))
33 print*,trim(proj_string)
35 print*,
'Converting through a pjuv object' 37 coordg =
pjuv_object(11.0d0*pj_deg_to_rad, 45.0d0*pj_deg_to_rad)
40 coordp = pj_fwd(coordg, pj)
42 coordgc = pj_inv(coordp, pj)
43 print*,
'Original:',coordg
44 print*,
'Projected:',coordp
45 print*,
'Returned:',coordgc
48 IF (abs(coordgc%u-coordg%u) > 1.0d-6 .OR. abs(coordgc%v-coordg%v) > 1.0d-6)
THEN 49 print*,
'Error pj_inv*pj_fwd failed or /= identity' 53 xorig(:) = (/11.0d0,12.0d0,11.0d0,12.0d0/)*pj_deg_to_rad
54 yorig(:) = (/45.0d0,45.0d0,46.0d0,46.0d0/)*pj_deg_to_rad
56 print*,
'Converting through pj_transform_f with z' 60 print*,
'Original:',x(1),y(1)
61 res = pj_transform_f(pjll, pj, x, y, z)
62 print*,
'Projected:',x(1),y(1)
63 IF (res == 0) res = pj_transform_f(pj, pjll, x, y, z)
65 print*,
'Returned:',x(1),y(1)
67 print*,
'pj_transform with z failed' 70 IF (maxval(abs(xorig-x)) > 1.0d-6 .OR. maxval(abs(yorig-y)) > 1.0d-6)
THEN 71 print*,
'Error pj_transform*pj_transform**-1 /= identity' 75 print*,
'Converting through pj_transform_f without z' 78 print*,
'Original:',x(1),y(1)
79 res = pj_transform_f(pjll, pj, x, y)
80 print*,
'Projected:',x(1),y(1)
81 IF (res == 0) res = pj_transform_f(pj, pjll, x, y)
83 print*,
'Returned:',x(1),y(1)
85 print*,
'pj_transform without z failed' 88 IF (maxval(abs(xorig-x)) > 1.0d-6 .OR. maxval(abs(yorig-y)) > 1.0d-6)
THEN 89 print*,
'Error pj_transform*pj_transform**-1 /= identity' 102 END PROGRAM proj_test
Initialize a projection from a string.
Fortran 2003 interface to the proj.4 https://github.com/OSGeo/proj.4 library.
Object describing a coordinate pair.
Object describing a cartographic projection.
Utility module for supporting Fortran 2003 C language interface module.
Convert a null-terminated C string into a Fortran CHARACTER variable of the proper length...
Test whether an opaque object is valid.