[GRASS-SVN] r55912 - grass/branches/develbranch_6/vector/v.in.ogr
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Apr 19 01:51:25 PDT 2013
Author: mmetz
Date: 2013-04-19 01:51:24 -0700 (Fri, 19 Apr 2013)
New Revision: 55912
Modified:
grass/branches/develbranch_6/vector/v.in.ogr/main.c
Log:
v.in.ogr: suggest a minimum snapping threshold if topological errors are encountered
Modified: grass/branches/develbranch_6/vector/v.in.ogr/main.c
===================================================================
--- grass/branches/develbranch_6/vector/v.in.ogr/main.c 2013-04-19 08:49:37 UTC (rev 55911)
+++ grass/branches/develbranch_6/vector/v.in.ogr/main.c 2013-04-19 08:51:24 UTC (rev 55912)
@@ -94,6 +94,8 @@
int layer_id;
int overwrite;
double area_size = 0.;
+ int ncentr, n_overlaps;
+ BOUND_BOX box;
G_gisinit(argv[0]);
@@ -622,6 +624,8 @@
Vect_hist_command(&Map);
+ ncentr = n_overlaps = n_polygons = 0;
+
/* Points and lines are written immediately with categories. Boundaries of polygons are
* written to the vector then cleaned and centroids are calculated for all areas in cleaan vector.
* Then second pass through finds all centroids in each polygon feature and adds its category
@@ -652,7 +656,6 @@
if (ncnames > 0) {
cat_col_name = cnames_opt->answers[0];
}
-
/* replace all spaces with underscore, otherwise dbln can't be read */
lname = G_store(layer_names[layer]);
G_strip(lname);
@@ -952,11 +955,10 @@
if (!no_clean_flag->answer &&
Vect_get_num_primitives(&Tmp, GV_BOUNDARY) > 0) {
- int ret, centr, ncentr, otype, n_overlaps, n_nocat;
+ int ret, centr, otype, n_nocat;
CENTR *Centr;
SPATIAL_INDEX si;
double x, y, total_area, overlap_area, nocat_area;
- BOUND_BOX box;
struct line_pnts *Points;
int nmodif;
@@ -1176,6 +1178,46 @@
Vect_delete(tempvect);
Vect_build(&Map);
+
+ if (n_polygons) {
+ ncentr = Vect_get_num_primitives(&Map, GV_CENTROID);
+ /* this test is not perfect:
+ * small gaps (areas without centroid) are not detected
+ * because they may be true gaps */
+ if (ncentr != n_polygons || n_overlaps) {
+ double new_snap;
+
+ Vect_get_map_box(&Map, &box);
+
+ if (abs(box.E) > abs(box.W))
+ xmax = abs(box.E);
+ else
+ xmax = abs(box.W);
+ if (abs(box.N) > abs(box.S))
+ xmax = abs(box.N);
+ else
+ xmax = abs(box.S);
+
+ if (xmax < ymax)
+ xmax = ymax;
+
+ new_snap = log2(xmax) - 52;
+ new_snap = pow(2, new_snap);
+ new_snap = log10(new_snap);
+ if (new_snap < 0)
+ new_snap = (int)new_snap;
+ else
+ new_snap = (int)new_snap + 1;
+ new_snap = pow(10, new_snap);
+
+ if (snap < new_snap) {
+ G_important_message("%s", separator);
+ G_warning(_("Errors were encountered during the import"));
+ G_important_message(_("Try to import again, snapping with at least %g: 'snap=%g'"), new_snap, new_snap);
+ }
+ }
+ }
+
Vect_close(&Map);
More information about the grass-commit
mailing list