[OSRS-PROJ] Wrapping projections

Glynn Clements glynn.clements at virgin.net
Fri May 31 01:17:54 EDT 2002


[This originally came up on the GRASS5 list, but it probably belongs
here.]

Should inverse projection functions "wrap", in the sense of being
periodic? The problem arises primarily when trying to generate global
raster maps using pseudo-cylindrical projections.

A concrete example:

What I get currently:

	http://freespace.virgin.net/glynn.clements/map1.png

What I want:

	http://freespace.virgin.net/glynn.clements/map2.png

To get the latter, I made the following patch to PROJ:

--- src/libes/proj/PJ_urmfps.c	20 Apr 2002 19:13:44 -0000	1.2
+++ src/libes/proj/PJ_urmfps.c	30 May 2002 04:30:08 -0000
@@ -17,8 +17,12 @@
 }
 INVERSE(s_inverse); /* sphere */
 	xy.y /= P->C_y;
+	if (fabs(xy.y) > HALFPI)
+		I_ERROR
 	lp.phi = aasin(sin(xy.y) / P->n);
 	lp.lam = xy.x / (C_x * cos(xy.y));
+	if (fabs(lp.lam) > PI)
+		I_ERROR
 	return (lp);
 }
 FREEUP; if (P) pj_dalloc(P); }

This causes the routine to indicate failure for x/y coordinates which
are outside of the "globe".

Should PROJ be doing this? The problem is, if PROJ doesn't do it, the
caller can't (in this case the caller could reject longitudes outside
of [-pi,pi], but it can't handle the latitudinal wrap without knowing
the details of the projection).

-- 
Glynn Clements <glynn.clements at virgin.net>
----------------------------------------
PROJ.4 Discussion List
See http://www.remotesensing.org/proj for subscription, unsubscription
and other information.



More information about the Proj mailing list