瀏覽代碼

v.what.rast: centroid support added

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@59341 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Neteler 11 年之前
父節點
當前提交
3e57667d27
共有 2 個文件被更改,包括 18 次插入8 次删除
  1. 11 5
      vector/v.what.rast/main.c
  2. 7 3
      vector/v.what.rast/v.what.rast.html

+ 11 - 5
vector/v.what.rast/main.c

@@ -28,7 +28,7 @@
 
 int main(int argc, char *argv[])
 {
-    int i, j, nlines, type, field, cat;
+    int i, j, nlines, type, field, cat, vtype;
     int fd;
 
     /* struct Categories RCats; */ /* TODO */
@@ -41,7 +41,7 @@ int main(int argc, char *argv[])
     char buf[2000];
     struct
     {
-	struct Option *vect, *rast, *field, *col, *where;
+	struct Option *vect, *rast, *field, *type, *col, *where;
     } opt;
     struct Flag *interp_flag, *print_flag;
     int Cache_size;
@@ -83,6 +83,10 @@ int main(int argc, char *argv[])
 
     opt.field = G_define_standard_option(G_OPT_V_FIELD);
 
+    opt.type = G_define_standard_option(G_OPT_V_TYPE);
+    opt.type->options = "point,centroid";
+    opt.type->answer = "point";
+
     opt.rast = G_define_standard_option(G_OPT_R_MAP);
     opt.rast->key = "raster";
     opt.rast->description = _("Name of existing raster map to be queried");
@@ -172,8 +176,9 @@ int main(int argc, char *argv[])
 	    G_warning(_("Raster type is float and column type is integer, some data lost!!"));
     }
 
+    vtype = Vect_option_to_types(opt.type);
     /* Read vector points to cache */
-    Cache_size = Vect_get_num_primitives(&Map, GV_POINTS);
+    Cache_size = Vect_get_num_primitives(&Map, vtype);
     /* Note: Some space may be wasted (outside region or no category) */
 
     cache = (struct order *)G_calloc(Cache_size, sizeof(struct order));
@@ -192,8 +197,9 @@ int main(int argc, char *argv[])
 	G_percent(i, nlines, 2);
 
 	/* check type */
-	if (!(type & GV_POINTS))
-	    continue;		/* Points only */
+	if (!(type & vtype))
+	    continue;		/* Points or centroids only */
+        G_debug(1, "line = %d type = %d", i, type);
 
 	/* check region */
 	if (!Vect_point_in_box(Points->x[0], Points->y[0], 0.0, &box)) {

+ 7 - 3
vector/v.what.rast/v.what.rast.html

@@ -1,8 +1,8 @@
 <h2>DESCRIPTION</h2>
 
 <em>v.what.rast</em> retrieves raster value from a given raster map for each point
-stored in a given vector map. It can update a <b>column</b> in the linked vector
-attribute table with the retrieved raster cell value or print it. The column type
+or centroid stored in a given vector map. It can update a <b>column</b> in the linked
+vector attribute table with the retrieved raster cell value or print it. The column type
 needs to be numeric (integer, float, double, ...).
 <p>
 If the <b>-p</b> flag is used, then the attribute table is not updated
@@ -12,7 +12,10 @@ If the <b>-i</b> flag is used, then the value to be uploaded to the database
 is interpolated from the four nearest raster cells values using an inverse
 distance weighting method (IDW). This is useful for cases when the vector
 point density is much higher than the raster cell size.
-
+<p>
+Points and centroid with shared category number cannot be processed.
+To solved this, unique categories may be added with <em>v.category</em> in
+a separate layer.
 
 <h2>NOTES</h2>
 
@@ -77,6 +80,7 @@ v.univar map=pnts column=heights type=point
 <h2>SEE ALSO</h2>
 
 <em>
+<a href="v.category.html">v.category</a>,
 <a href="v.db.addtable.html">v.db.addtable</a>,
 <a href="v.db.select.html">v.db.select</a>,
 <a href="v.drape.html">v.drape</a>,