[GRASS-SVN] r64034 - grass/branches/releasebranch_7_0/raster/r.proj

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jan 9 12:08:02 PST 2015


Author: mmetz
Date: 2015-01-09 12:08:02 -0800 (Fri, 09 Jan 2015)
New Revision: 64034

Modified:
   grass/branches/releasebranch_7_0/raster/r.proj/bordwalk.c
   grass/branches/releasebranch_7_0/raster/r.proj/main.c
   grass/branches/releasebranch_7_0/raster/r.proj/r.proj.h
Log:
r.proj: sync to trunk

Modified: grass/branches/releasebranch_7_0/raster/r.proj/bordwalk.c
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.proj/bordwalk.c	2015-01-09 20:04:07 UTC (rev 64033)
+++ grass/branches/releasebranch_7_0/raster/r.proj/bordwalk.c	2015-01-09 20:08:02 UTC (rev 64034)
@@ -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/branches/releasebranch_7_0/raster/r.proj/main.c
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.proj/main.c	2015-01-09 20:04:07 UTC (rev 64033)
+++ grass/branches/releasebranch_7_0/raster/r.proj/main.c	2015-01-09 20:08:02 UTC (rev 64034)
@@ -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/branches/releasebranch_7_0/raster/r.proj/r.proj.h
===================================================================
--- grass/branches/releasebranch_7_0/raster/r.proj/r.proj.h	2015-01-09 20:04:07 UTC (rev 64033)
+++ grass/branches/releasebranch_7_0/raster/r.proj/r.proj.h	2015-01-09 20:08:02 UTC (rev 64034)
@@ -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