[GRASS-SVN] r61492 - grass/trunk/lib/vector/Vlib

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jul 31 13:48:38 PDT 2014


Author: mmetz
Date: 2014-07-31 13:48:38 -0700 (Thu, 31 Jul 2014)
New Revision: 61492

Modified:
   grass/trunk/lib/vector/Vlib/build.c
Log:
Vlib: speed up Vect_isle_find_area()

Modified: grass/trunk/lib/vector/Vlib/build.c
===================================================================
--- grass/trunk/lib/vector/Vlib/build.c	2014-07-31 20:46:55 UTC (rev 61491)
+++ grass/trunk/lib/vector/Vlib/build.c	2014-07-31 20:48:38 UTC (rev 61492)
@@ -174,7 +174,7 @@
  */
 int Vect_isle_find_area(struct Map_info *Map, int isle)
 {
-    int i, line, sel_area, area, poly;
+    int i, j, line, sel_area, area, poly;
     const struct Plus_head *plus;
     struct P_line *Line;
     struct P_node *Node;
@@ -226,7 +226,7 @@
      * get the smallest area that contains the isle
      * using the bbox size is working because if 2 areas both contain
      * the isle, one of these areas must be inside the other area
-     * which means that the bbox of the outer area must be lager than
+     * which means that the bbox of the outer area must be larger than
      * the bbox of the inner area, and equal bbox sizes are not possible */
 
     if (alloc_size_list < List->n_values) {
@@ -234,12 +234,24 @@
 	size_list = G_realloc(size_list, alloc_size_list * sizeof(BOX_SIZE));
     }
 
+    j = 0;
     for (i = 0; i < List->n_values; i++) {
-	size_list[i].i = List->id[i];
 	abox = &List->box[i];
-	size_list[i].box = List->box[i];
-	size_list[i].size = (abox->N - abox->S) * (abox->E - abox->W);
+
+	if (box.E > abox->E || box.W < abox->W || box.N > abox->N ||
+	    box.S < abox->S) {
+	    G_debug(3, "  isle not completely inside area box");
+	    continue;
+	}
+	
+	List->id[j] = List->id[i];
+	List->box[j] = List->box[i];
+	size_list[j].i = List->id[j];
+	size_list[j].box = List->box[j];
+	size_list[j].size = (abox->N - abox->S) * (abox->E - abox->W);
+	j++;
     }
+    List->n_values = j;
 
     if (List->n_values > 1) {
 	if (List->n_values == 2) {



More information about the grass-commit mailing list