[GRASS-SVN] r64204 - grass/branches/releasebranch_7_0/lib/vector/Vlib

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jan 15 13:03:24 PST 2015


Author: mmetz
Date: 2015-01-15 13:03:24 -0800 (Thu, 15 Jan 2015)
New Revision: 64204

Modified:
   grass/branches/releasebranch_7_0/lib/vector/Vlib/find.c
Log:
Vlib: optimize Vect_find_area(), add comments

Modified: grass/branches/releasebranch_7_0/lib/vector/Vlib/find.c
===================================================================
--- grass/branches/releasebranch_7_0/lib/vector/Vlib/find.c	2015-01-15 21:03:10 UTC (rev 64203)
+++ grass/branches/releasebranch_7_0/lib/vector/Vlib/find.c	2015-01-15 21:03:24 UTC (rev 64204)
@@ -287,7 +287,13 @@
     Vect_select_areas_by_box(Map, &box, List);
     G_debug(3, "  %d areas selected by box", List->n_values);
 
-    /* sort areas by size, the smallest is likely to be the nearest */
+    /* sort areas by bbox size
+     * get the smallest area that contains the point
+     * using the bbox size is working because if 2 areas both contain
+     * the point, one of these areas must be inside the other area
+     * 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) {
 	alloc_size_list = List->n_values;
 	size_list = G_realloc(size_list, alloc_size_list * sizeof(BOX_SIZE));
@@ -314,7 +320,9 @@
 
     for (i = 0; i < List->n_values; i++) {
 	area = size_list[i].i;
-	ret = Vect_point_in_area(x, y, Map, area, &size_list[i].box);
+	/* testing only the outer ring is sufficient because 
+	 * inner rings have been tested earlier (sorted list) */
+	ret = Vect_point_in_area_outer_ring(x, y, Map, area, &size_list[i].box);
 
 	G_debug(3, "    area = %d Vect_point_in_area() = %d", area, ret);
 
@@ -342,6 +350,8 @@
     static struct boxlist *List;
     static struct line_pnts *Points;
 
+    /* TODO: sync to Vect_find_area() */
+
     G_debug(3, "Vect_find_island() x = %f y = %f", x, y);
 
     if (first) {



More information about the grass-commit mailing list