Quellcode durchsuchen

r.proj: sync to trunk

git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@64034 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz vor 10 Jahren
Ursprung
Commit
a033970ab6
3 geänderte Dateien mit 59 neuen und 10 gelöschten Zeilen
  1. 54 3
      raster/r.proj/bordwalk.c
  2. 3 5
      raster/r.proj/main.c
  3. 2 2
      raster/r.proj/r.proj.h

+ 54 - 3
raster/r.proj/bordwalk.c

@@ -226,8 +226,59 @@ void bordwalk(const struct Cell_head *from_hd, struct Cell_head *to_hd,
     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);
 }

+ 3 - 5
raster/r.proj/main.c

@@ -262,7 +262,7 @@ int main(int argc, char **argv)
 #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 @@ int main(int argc, char **argv)
 	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 @@ int main(int argc, char **argv)
 	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 @@ int main(int argc, char **argv)
 	    fprintf(stdout, "Local east: %s\n", east_str);
 	}
 
-	/* somehow approximate local ewres, nsres ?? (use 'g.region -m' on lat/lon side) */
-
 	exit(EXIT_SUCCESS);
     }
 

+ 2 - 2
raster/r.proj/r.proj.h

@@ -37,8 +37,8 @@ struct menu
 
 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 *);