Преглед на файлове

v.in.ogr: improve suggest snap threshold value

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@55920 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz преди 12 години
родител
ревизия
c6d8e5a484
променени са 2 файла, в които са добавени 43 реда и са изтрити 16 реда
  1. 34 14
      vector/v.in.ogr/main.c
  2. 9 2
      vector/v.in.ogr/v.in.ogr.html

+ 34 - 14
vector/v.in.ogr/main.c

@@ -1346,12 +1346,13 @@ int main(int argc, char *argv[])
 	Vect_topo_check(&Map, NULL);
 
     if (n_polygons) {
-	ncentr = Vect_get_num_primitives(&Map, GV_CENTROID);
+	/* test for topological errors */
 	/* this test is not perfect:
 	 * small gaps (areas without centroid) are not detected
-	 * because they may be true gaps */
+	 * small gaps may also be true gaps */
+	ncentr = Vect_get_num_primitives(&Map, GV_CENTROID);
 	if (ncentr != n_polygons || n_overlaps) {
-	    double new_snap;
+	    double min_snap, max_snap;
 
 	    Vect_get_map_box(&Map, &box);
 	    
@@ -1367,20 +1368,39 @@ int main(int argc, char *argv[])
 	    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;
+	    /* double precision ULP */
+	    min_snap = log2(xmax) - 52;
+	    min_snap = pow(2, min_snap);
+	    /* human readable */
+	    min_snap = log10(min_snap);
+	    if (min_snap < 0)
+		min_snap = (int)min_snap;
+	    else
+		min_snap = (int)min_snap + 1;
+	    min_snap = pow(10, min_snap);
+
+	    /* single precision ULP */
+	    max_snap = log2(xmax) - 23;
+	    max_snap = pow(2, max_snap);
+	    /* human readable */
+	    max_snap = log10(max_snap);
+	    if (max_snap < 0)
+		max_snap = (int)max_snap;
 	    else
-		new_snap = (int)new_snap + 1;
-	    new_snap = pow(10, new_snap);
+		max_snap = (int)max_snap + 1;
+	    max_snap = pow(10, max_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);
+	    G_important_message("%s", separator);
+	    G_warning(_("Errors were encountered during the import"));
+
+	    if (snap < min_snap) {
+		G_important_message(_("Try to import again, snapping with at least %g: 'snap=%g'"), min_snap, min_snap);
+	    }
+	    else if (snap < max_snap) {
+		min_snap = snap * 10;
+		G_important_message(_("Try to import again, snapping with %g: 'snap=%g'"), min_snap, min_snap);
 	    }
+	    /* else assume manual cleaning is required */
 	}
     }
 

+ 9 - 2
vector/v.in.ogr/v.in.ogr.html

@@ -21,9 +21,16 @@ The <b>-r</b> current region flag is identical, but uses the current
 region settings as the spatial bounds
 (see <em><a href="g.region.html">g.region</a></em>).
 
-<p>
+<h3>Topology cleaning</h3>
 Topology cleaning on areas is automatically performed, but may fail in
-special cases (then use <em><a href="v.clean.html">v.clean</a></em>).
+special cases. In these cases, a <b>snap</b> threshold value is 
+estimated from the imported vector data and printed out at the end. The 
+vector data can then be imported again with the suggested <b>snap</b> 
+threshold value which is incremented by powers of 10 until either an 
+estimated upper limit for the threshold value is reached or the topology 
+cleaning on areas was successful. In some cases, manual cleaning might 
+be required or areas are truly overlapping, e.g. buffers created with 
+non-topological software.
 
 <p>
 The <b>min_area</b> threshold value is being specified as area size in