[GRASS-SVN] r47015 - grass/trunk/lib/vector/Vlib
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Jul 6 08:07:29 EDT 2011
Author: mmetz
Date: 2011-07-06 05:07:29 -0700 (Wed, 06 Jul 2011)
New Revision: 47015
Modified:
grass/trunk/lib/vector/Vlib/area.c
grass/trunk/lib/vector/Vlib/find.c
grass/trunk/lib/vector/Vlib/poly.c
Log:
sync Vect_point_in_area() to the other Vect_point_in_*() functions
Modified: grass/trunk/lib/vector/Vlib/area.c
===================================================================
--- grass/trunk/lib/vector/Vlib/area.c 2011-07-06 12:05:06 UTC (rev 47014)
+++ grass/trunk/lib/vector/Vlib/area.c 2011-07-06 12:07:29 UTC (rev 47015)
@@ -339,20 +339,20 @@
\return 1 if point is in area
\return 0 if not
*/
-int Vect_point_in_area(const struct Map_info *Map, int area, double x, double y)
+int Vect_point_in_area(double x, double y, const struct Map_info *Map,
+ int area, struct bound_box box)
{
int i, isle;
const struct Plus_head *Plus;
struct P_area *Area;
+ struct bound_box ibox;
int poly;
- struct bound_box box;
Plus = &(Map->plus);
Area = Plus->Area[area];
if (Area == NULL)
return 0;
- Vect_get_area_box(Map, area, &box);
poly = Vect_point_in_area_outer_ring(x, y, Map, area, box);
if (poly == 0)
return 0; /* includes area boundary (poly == 2), OK? */
@@ -360,8 +360,8 @@
/* check if in islands */
for (i = 0; i < Area->n_isles; i++) {
isle = Area->isles[i];
- Vect_get_isle_box(Map, isle, &box);
- poly = Vect_point_in_island(x, y, Map, isle, box);
+ Vect_get_isle_box(Map, isle, &ibox);
+ poly = Vect_point_in_island(x, y, Map, isle, ibox);
if (poly >= 1)
return 0; /* excludes island boundary (poly == 2), OK? */
}
Modified: grass/trunk/lib/vector/Vlib/find.c
===================================================================
--- grass/trunk/lib/vector/Vlib/find.c 2011-07-06 12:05:06 UTC (rev 47014)
+++ grass/trunk/lib/vector/Vlib/find.c 2011-07-06 12:07:29 UTC (rev 47015)
@@ -28,6 +28,7 @@
typedef struct {
int i;
double size;
+ struct bound_box box;
} BOX_SIZE;
static int sort_by_size(const void *a, const void *b)
@@ -299,6 +300,7 @@
for (i = 0; i < List->n_values; i++) {
size_list[i].i = List->id[i];
box = List->box[i];
+ size_list[i].box = List->box[i];
size_list[i].size = (box.N - box.S) * (box.E - box.W);
}
@@ -314,7 +316,7 @@
for (i = 0; i < List->n_values; i++) {
area = size_list[i].i;
- ret = Vect_point_in_area(Map, area, x, y);
+ ret = Vect_point_in_area(x, y, Map, area, size_list[i].box);
G_debug(3, " area = %d Vect_point_in_area() = %d", area, ret);
Modified: grass/trunk/lib/vector/Vlib/poly.c
===================================================================
--- grass/trunk/lib/vector/Vlib/poly.c 2011-07-06 12:05:06 UTC (rev 47014)
+++ grass/trunk/lib/vector/Vlib/poly.c 2011-07-06 12:07:29 UTC (rev 47015)
@@ -695,6 +695,7 @@
int n_intersects, inter;
int i, line;
static struct line_pnts *Points;
+ struct bound_box lbox;
const struct Plus_head *Plus;
struct P_line *Line;
struct P_area *Area;
@@ -715,16 +716,24 @@
return 0;
n_intersects = 0;
+
for (i = 0; i < Area->n_lines; i++) {
line = abs(Area->lines[i]);
G_debug(3, " line[%d] = %d", i, line);
Line = Plus->Line[line];
+
+ /* this is slow, but the fastest of all alternatives */
+ Vect_get_line_box(Map, line, &lbox);
+
+ /* slower as long as the spatial index is in memory: */
+ /*
+ Vect_read_line(Map, Points, NULL, line);
+ Vect_line_box(Points, &lbox);
+ */
- Vect_get_line_box(Map, line, &box);
-
/* dont check lines that obviously do not intersect with test ray */
- if ((box.N < Y) || (box.S > Y) || (box.E < X))
+ if ((lbox.N < Y) || (lbox.S > Y) || (lbox.E < X))
continue;
Vect_read_line(Map, Points, NULL, line);
@@ -763,6 +772,7 @@
int n_intersects, inter;
int i, line;
static struct line_pnts *Points;
+ struct bound_box lbox;
const struct Plus_head *Plus;
struct P_line *Line;
struct P_isle *Isle;
@@ -786,10 +796,17 @@
Line = Plus->Line[line];
- Vect_get_line_box(Map, line, &box);
+ /* this is slow, but the fastest of all alternatives */
+ Vect_get_line_box(Map, line, &lbox);
+
+ /* slower as long as the spatial index is in memory: */
+ /*
+ Vect_read_line(Map, Points, NULL, line);
+ Vect_line_box(Points, &lbox);
+ */
/* dont check lines that obviously do not intersect with test ray */
- if ((box.N < Y) || (box.S > Y) || (box.E < X))
+ if ((lbox.N < Y) || (lbox.S > Y) || (lbox.E < X))
continue;
Vect_read_line(Map, Points, NULL, line);
More information about the grass-commit
mailing list