[GRASS-SVN] r68453 - grass/trunk/raster/r.resamp.interp

svn_grass at osgeo.org svn_grass at osgeo.org
Tue May 17 14:02:57 PDT 2016


Author: mmetz
Date: 2016-05-17 14:02:57 -0700 (Tue, 17 May 2016)
New Revision: 68453

Modified:
   grass/trunk/raster/r.resamp.interp/main.c
Log:
r.resamp.interp: do not use Rast_easting_to_col() because it does ll wrap

Modified: grass/trunk/raster/r.resamp.interp/main.c
===================================================================
--- grass/trunk/raster/r.resamp.interp/main.c	2016-05-17 20:48:12 UTC (rev 68452)
+++ grass/trunk/raster/r.resamp.interp/main.c	2016-05-17 21:02:57 UTC (rev 68453)
@@ -106,6 +106,18 @@
     /* set window to old map */
     Rast_get_cellhd(rastin->answer, "", &src_w);
 
+    if (G_projection() == PROJECTION_LL) {
+	/* try to shift source window to overlap with destination window */
+	while (src_w.west >= dst_w.east && src_w.east - 360.0 > dst_w.west) {
+	    src_w.east -= 360.0;
+	    src_w.west -= 360.0;
+	}
+	while (src_w.east <= dst_w.west && src_w.west + 360.0 < dst_w.east) {
+	    src_w.east += 360.0;
+	    src_w.west += 360.0;
+	}
+    }
+
     /* enlarge source window */
     {
 	double north = Rast_row_to_northing(0.5, &dst_w);
@@ -114,8 +126,13 @@
 	int r1 = (int)floor(Rast_northing_to_row(south, &src_w) - 0.5) + 3;
 	double west = Rast_col_to_easting(0.5, &dst_w);
 	double east = Rast_col_to_easting(dst_w.cols - 0.5, &dst_w);
+	/* do not use Rast_easting_to_col() because it does ll wrap */
+	/*
 	int c0 = (int)floor(Rast_easting_to_col(west, &src_w) - 0.5) - 2;
 	int c1 = (int)floor(Rast_easting_to_col(east, &src_w) - 0.5) + 3;
+	*/
+	int c0 = (int)floor(((west - src_w.west) / src_w.ew_res) - 0.5) - 2;
+	int c1 = (int)floor(((east - src_w.west) / src_w.ew_res) - 0.5) + 3;
 
 	src_w.south -= src_w.ns_res * (r1 - src_w.rows);
 	src_w.north += src_w.ns_res * (-r0);



More information about the grass-commit mailing list