[GRASS-SVN] r63697 - grass/trunk/raster/r.proj

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Dec 23 13:54:30 PST 2014


Author: mmetz
Date: 2014-12-23 13:54:30 -0800 (Tue, 23 Dec 2014)
New Revision: 63697

Modified:
   grass/trunk/raster/r.proj/bordwalk.c
   grass/trunk/raster/r.proj/main.c
   grass/trunk/raster/r.proj/r.proj.h
Log:
r.proj: fix #2100, r40560

Modified: grass/trunk/raster/r.proj/bordwalk.c
===================================================================
--- grass/trunk/raster/r.proj/bordwalk.c	2014-12-23 14:09:20 UTC (rev 63696)
+++ grass/trunk/raster/r.proj/bordwalk.c	2014-12-23 21:54:30 UTC (rev 63697)
@@ -226,8 +226,59 @@
     debug("Final check", to_hd);
 }
 
-void bordwalk2(const struct Cell_head *from_hd, struct Cell_head *to_hd,
-	      const struct pj_info *from_pj, const struct pj_info *to_pj)
+void bordwalk_edge(const struct Cell_head *from_hd, struct Cell_head *to_hd,
+	           const struct pj_info *from_pj, const struct pj_info *to_pj)
 {
-    bordwalk1(from_pj, to_pj, from_hd, to_hd);
+    double idx;
+    double hx, hy;
+
+    /* like bordwalk1, but use cell edges instead of cell centers */
+
+    /* start with cell head center */
+    hx = (from_hd->west + from_hd->east) / 2.0;
+    hy = (from_hd->north + from_hd->south) / 2.0;
+
+    if (pj_do_proj(&hx, &hy, from_pj, to_pj) < 0)
+	G_fatal_error(_("Unable to reproject map center"));
+
+    to_hd->east  = hx;
+    to_hd->west  = hx;
+    to_hd->north = hy;
+    to_hd->south = hy;
+
+    /* Top */
+    for (idx = from_hd->west; idx < from_hd->east;
+	 idx += from_hd->ew_res)
+	proj_update(from_pj, to_pj, to_hd, idx, from_hd->north);
+    idx = from_hd->east;
+    proj_update(from_pj, to_pj, to_hd, idx, from_hd->north);
+
+    debug("Top", to_hd);
+
+    /* Right */
+    for (idx = from_hd->north; idx > from_hd->south;
+	 idx -= from_hd->ns_res)
+	proj_update(from_pj, to_pj, to_hd, from_hd->east, idx);
+    idx = from_hd->south;
+    proj_update(from_pj, to_pj, to_hd, from_hd->east, idx);
+
+    debug("Right", to_hd);
+
+    /* Bottom */
+    for (idx = from_hd->east; idx > from_hd->west;
+	 idx -= from_hd->ew_res)
+	proj_update(from_pj, to_pj, to_hd, idx, from_hd->south);
+    idx = from_hd->west;
+    proj_update(from_pj, to_pj, to_hd, idx, from_hd->south);
+
+    debug("Bottom", to_hd);
+
+    /* Left */
+    for (idx = from_hd->south; idx < from_hd->north;
+	 idx += from_hd->ns_res)
+	proj_update(from_pj, to_pj, to_hd, from_hd->west, idx);
+    idx = from_hd->north;
+    proj_update(from_pj, to_pj, to_hd, from_hd->west, idx);
+
+    debug("Left", to_hd);
 }

Modified: grass/trunk/raster/r.proj/main.c
===================================================================
--- grass/trunk/raster/r.proj/main.c	2014-12-23 14:09:20 UTC (rev 63696)
+++ grass/trunk/raster/r.proj/main.c	2014-12-23 21:54:30 UTC (rev 63697)
@@ -262,7 +262,7 @@
 #endif
     G_get_window(&outcellhd);
 
-    if(gprint_bounds->answer && !print_bounds->answer)
+    if (gprint_bounds->answer && !print_bounds->answer)
 	print_bounds->answer = gprint_bounds->answer;
     curr_proj = G_projection();
 
@@ -362,7 +362,7 @@
 	outcellhd.south =  1e9;
 	outcellhd.east  = -1e9;
 	outcellhd.west  =  1e9;
-	bordwalk2(&incellhd, &outcellhd, &iproj, &oproj);
+	bordwalk_edge(&incellhd, &outcellhd, &iproj, &oproj);
 	inorth = outcellhd.north;
 	isouth = outcellhd.south;
 	ieast  = outcellhd.east;
@@ -373,7 +373,7 @@
 	G_format_easting(ieast, east_str, curr_proj);
 	G_format_easting(iwest, west_str, curr_proj);
 
-	if(gprint_bounds->answer) {
+	if (gprint_bounds->answer) {
 	    fprintf(stdout, "n=%s s=%s w=%s e=%s rows=%d cols=%d\n",
 		north_str, south_str, west_str, east_str, irows, icols);
 	}
@@ -386,8 +386,6 @@
 	    fprintf(stdout, "Local east: %s\n", east_str);
 	}
 
-	/* somehow approximate local ewres, nsres ?? (use 'g.region -m' on lat/lon side) */
-
 	exit(EXIT_SUCCESS);
     }
 

Modified: grass/trunk/raster/r.proj/r.proj.h
===================================================================
--- grass/trunk/raster/r.proj/r.proj.h	2014-12-23 14:09:20 UTC (rev 63696)
+++ grass/trunk/raster/r.proj/r.proj.h	2014-12-23 21:54:30 UTC (rev 63697)
@@ -37,8 +37,8 @@
 
 extern void bordwalk(const struct Cell_head *, struct Cell_head *,
 		     const struct pj_info *, const struct pj_info *);
-extern void bordwalk2(const struct Cell_head *, struct Cell_head *,
-		      const struct pj_info *, const struct pj_info *);
+extern void bordwalk_edge(const struct Cell_head *, struct Cell_head *,
+		          const struct pj_info *, const struct pj_info *);
 extern struct cache *readcell(int, const char *);
 extern block *get_block(struct cache *, int);
 extern void release_cache(struct cache *);



More information about the grass-commit mailing list