[GRASS-SVN] r55629 - grass/trunk/vector/v.in.region
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Apr 4 14:15:02 PDT 2013
Author: mmetz
Date: 2013-04-04 14:15:02 -0700 (Thu, 04 Apr 2013)
New Revision: 55629
Modified:
grass/trunk/vector/v.in.region/main.c
grass/trunk/vector/v.in.region/v.in.region.html
Log:
v.in.region: add -d flag for raster reprojection
Modified: grass/trunk/vector/v.in.region/main.c
===================================================================
--- grass/trunk/vector/v.in.region/main.c 2013-04-04 20:37:09 UTC (rev 55628)
+++ grass/trunk/vector/v.in.region/main.c 2013-04-04 21:15:02 UTC (rev 55629)
@@ -19,12 +19,15 @@
#include <grass/gis.h>
#include <grass/vector.h>
#include <grass/dbmi.h>
+#include <grass/raster.h>
#include <grass/glocale.h>
int main(int argc, char **argv)
{
- int type, cat;
+ int type, cat, r, c;
+ double e, n;
struct Option *out_opt, *type_opt, *cat_opt;
+ struct Flag *dense_flag;
struct GModule *module;
struct Map_info Out;
struct Cell_head window;
@@ -50,6 +53,10 @@
cat_opt = G_define_standard_option(G_OPT_V_CAT);
cat_opt->answer = "1";
+ dense_flag = G_define_flag();
+ dense_flag->key = 'd';
+ dense_flag->description = _("Densify lines using region resolution");
+
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
@@ -70,16 +77,43 @@
/* Rectangle */
Vect_append_point(Points, window.west, window.south, 0.0);
- if (window.proj == PROJECTION_LL && diff_long >= 179)
+ if (dense_flag->answer) {
+ /* south: west to east */
+ for (c = 1; c < window.cols; c++) {
+ e = Rast_col_to_easting(c, &window);
+ Vect_append_point(Points, e, window.south, 0.0);
+ }
+ }
+ else if (window.proj == PROJECTION_LL && diff_long >= 179)
Vect_append_point(Points, mid_long, window.south, 0.0);
Vect_append_point(Points, window.east, window.south, 0.0);
+ if (dense_flag->answer) {
+ /* east: south to north */
+ for (r = window.rows - 1; r > 0; r--) {
+ n = Rast_row_to_northing(r, &window);
+ Vect_append_point(Points, window.east, n, 0.0);
+ }
+ }
Vect_append_point(Points, window.east, window.north, 0.0);
- if (window.proj == PROJECTION_LL && diff_long >= 179)
+ if (dense_flag->answer) {
+ /* north: east to west */
+ for (c = window.cols - 1; c > 0 ; c--) {
+ e = Rast_col_to_easting(c, &window);
+ Vect_append_point(Points, e, window.north, 0.0);
+ }
+ }
+ else if (window.proj == PROJECTION_LL && diff_long >= 179)
Vect_append_point(Points, mid_long, window.north, 0.0);
Vect_append_point(Points, window.west, window.north, 0.0);
+ if (dense_flag->answer) {
+ /* west: north to south */
+ for (r = 1; r < window.rows; r++) {
+ n = Rast_row_to_northing(r, &window);
+ Vect_append_point(Points, window.west, n, 0.0);
+ }
+ }
Vect_append_point(Points, window.west, window.south, 0.0);
-
if (type == GV_AREA) {
Vect_write_line(&Out, GV_BOUNDARY, Points, Cats);
Modified: grass/trunk/vector/v.in.region/v.in.region.html
===================================================================
--- grass/trunk/vector/v.in.region/v.in.region.html 2013-04-04 20:37:09 UTC (rev 55628)
+++ grass/trunk/vector/v.in.region/v.in.region.html 2013-04-04 21:15:02 UTC (rev 55629)
@@ -2,10 +2,17 @@
<em>v.in.region</em> creates a new vector map from current region.
+<p>
+If the output of <em>v.in.region</em> is to be used for raster
+reprojection, the <em>-d</em> flag should be used after setting the
+region to the raster map to be reprojected with
+<em><a href="r.proj.html">r.proj</a></em>.
+
<h2>SEE ALSO</h2>
<em><a href="g.region.html">g.region</a></em><br>
<em><a href="d.vect.html">d.vect</a></em><br>
+<em><a href="r.proj.html">r.proj</a></em><br>
<h2>AUTHOR</h2>
More information about the grass-commit
mailing list