1 subroutine da_xyll_lc(x, y, proj, lat, lon)
3 ! subroutine da_to convert from the (x,y) cartesian coordinate to the
4 ! geographical latitude and longitude for a Lambert Conformal projection.
8 real, intent(in) :: x ! Cartesian X coordinate
9 real, intent(in) :: y ! Cartesian Y coordinate
10 type(proj_info),intent(in) :: proj ! Projection info structure
13 real, intent(out) :: lat ! Latitude (-90->90 deg N)
14 real, intent(out) :: lon ! Longitude (-180->180 E)
24 if (trace_use_dull) call da_trace_entry("da_xyll_lc")
27 chi1 = (90.0 - proj%hemi*proj%truelat1)*rad_per_deg
28 chi2 = (90.0 - proj%hemi*proj%truelat2)*rad_per_deg
30 ! See if we are in the southern hemispere and flip the indices
32 if (proj%hemi == -1.0) then
40 ! Compute radius**2 to i/j location
41 xx = inew - proj%polei
42 yy = proj%polej - jnew
44 r = sqrt(r2)/proj%rebydx
48 lat = proj%hemi * 90.0
53 lon = proj%stdlon + deg_per_rad * ATAN2(proj%hemi*xx,yy)/proj%cone
54 lon = MOD(lon+360.0, 360.0)
56 ! Latitude. Latitude determined by solving an equation adapted
58 ! Maling, D.H., 1973: Coordinate Systems and Map Projections
59 ! Equations #20 in Appendix I.
61 if (chi1 == chi2) then
62 chi = 2.0*ATAN((r/TAN(chi1))**(1.0/proj%cone) * TAN(chi1*0.5))
64 chi = 2.0*ATAN((r*proj%cone/Sin(chi1))**(1.0/proj%cone) * TAN(chi1*0.5))
66 lat = (90.0-chi*deg_per_rad)*proj%hemi
69 if (lon > +180.0) lon = lon - 360.0
70 if (lon < -180.0) lon = lon + 360.0
72 if (trace_use_dull) call da_trace_exit("da_xyll_lc")
74 end subroutine da_xyll_lc