[GRASS-SVN] r50023 - grass/trunk/vector/v.proj

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Jan 1 11:57:39 EST 2012


Author: mmetz
Date: 2012-01-01 08:57:39 -0800 (Sun, 01 Jan 2012)
New Revision: 50023

Modified:
   grass/trunk/vector/v.proj/main.c
   grass/trunk/vector/v.proj/v.proj.html
Log:
v.proj: optionally disable longitude wrapping in the proj4 lib

Modified: grass/trunk/vector/v.proj/main.c
===================================================================
--- grass/trunk/vector/v.proj/main.c	2012-01-01 14:40:48 UTC (rev 50022)
+++ grass/trunk/vector/v.proj/main.c	2012-01-01 16:57:39 UTC (rev 50023)
@@ -52,7 +52,7 @@
     struct Map_info Map;
     struct Map_info Out_Map;
     struct bound_box src_box, tgt_box;
-    int wrap360 = 0, recommend_wrap = 0;
+    int nowrap = 0, recommend_nowrap = 0;
     struct
     {
 	struct Flag *list;	/* list files in source location */
@@ -121,7 +121,7 @@
     flag.wrap->key = 'w';
     flag.wrap->description = _("Latlon output only, default is -180,180");
     flag.wrap->label =
-	_("Wrap to 0,360 for latlon output");
+	_("Disable wrapping to -180,180 for latlon output");
     flag.transformz->guisection = _("Target");
 
     /* The parser checks if the map already exists in current mapset,
@@ -162,7 +162,7 @@
 
     Out_proj = G_projection();
     if (Out_proj == PROJECTION_LL && flag.wrap->answer)
-	wrap360 = 1;
+	nowrap = 1;
 
     /* Change the location here and then come back */
 
@@ -209,6 +209,11 @@
 	if (in_proj_keys == NULL)
 	    exit(EXIT_FAILURE);
 
+	/* apparently the +over switch must be set in the input projection,
+	 * not the output latlon projection */
+	if (Out_proj == PROJECTION_LL && nowrap == 1)
+	    G_set_key_value("+over", "defined", in_proj_keys);
+
 	in_unit_keys = G_get_projunits();
 	if (in_unit_keys == NULL)
 	    exit(EXIT_FAILURE);
@@ -259,8 +264,8 @@
     Points = Vect_new_line_struct();
     Cats = Vect_new_cats_struct();
 
-    /* test if latlon wrapping to 0,360 would be needed */
-    if (Out_proj == PROJECTION_LL && wrap360 == 0) {
+    /* test if latlon wrapping to -180,180 should be disabled */
+    if (Out_proj == PROJECTION_LL && nowrap == 0) {
 	int first = 1, counter = 0;
 	double x, y;
 	
@@ -333,7 +338,7 @@
 	}
 	if (tgt_box.W > x) {
 	    tgt_box.E = x + 360;
-	    recommend_wrap = 1;
+	    recommend_nowrap = 1;
 	}
 	if (tgt_box.N < y)
 	    tgt_box.N = y;
@@ -349,7 +354,7 @@
 	if (tgt_box.W > x) {
 	    if (tgt_box.E < x + 360)
 		tgt_box.E = x + 360;
-	    recommend_wrap = 1;
+	    recommend_nowrap = 1;
 	}
 	if (tgt_box.N < y)
 	    tgt_box.N = y;
@@ -400,17 +405,7 @@
 			    &info_in, &info_out) < 0) {
 	    G_fatal_error(_("Error in pj_do_transform"));
 	}
-	
-	if (wrap360) {
-	    int j;
 
-	    for (j = 0; j < Points->n_points; j++) {
-		/* use tgt_box.W instead of 0 ? */
-		if (Points->x[j] < 0)
-		    Points->x[j] += 360.;
-	    }
-	}
-
 	Vect_write_line(&Out_Map, type, Points, Cats);	/* write line */
     }				/* end lines section */
     fprintf(stderr, "\r");
@@ -424,8 +419,8 @@
     Vect_build(&Out_Map);
     Vect_close(&Out_Map);
 
-    if (recommend_wrap)
-	G_important_message(_("Wrapping to 0,360 recommended."));
+    if (recommend_nowrap)
+	G_important_message(_("Try to disable wrapping to -180,180 if topological errors occurred."));
 
     exit(EXIT_SUCCESS);
 }

Modified: grass/trunk/vector/v.proj/v.proj.html
===================================================================
--- grass/trunk/vector/v.proj/v.proj.html	2012-01-01 14:40:48 UTC (rev 50022)
+++ grass/trunk/vector/v.proj/v.proj.html	2012-01-01 16:57:39 UTC (rev 50023)
@@ -26,9 +26,8 @@
 <p>When projecting into a latlon location, east coordinates are wrapped 
 by the proj4 library to fit into the range -180,180. This is in most cases 
 appropriate, but can cause errors the input vector crosses the datum line 
-at 180E/W. In this case the east coordinates need to be wrapped to the 
-range 0,360 after transformation. Wrapping of eastings to the range 0,360 
-is activated with the <b>-w</b> flag.
+at 180E/W. In this case wrapping of east coordinates to -180,180 needs 
+to be disabled with the <b>-w</b> flag.
 
 <h2>EXAMPLES</h2>
 



More information about the grass-commit mailing list