[GRASS-SVN] r49953 - grass/trunk/vector/v.select
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Dec 28 13:11:58 EST 2011
Author: mmetz
Date: 2011-12-28 10:11:58 -0800 (Wed, 28 Dec 2011)
New Revision: 49953
Modified:
grass/trunk/vector/v.select/select.c
Log:
code cleanup, bug fix for areas without centroid
Modified: grass/trunk/vector/v.select/select.c
===================================================================
--- grass/trunk/vector/v.select/select.c 2011-12-28 17:32:03 UTC (rev 49952)
+++ grass/trunk/vector/v.select/select.c 2011-12-28 18:11:58 UTC (rev 49953)
@@ -73,7 +73,6 @@
/* Check if this line overlaps any feature in B */
/* x Lines in B */
if (btype & (GV_POINTS | GV_LINES)) {
- int i;
int found = 0;
/* Lines */
@@ -119,7 +118,6 @@
/* x Areas in B. */
if (btype & GV_AREA) {
- int i;
Vect_select_areas_by_box(bIn, &abox, List);
for (i = 0; i < List->n_values; i++) {
@@ -187,7 +185,7 @@
#endif
if (!AGeom)
G_fatal_error(_("Unable to read area id %d from vector map <%s>"),
- aline, Vect_get_full_name(aIn));
+ aarea, Vect_get_full_name(aIn));
}
/* x Lines in B */
@@ -254,7 +252,7 @@
Vect_select_areas_by_box(bIn, &abox, TmpList);
for (i = 0; i < LList->n_values; i++) {
- int j, aline;
+ int j;
aline = abs(LList->value[i]);
@@ -271,9 +269,16 @@
/* Check if any centroid of area B is in area A.
* This test is important in if area B is completely within area A */
- bcentroid = Vect_get_area_centroid(bIn, barea);
- Vect_read_line(bIn, BPoints, NULL, bcentroid);
+ if ((bcentroid = Vect_get_area_centroid(bIn, barea)) > 0)
+ Vect_read_line(bIn, BPoints, NULL, bcentroid);
+ else {
+ double x, y;
+ Vect_get_point_in_area(bIn, barea, &x, &y);
+ Vect_reset_line(BPoints);
+ Vect_append_point(BPoints, x, y, 0.0);
+ }
+
if (operator != OP_OVERLAP) {
#ifdef HAVE_GEOS
if(area_relate_geos(bIn, AGeom,
More information about the grass-commit
mailing list