[GRASS-SVN] r64205 - grass/trunk/lib/vector/Vlib
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Jan 15 13:11:58 PST 2015
Author: mmetz
Date: 2015-01-15 13:11:57 -0800 (Thu, 15 Jan 2015)
New Revision: 64205
Modified:
grass/trunk/lib/vector/Vlib/poly.c
Log:
Vlib: sync Vect_point_in_*() fns, add comments
Modified: grass/trunk/lib/vector/Vlib/poly.c
===================================================================
--- grass/trunk/lib/vector/Vlib/poly.c 2015-01-15 21:03:24 UTC (rev 64204)
+++ grass/trunk/lib/vector/Vlib/poly.c 2015-01-15 21:11:57 UTC (rev 64205)
@@ -657,7 +657,7 @@
\return 0 - outside
\return 1 - inside
- \return 2 - on the boundary (exactly may be said only for vertex of vertical/horizontal line)
+ \return 2 - on the boundary
*/
int Vect_point_in_poly(double X, double Y, const struct line_pnts *Points)
{
@@ -686,7 +686,7 @@
\return 0 - outside
\return 1 - inside
- \return 2 - on the boundary (exactly may be said only for vertex of vertical/horizontal line)
+ \return 2 - on the boundary
*/
int
Vect_point_in_area_outer_ring(double X, double Y, const struct Map_info *Map,
@@ -699,9 +699,11 @@
const struct Plus_head *Plus;
struct P_area *Area;
- G_debug(3, "Vect_point_in_area_outer_ring(): x = %f y = %f area = %d", X,
- Y, area);
+ /* keep in sync with Vect_point_in_island() */
+ G_debug(3, "Vect_point_in_area_outer_ring(): x = %f y = %f area = %d",
+ X, Y, area);
+
if (first == 1) {
Points = Vect_new_line_struct();
first = 0;
@@ -715,10 +717,8 @@
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);
Vect_read_line(Map, Points, NULL, line);
@@ -736,12 +736,9 @@
* just feeding the line to segments_x_ray() */
inter = segments_x_ray(X, Y, Points);
- G_debug(3, " inter = %d", inter);
-
if (inter == -1)
return 2;
n_intersects += inter;
- G_debug(3, " n_intersects = %d", n_intersects);
}
/* odd number of intersections: inside, return 1
@@ -759,7 +756,7 @@
\return 0 - outside
\return 1 - inside
- \return 2 - on the boundary (exactly may be said only for vertex of vertical/horizontal line)
+ \return 2 - on the boundary
*/
int Vect_point_in_island(double X, double Y, const struct Map_info *Map,
int isle, struct bound_box *box)
@@ -771,8 +768,11 @@
const struct Plus_head *Plus;
struct P_isle *Isle;
- G_debug(3, "Vect_point_in_island(): x = %f y = %f isle = %d", X, Y, isle);
+ /* keep in sync with Vect_point_in_area_outer_ring() */
+ G_debug(3, "Vect_point_in_island(): x = %f y = %f isle = %d",
+ X, Y, isle);
+
if (first == 1) {
Points = Vect_new_line_struct();
first = 0;
@@ -781,6 +781,7 @@
Plus = &(Map->plus);
Isle = Plus->Isle[isle];
+ /* First it must be in box */
if (X < box->W || X > box->E || Y > box->N || Y < box->S)
return 0;
More information about the grass-commit
mailing list