[GRASS-SVN] r29707 - grass/trunk/vector/v.edit/lib
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Jan 14 10:28:14 EST 2008
Author: martinl
Date: 2008-01-14 10:28:13 -0500 (Mon, 14 Jan 2008)
New Revision: 29707
Modified:
grass/trunk/vector/v.edit/lib/break.c
grass/trunk/vector/v.edit/lib/cats.c
grass/trunk/vector/v.edit/lib/copy.c
grass/trunk/vector/v.edit/lib/delete.c
grass/trunk/vector/v.edit/lib/distance.c
grass/trunk/vector/v.edit/lib/flip.c
grass/trunk/vector/v.edit/lib/merge.c
grass/trunk/vector/v.edit/lib/move.c
grass/trunk/vector/v.edit/lib/snap.c
grass/trunk/vector/v.edit/lib/vertex.c
grass/trunk/vector/v.edit/lib/zbulk.c
Log:
veditlib: cosmetics, message cleaning (debugging)
Modified: grass/trunk/vector/v.edit/lib/break.c
===================================================================
--- grass/trunk/vector/v.edit/lib/break.c 2008-01-14 13:17:31 UTC (rev 29706)
+++ grass/trunk/vector/v.edit/lib/break.c 2008-01-14 15:28:13 UTC (rev 29707)
@@ -1,5 +1,5 @@
/**
- \brief Vedit library - split/break line
+ \brief Vedit library - split/break lines
This program is free software under the
GNU General Public License (>=v2).
@@ -21,7 +21,7 @@
\param[in] Map vector map
\param[in] List list of selected lines
\param[in] coord points location
- \param[in] List_updated list of rewritten features (if given)
+ \param[in] List_updated list of rewritten features (or NULL)
\return number of modified lines
\return -1 on error
@@ -72,14 +72,15 @@
continue;
}
- G_debug (3, "do_break: line=%d, x=%f, y=%f, px=%f, py=%f, seg=%d, dist=%f, spdist=%f, lpdist=%f",
+ G_debug (3, "Vedit_split_lines(): line=%d, x=%f, y=%f, px=%f, py=%f, seg=%d, "
+ "dist=%f, spdist=%f, lpdist=%f",
line, coord->x[j], coord->y[j], px, py, seg, dist, spdist, lpdist);
if (spdist <= 0.0 ||
spdist >= Vect_line_length(Points))
continue;
- G_debug (3, "do_break: line=%d broken", line);
+ G_debug (3, "Vedit_split_lines(): line=%d", line);
/* copy first line part */
for (l = 0; l < seg; l++) {
@@ -92,6 +93,9 @@
/* rewrite the line */
newline = Vect_rewrite_line (Map, line, type, Points2, Cats);
+ if (newline < 0) {
+ return -1;
+ }
if (List_updated)
Vect_list_append (List_updated, newline);
Vect_reset_line (Points2);
@@ -107,6 +111,9 @@
/* rewrite the line */
newline = Vect_write_line (Map, type, Points2, Cats);
+ if (newline < 0) {
+ return -1;
+ }
if (List_updated)
Vect_list_append (List_updated, newline);
@@ -233,7 +240,7 @@
}
if (!n_on_line[0] || !n_on_line[1]) {
- G_warning (_("Unable to connect line id %d to line %d"), line[0], line[1]);
+ G_warning (_("Unable to connect lines %d,%d"), line[0], line[1]);
continue;
}
@@ -260,13 +267,11 @@
Points[0] -> z[pnt_idx[0]],
WITHOUT_Z);
- G_debug (3, "do_connect: dist=%f/%f -> pnt_idx=%d -> x=%f, y=%f / dist_connect=%f (thresh=%f)",
+ G_debug (3, "Vedit_connect_lines(): dist=%f/%f -> pnt_idx=%d -> "
+ "x=%f, y=%f / dist_connect=%f (thresh=%f)",
dist[0], dist[1], pnt_idx[0], nx[pnt_idx[1]], ny[pnt_idx[1]], dist_connect, thresh);
if (thresh >= 0.0 && dist_connect > thresh) {
- G_warning (_("Unable to connect line id %d to line %d because of threshold distance. "
- "Run v.edit with other threshold distance value."),
- line[0], line[1]);
continue;
}
@@ -282,6 +287,9 @@
/* rewrite the first line */
newline = Vect_rewrite_line (Map, line[0], type[0], Points[0], Cats[0]);
+ if (newline < 0) {
+ return -1;
+ }
Vect_list_append (List_updated, newline);
connected = 1;
}
@@ -310,8 +318,7 @@
if (connected)
nlines_modified += 2;
- else
- G_warning (_("Unable to connect line id %d to line %d"), line[0], line[1]);
+
} /* for each line pair */
/* destroy structures */
Modified: grass/trunk/vector/v.edit/lib/cats.c
===================================================================
--- grass/trunk/vector/v.edit/lib/cats.c 2008-01-14 13:17:31 UTC (rev 29706)
+++ grass/trunk/vector/v.edit/lib/cats.c 2008-01-14 15:28:13 UTC (rev 29707)
@@ -16,12 +16,12 @@
#include "vedit.h"
/**
- \brief Edit category numbers of selected vector features
+ \brief Add/remove categories of selected vector features
\param[in] Map vector map
\param[in] List list of selected features
\param[in] layer layer number
- \param[in] del action (add/delete)
+ \param[in] del action (non-zero for delete otherwise add)
\param[in] cats_list list of category numbers
\return number of modified features
@@ -36,62 +36,63 @@
int line, type, cat;
int nlines_modified, rewrite;
- nlines_modified = 0;
-
/* features defined by cats */
- if(Clist->n_ranges > 0) {
- Cats = Vect_new_cats_struct ();
- Points = Vect_new_line_struct();
+ if(Clist->n_ranges <= 0) {
+ return 0;
+ }
- /* for each line, set new category */
- for (i = 0; i < List->n_values; i++) {
- line = List->value[i];
- type = Vect_read_line(Map, Points, Cats, line);
+ nlines_modified = 0;
- if (!Vect_line_alive (Map, line))
- continue;
+ Cats = Vect_new_cats_struct ();
+ Points = Vect_new_line_struct();
- rewrite = 0;
- for (j = 0; j < Clist -> n_ranges; j++) {
- for (cat = Clist -> min[j]; cat <= Clist -> max[j]; cat++) {
- /* add new category */
- if (!del) {
- if(Vect_cat_set (Cats, layer, cat) < 1) {
- G_warning (_("Unable to set category %d line %d"),
- cat, line);
- }
- else {
- rewrite = 1;
- }
+ /* for each line, set new category */
+ for (i = 0; i < List->n_values; i++) {
+ line = List->value[i];
+ type = Vect_read_line(Map, Points, Cats, line);
+
+ if (!Vect_line_alive (Map, line))
+ continue;
+
+ rewrite = 0;
+ for (j = 0; j < Clist -> n_ranges; j++) {
+ for (cat = Clist -> min[j]; cat <= Clist -> max[j]; cat++) {
+ /* add new category */
+ if (!del) {
+ if(Vect_cat_set (Cats, layer, cat) < 1) {
+ G_warning (_("Unable to set category %d for line %d"),
+ cat, line);
}
- else { /* delete old category */
- if(Vect_field_cat_del (Cats, layer, cat) == 0) {
- G_warning (_("Unable to delete layer/category [%d/%d] line %d"),
- layer, cat, line);
- }
- else {
- rewrite = 1;
- }
+ else {
+ rewrite = 1;
}
}
+ else { /* delete old category */
+ if(Vect_field_cat_del (Cats, layer, cat) == 0) {
+ G_warning (_("Unable to delete layer/category %d/%d line %d"),
+ layer, cat, line);
+ }
+ else {
+ rewrite = 1;
+ }
+ }
}
-
- if (rewrite == 0)
- continue;
-
- if (Vect_rewrite_line (Map, line, type, Points, Cats) < 0) {
- G_warning (_("Unable to rewrite line %d"), line);
- return -1;
- }
-
- nlines_modified++;
-
}
-
- /* destroy structures */
- Vect_destroy_line_struct(Points);
- Vect_destroy_cats_struct(Cats);
+
+ if (rewrite == 0)
+ continue;
+
+ if (Vect_rewrite_line (Map, line, type, Points, Cats) < 0) {
+ return -1;
+ }
+
+ nlines_modified++;
+
}
+
+ /* destroy structures */
+ Vect_destroy_line_struct(Points);
+ Vect_destroy_cats_struct(Cats);
return nlines_modified;
}
Modified: grass/trunk/vector/v.edit/lib/copy.c
===================================================================
--- grass/trunk/vector/v.edit/lib/copy.c 2008-01-14 13:17:31 UTC (rev 29706)
+++ grass/trunk/vector/v.edit/lib/copy.c 2008-01-14 15:28:13 UTC (rev 29707)
@@ -51,11 +51,10 @@
type = Vect_read_line(FromMap, Points, Cats, line);
- G_debug(3, "Copying line type %d number %d", type, line);
+ G_debug(3, "Vedit_copy_lines(): type=%d, line=%d", type, line);
/* copy */
if (Vect_write_line (Map, type, Points, Cats) < 0) {
- G_warning (_("Unable to write line %d"), line);
return -1;
}
Modified: grass/trunk/vector/v.edit/lib/delete.c
===================================================================
--- grass/trunk/vector/v.edit/lib/delete.c 2008-01-14 13:17:31 UTC (rev 29706)
+++ grass/trunk/vector/v.edit/lib/delete.c 2008-01-14 15:28:13 UTC (rev 29707)
@@ -35,8 +35,7 @@
line = List -> value[i];
if (Vect_line_alive(Map, line)) {
- if (-1 == Vect_delete_line(Map, line)) {
- G_warning (_("Unable to delete line %d"), line);
+ if (Vect_delete_line(Map, line) < 0) {
return -1;
}
Modified: grass/trunk/vector/v.edit/lib/distance.c
===================================================================
--- grass/trunk/vector/v.edit/lib/distance.c 2008-01-14 13:17:31 UTC (rev 29706)
+++ grass/trunk/vector/v.edit/lib/distance.c 2008-01-14 15:28:13 UTC (rev 29707)
@@ -66,5 +66,8 @@
*mindistidx = i;
}
- return distances [*mindistidx];
+ G_debug(3, "Vedit_get_min_distance(): dists=%f,%f,%f,%f",
+ distances[0], distances[1], distances[2], distances[3]);
+
+ return distances[*mindistidx];
}
Modified: grass/trunk/vector/v.edit/lib/flip.c
===================================================================
--- grass/trunk/vector/v.edit/lib/flip.c 2008-01-14 13:17:31 UTC (rev 29706)
+++ grass/trunk/vector/v.edit/lib/flip.c 2008-01-14 15:28:13 UTC (rev 29707)
@@ -49,11 +49,11 @@
Vect_line_reverse (Points);
if (Vect_rewrite_line (Map, line, type, Points, Cats) < 0) {
- G_warning (_("Unable to rewrite line %d"),
- line);
return -1;
}
+ G_debug(3, "Vedit_flip_lines(): line=%d", line);
+
nlines_flipped++;
}
Modified: grass/trunk/vector/v.edit/lib/merge.c
===================================================================
--- grass/trunk/vector/v.edit/lib/merge.c 2008-01-14 13:17:31 UTC (rev 29706)
+++ grass/trunk/vector/v.edit/lib/merge.c 2008-01-14 15:28:13 UTC (rev 29707)
@@ -61,8 +61,6 @@
nlines_merged = 0;
if (List->n_values < 2) {
- G_warning (_("Only %d lines found, at least two needed"),
- List->n_values);
return 0;
}
@@ -146,12 +144,10 @@
Points2, Cats2,
-1.0, &Points); /* do not use threshold value */
- G_debug (3, "merge lines: %d, %d", line1, line2);
+ G_debug (3, "Vedit_merge_lines(): lines=%d,%d", line1, line2);
if (Points -> n_points > 0) {
if (Vect_delete_line(Map, line2) == -1) {
- G_warning (_("Unable to delete line %d"),
- line2);
return -1;
}
@@ -164,8 +160,6 @@
if (Points -> n_points > 0) {
line = Vect_rewrite_line (Map, line1, type1, Points, Cats1);
if (line < 0) {
- G_warning (_("Unable to rewrite line %d"),
- line1);
return -1;
}
@@ -202,7 +196,7 @@
mindist = Vedit_get_min_distance(Points1, Points2, 0, /* TODO 3D */
&mindistidx);
- G_debug (3, "merge line ? index: %d, mindist: %g, thresh: %g",
+ G_debug (3, " merge line ? index: %d, mindist: %g, thresh: %g",
mindistidx, mindist, thresh);
if (thresh > 0 && mindist > thresh) {
Modified: grass/trunk/vector/v.edit/lib/move.c
===================================================================
--- grass/trunk/vector/v.edit/lib/move.c 2008-01-14 13:17:31 UTC (rev 29706)
+++ grass/trunk/vector/v.edit/lib/move.c 2008-01-14 15:28:13 UTC (rev 29707)
@@ -50,7 +50,7 @@
type = Vect_read_line(Map, Points, Cats, line);
- G_debug(3, "Vedit_move_lines(): type=%d, id=%d", type, line);
+ G_debug(3, "Vedit_move_lines(): type=%d, line=%d", type, line);
x = Points->x;
y = Points->y;
@@ -74,8 +74,6 @@
newline = Vect_rewrite_line (Map, line, type, Points, Cats);
if (newline < 0) {
- G_warning(_("Unable to rewrite line %d"),
- line);
return -1;
}
Modified: grass/trunk/vector/v.edit/lib/snap.c
===================================================================
--- grass/trunk/vector/v.edit/lib/snap.c 2008-01-14 13:17:31 UTC (rev 29706)
+++ grass/trunk/vector/v.edit/lib/snap.c 2008-01-14 15:28:13 UTC (rev 29707)
@@ -72,6 +72,7 @@
*y = Points->y[mindist_idx];
*z = Points->z[mindist_idx];
snapped = 1;
+ G_debug(3, "Vedit_snap_point(): line=%d", line2snap);
}
}
@@ -149,11 +150,11 @@
z[npoints-1] = z[0];
rewrite = 1;
+ G_debug(3, "Vedit_snap_line(): line=%d", line);
}
if (rewrite) {
if (Vect_rewrite_line (Map, line, type, Points, Cats) < 0) {
- G_warning(_("Unable to rewrite line %d"), line);
return -1;
}
}
Modified: grass/trunk/vector/v.edit/lib/vertex.c
===================================================================
--- grass/trunk/vector/v.edit/lib/vertex.c 2008-01-14 13:17:31 UTC (rev 29706)
+++ grass/trunk/vector/v.edit/lib/vertex.c 2008-01-14 15:28:13 UTC (rev 29707)
@@ -152,7 +152,6 @@
if (rewrite) {
if (Vect_rewrite_line (Map, line, type, Points, Cats) < 0) {
- G_warning(_("Unable to rewrite line %d"), line);
return -1;
}
@@ -243,7 +242,6 @@
if (rewrite) {
Vect_line_prune (Points);
if (Vect_rewrite_line (Map, line, type, Points, Cats) < 0) {
- G_warning(_("Unable to rewrite line %d"), line);
return -1;
}
@@ -326,7 +324,6 @@
if (rewrite) {
/* rewrite the line */
if (Vect_rewrite_line (Map, line, type, Points, Cats) < 0) {
- G_warning (_("Unable to rewrite line %d"), line);
return -1;
}
Modified: grass/trunk/vector/v.edit/lib/zbulk.c
===================================================================
--- grass/trunk/vector/v.edit/lib/zbulk.c 2008-01-14 13:17:31 UTC (rev 29706)
+++ grass/trunk/vector/v.edit/lib/zbulk.c 2008-01-14 15:28:13 UTC (rev 29707)
@@ -64,6 +64,9 @@
/* write temporaly line */
temp_line = Vect_write_line(Map, GV_LINE, Points_se, Cats);
+ if (temp_line < 0) {
+ return -1;
+ }
/* determine order of lines */
cv_i = 0;
@@ -110,13 +113,17 @@
Points->z[p_i] = value;
}
- Vect_rewrite_line(Map, line, type, Points, Cats);
+ if (Vect_rewrite_line(Map, line, type, Points, Cats) < 0) {
+ return -1;
+ }
nlines_modified++;
value += step;
}
- Vect_delete_line(Map, temp_line);
+ if (Vect_delete_line(Map, temp_line) < 0) {
+ return -1;
+ }
db_CatValArray_free(&cv);
Vect_destroy_line_struct(Points);
More information about the grass-commit
mailing list