[GRASS-SVN] r30538 - grass/branches/releasebranch_6_3/vector/v.edit
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Mar 12 19:06:47 EDT 2008
Author: martinl
Date: 2008-03-12 19:06:47 -0400 (Wed, 12 Mar 2008)
New Revision: 30538
Modified:
grass/branches/releasebranch_6_3/vector/v.edit/args.c
grass/branches/releasebranch_6_3/vector/v.edit/description.html
grass/branches/releasebranch_6_3/vector/v.edit/global.h
grass/branches/releasebranch_6_3/vector/v.edit/main.c
grass/branches/releasebranch_6_3/vector/v.edit/max_distance.c
grass/branches/releasebranch_6_3/vector/v.edit/proto.h
grass/branches/releasebranch_6_3/vector/v.edit/select.c
Log:
v.edit: backported from trunk (requested by wxGUI/vdigit)
Modified: grass/branches/releasebranch_6_3/vector/v.edit/args.c
===================================================================
--- grass/branches/releasebranch_6_3/vector/v.edit/args.c 2008-03-12 22:00:32 UTC (rev 30537)
+++ grass/branches/releasebranch_6_3/vector/v.edit/args.c 2008-03-12 23:06:47 UTC (rev 30538)
@@ -111,10 +111,10 @@
params -> maxdist->key = "thresh";
params -> maxdist->type = TYPE_DOUBLE;
params -> maxdist->required = NO;
- params -> maxdist->multiple = NO;
- params -> maxdist->label = _("Threshold distance");
+ params -> maxdist->multiple = YES;
+ params -> maxdist->label = _("Threshold distance (coords,snap,query)");
params -> maxdist->description = _("'-1' for threshold based on the current resolution settings");
- params -> maxdist->answer = "-1";
+ params -> maxdist->answer = "-1,0,0";
params -> id = G_define_standard_option(G_OPT_V_CATS);
params -> id->required = NO;
Modified: grass/branches/releasebranch_6_3/vector/v.edit/description.html
===================================================================
--- grass/branches/releasebranch_6_3/vector/v.edit/description.html 2008-03-12 22:00:32 UTC (rev 30537)
+++ grass/branches/releasebranch_6_3/vector/v.edit/description.html 2008-03-12 23:06:47 UTC (rev 30538)
@@ -13,14 +13,13 @@
vector map are not modified at all.
<p>
-Vector features can be selected either by internal <b>id</b>,
-category number <b>cats</b>, coordinates <b>coords</b>, bounding
+Vector features can be selected either by internal <b>id</b>, category
+number <b>cats</b>, coordinates <b>coords</b>, bounding
box <b>bbox</b>, <b>polygon</b>, <b>where</b> statement (attribute
-data) or by <b>query</b>. Selecting features by
-coordinates is affected by the current 2D resolution. It can be
-changed using threshold distance <b>thresh</b>. The options
-are <em>orthogonal</em>, i.e. can be used in various combinations. For
-example:
+data) or by <b>query</b>. Selecting features by coordinates is
+affected by the current 2D resolution or by the threshold distance
+given by <b>thresh</b>. The options are <em>orthogonal</em>, i.e. can
+be used in various combinations. For example:
<div class="code"><pre>
v.edit map=roads tool=select \
@@ -75,8 +74,9 @@
standard format) to existing vector map. Features can be read from
standard input or from the given text file (<b>input</b>
option). If no header is given, the <b>-n</b> flag must be
- used. Added features can be snapped (based on <b>snap</b>
- parameter) using threshold distance <b>thresh</b>.</li>
+ used. Added features can be snapped (defined by <b>snap</b>
+ parameter) to nodes or vertices based on threshold
+ distance <b>thresh</b>.</li>
<li><b>delete</b> - Delete selected vector features from existing
vector map.</li>
@@ -88,8 +88,9 @@
<li><b>move</b> - Move selected features of existing vector map
relatively to their current location. This tool requires
<b>move</b> option. The option defines coordinates of the movement
- direction. Moved features can be snapped (based on <b>snap</b>
- parameter) using threshold distance <b>thresh</b>.</li>
+ direction. Moved features can be snapped (defined by <b>snap</b>
+ parameter) to nodes or vertices based on threshold
+ distance <b>thresh</b>.</li>
<li><b>flip</b> - Flip direction of selected vector lines
(lines or boundaries).</li>
@@ -119,8 +120,9 @@
<li><b>connect</b> - Connect selected lines or boundaries, the
first given line is connected to the second one. The second line
- is broken if necessary. The lines are connected regarding
- threshold distance <b>thresh</b>.</li>
+ is broken if necessary. The lines are connected only if distance
+ between them is not greater than snapping threshold
+ distance <b>thresh</b>.</li>
<li><b>chtype</b> - Change feature type of selected geometry
objects. Points are converted to centroids, centroids to points,
@@ -137,10 +139,10 @@
<li><b>vertexmove</b> - Move vertex(ces) specified
by <b>coords</b> option. Direction of the movement is specified by
- the <b>move</b> option. If <b>-1</b> is given only first found line or
- boundary in bounding box is modified. Moved vertex can be snapped
- (based on <b>snap</b> parameter) using threshold
- distance <b>thresh</b>.</li>
+ the <b>move</b> option. If <b>-1</b> is given only first found
+ line or boundary in bounding box is modified. Moved vertex can be
+ snapped (defined <b>snap</b>) to nodes or vertices based on
+ threshold distance <b>thresh</b>.</li>
<li><b>zbulk</b> - Assign z coordinate to 3D vector lines in given
bounding box. The first found line will get z coordinate based on
@@ -247,7 +249,7 @@
distance 10 map units:
<div class="code"><pre>
-v.edit tool=move map=roads cat=1 move=1000,-1000 snap=node thresh=10
+v.edit tool=move map=roads cat=1 move=1000,-1000 snap=node thresh=-1,10
</pre></div>
Move all features defined by bounding box
@@ -311,7 +313,7 @@
Snap all lines using threshold distance 20 map units:
<div class="code"><pre>
-v.edit map=roads id=1-9999 tool=snap thresh=20 type=line
+v.edit map=roads id=1-9999 tool=snap thresh=-1,20 type=line
</pre></div>
<h3>Connect lines</h3>
@@ -326,7 +328,7 @@
50. Maximum threshold distance is 700 map units:
<div class="code"><pre>
-v.edit map=roads tool=connect id=48,565,60,50 thresh=1000
+v.edit map=roads tool=connect id=48,565,60,50 thresh=-1,700
</pre></div>
<h3>Add vertex</h3>
@@ -380,13 +382,13 @@
Select all lines shorter (or equal) than 10 map units:
<div class="code"><pre>
-v.edit map=roads tool=select query=length thresh=-10
+v.edit map=roads tool=select query=length thresh=-1,0,-10
</pre></div>
Select from given bounding box all lines longer then 200 map units:
<div class="code"><pre>
-v.edit map=roads tool=select bbox=598260,4919730,605100,4926240 query=length thresh=1000
+v.edit map=roads tool=select bbox=598260,4919730,605100,4926240 query=length thresh=-1,0,1000
</pre></div>
<h3>Fix height of contours</h3>
Modified: grass/branches/releasebranch_6_3/vector/v.edit/global.h
===================================================================
--- grass/branches/releasebranch_6_3/vector/v.edit/global.h 2008-03-12 22:00:32 UTC (rev 30537)
+++ grass/branches/releasebranch_6_3/vector/v.edit/global.h 2008-03-12 23:06:47 UTC (rev 30538)
@@ -10,6 +10,10 @@
# define SEP "----------------------------------"
+#define THRESH_COORDS 0
+#define THRESH_SNAP 1
+#define THRESH_QUERY 2
+
enum mode {
/* geometry of features is not changed */
MODE_CREATE, /* create new vector map */
Modified: grass/branches/releasebranch_6_3/vector/v.edit/main.c
===================================================================
--- grass/branches/releasebranch_6_3/vector/v.edit/main.c 2008-03-12 22:00:32 UTC (rev 30537)
+++ grass/branches/releasebranch_6_3/vector/v.edit/main.c 2008-03-12 23:06:47 UTC (rev 30538)
@@ -33,7 +33,7 @@
int i;
int move_first, snap;
int ret, print, layer;
- double move_x, move_y, thresh;
+ double move_x, move_y, thresh[3];
struct line_pnts *coord;
@@ -145,12 +145,24 @@
}
layer = atoi (params.fld -> answer);
- if (params.query->answer) { /* allow negative threshold value (shorter / longer) */
- thresh = atof (params.maxdist -> answer);
+ i = 0;
+ while(params.maxdist->answers[i]) {
+ switch(i) {
+ case THRESH_COORDS:
+ thresh[THRESH_COORDS] = max_distance(atof (params.maxdist -> answers[THRESH_COORDS]));
+ thresh[THRESH_SNAP] = thresh[THRESH_QUERY] = thresh[THRESH_COORDS];
+ break;
+ case THRESH_SNAP:
+ thresh[THRESH_SNAP] = max_distance(atof (params.maxdist -> answers[THRESH_SNAP]));
+ break;
+ case THRESH_QUERY:
+ thresh[THRESH_QUERY] = atof (params.maxdist -> answers[THRESH_QUERY]);
+ break;
+ default: break;
+ }
+ i++;
}
- else {
- thresh = max_distance(atof (params.maxdist -> answer));
- }
+
move_first = params.move_first->answer ? 1 : 0;
snap = NO_SNAP;
if (strcmp(params.snap->answer, "node") == 0)
@@ -163,12 +175,12 @@
List = Vect_new_list();
if (action_mode == MODE_COPY && BgMap && BgMap[0]) {
List = select_lines(BgMap[0], action_mode,
- ¶ms,
+ ¶ms, thresh,
List);
}
else {
List = select_lines(&Map, action_mode,
- ¶ms,
+ ¶ms, thresh,
List);
}
}
@@ -222,16 +234,17 @@
ret = asc_to_bin(ascii, &Map, List_added);
G_message(_("%d features added"), ret);
if (ret > 0) {
+ G_verbose_message(_("Threshold value for snapping is %.2f"), thresh[THRESH_SNAP]);
if (snap != NO_SNAP) { /* apply snapping */
Vedit_snap_lines(&Map, BgMap, nbgmaps,
List_added,
- thresh,
+ thresh[THRESH_SNAP],
snap == SNAP ? 0 : 1); /* snap to vertex ? */
}
if (params.close -> answer) { /* close boundaries */
int nclosed;
- nclosed = close_lines(&Map, GV_BOUNDARY, thresh);
- G_message (_("%d lines closed"), nclosed);
+ nclosed = close_lines(&Map, GV_BOUNDARY, thresh[THRESH_SNAP]);
+ G_message (_("%d boundaries closed"), nclosed);
}
}
Vect_destroy_list (List_added);
@@ -243,35 +256,37 @@
case MODE_MOVE:
move_x = atof(params.move -> answers[0]);
move_y = atof(params.move -> answers[1]);
+ G_verbose_message(_("Threshold value for snapping is %.2f"), thresh[THRESH_SNAP]);
ret = Vedit_move_lines(&Map, BgMap, nbgmaps,
List,
- move_x, move_y, 0.0, snap, thresh); /* TODO: 3D */
+ move_x, move_y, 0.0, snap, thresh[THRESH_SNAP]); /* TODO: 3D */
G_message(_("%d features moved"), ret);
break;
case MODE_VERTEX_MOVE:
move_x = atof(params.move -> answers[0]);
move_y = atof(params.move -> answers[1]);
+ G_verbose_message(_("Threshold value for snapping is %.2f"), thresh[THRESH_SNAP]);
ret = Vedit_move_vertex(&Map, BgMap, nbgmaps,
List,
- coord, thresh,
+ coord, thresh[THRESH_COORDS], thresh[THRESH_SNAP],
move_x, move_y, 0.0, /* TODO: 3D */
move_first, snap);
G_message(_("%d vertices moved"), ret);
break;
case MODE_VERTEX_ADD:
ret = Vedit_add_vertex(&Map, List,
- coord, thresh);
+ coord, thresh[THRESH_COORDS]);
G_message(_("%d vertices added"), ret);
break;
case MODE_VERTEX_DELETE:
ret = Vedit_remove_vertex(&Map, List,
- coord, thresh);
+ coord, thresh[THRESH_COORDS]);
G_message(_("%d vertices removed"), ret);
break;
case MODE_BREAK:
if (params.coord->answer) {
ret = Vedit_split_lines(&Map, List,
- coord, thresh, NULL);
+ coord, thresh[THRESH_COORDS], NULL);
}
else {
ret = Vect_break_lines_list(&Map, List,
@@ -280,8 +295,9 @@
G_message(_("%d lines broken"), ret);
break;
case MODE_CONNECT:
+ G_verbose_message(_("Threshold value for snapping is %.2f"), thresh[THRESH_SNAP]);
ret = Vedit_connect_lines(&Map, List,
- thresh);
+ thresh[THRESH_SNAP]);
G_message(_("%d lines connected"), ret);
break;
case MODE_MERGE:
@@ -318,7 +334,8 @@
G_message (_("%d features copied"), ret);
break;
case MODE_SNAP:
- ret = snap_lines(&Map, List, thresh);
+ G_verbose_message(_("Threshold value for snapping is %.2f"), thresh[THRESH_SNAP]);
+ ret = snap_lines(&Map, List, thresh[THRESH_SNAP]);
break;
case MODE_FLIP:
ret = Vedit_flip_lines(&Map, List);
Modified: grass/branches/releasebranch_6_3/vector/v.edit/max_distance.c
===================================================================
--- grass/branches/releasebranch_6_3/vector/v.edit/max_distance.c 2008-03-12 22:00:32 UTC (rev 30537)
+++ grass/branches/releasebranch_6_3/vector/v.edit/max_distance.c 2008-03-12 23:06:47 UTC (rev 30538)
@@ -54,7 +54,9 @@
else
maxd = yres;
- G_important_message (_("Threshold distance set to %g map units (based on 2D resolution)"), maxd);
+ /*
+ G_important_message (_("Threshold distance set to %g map units (based on 2D resolution)"), maxd);
+ */
}
else {
maxd = maxdistance;
Modified: grass/branches/releasebranch_6_3/vector/v.edit/proto.h
===================================================================
--- grass/branches/releasebranch_6_3/vector/v.edit/proto.h 2008-03-12 22:00:32 UTC (rev 30537)
+++ grass/branches/releasebranch_6_3/vector/v.edit/proto.h 2008-03-12 23:06:47 UTC (rev 30538)
@@ -12,7 +12,7 @@
/* select.c */
int print_selected(struct ilist *);
struct ilist* select_lines(struct Map_info *, enum mode,
- struct GParams *,
+ struct GParams *, double *,
struct ilist *);
int sel_by_cat(struct Map_info *, struct cat_list*,
int, int, char *,
Modified: grass/branches/releasebranch_6_3/vector/v.edit/select.c
===================================================================
--- grass/branches/releasebranch_6_3/vector/v.edit/select.c 2008-03-12 22:00:32 UTC (rev 30537)
+++ grass/branches/releasebranch_6_3/vector/v.edit/select.c 2008-03-12 23:06:47 UTC (rev 30538)
@@ -34,15 +34,13 @@
\return list of newly selected features
*/
struct ilist *select_lines(struct Map_info *Map, enum mode action_mode,
- struct GParams *params,
+ struct GParams *params, double *thresh,
struct ilist *List)
{
int layer, type;
- double thresh;
layer = atoi (params -> fld -> answer);
type = Vect_option_to_types (params -> type);
- thresh = atof (params -> maxdist -> answer);
/* select by id's */
if (params -> id -> answer != NULL) {
@@ -74,8 +72,9 @@
i += 2;
}
+ G_verbose_message(_("Threshold value for coordinates is %.2f"), thresh[THRESH_COORDS]);
sel_by_coordinates(Map,
- type, coords, thresh,
+ type, coords, thresh[THRESH_COORDS],
List);
Vect_destroy_line_struct(coords);
@@ -168,8 +167,9 @@
query_type = QUERY_DANGLE;
}
+ G_verbose_message(_("Threshold value for querying is %.2f"), thresh[THRESH_QUERY]);
Vedit_select_by_query(Map,
- type, layer, thresh, query_type,
+ type, layer, thresh[THRESH_QUERY], query_type,
List_tmp);
/* merge lists (only duplicate items) */
More information about the grass-commit
mailing list