[GRASS-SVN] r64208 - in grass/branches/releasebranch_7_0: include/defs lib/vector/Vlib
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Jan 15 13:34:34 PST 2015
Author: mmetz
Date: 2015-01-15 13:34:34 -0800 (Thu, 15 Jan 2015)
New Revision: 64208
Modified:
grass/branches/releasebranch_7_0/include/defs/vector.h
grass/branches/releasebranch_7_0/lib/vector/Vlib/build.c
grass/branches/releasebranch_7_0/lib/vector/Vlib/build_nat.c
Log:
Vlib: update Vect_attach_isle() and Vect_isle_find_area()
Modified: grass/branches/releasebranch_7_0/include/defs/vector.h
===================================================================
--- grass/branches/releasebranch_7_0/include/defs/vector.h 2015-01-15 21:34:22 UTC (rev 64207)
+++ grass/branches/releasebranch_7_0/include/defs/vector.h 2015-01-15 21:34:34 UTC (rev 64208)
@@ -576,8 +576,8 @@
int Vect_build_ogr(struct Map_info *, int);
int Vect_build_pg(struct Map_info *, int);
int Vect_build_line_area(struct Map_info *, int, int);
-int Vect_isle_find_area(struct Map_info *, int);
-int Vect_attach_isle(struct Map_info *, int);
+int Vect_isle_find_area(struct Map_info *, int, const struct bound_box *);
+int Vect_attach_isle(struct Map_info *, int, const struct bound_box *);
int Vect_attach_isles(struct Map_info *, const struct bound_box *);
int Vect_attach_centroids(struct Map_info *, const struct bound_box *);
Modified: grass/branches/releasebranch_7_0/lib/vector/Vlib/build.c
===================================================================
--- grass/branches/releasebranch_7_0/lib/vector/Vlib/build.c 2015-01-15 21:34:22 UTC (rev 64207)
+++ grass/branches/releasebranch_7_0/lib/vector/Vlib/build.c 2015-01-15 21:34:34 UTC (rev 64208)
@@ -168,11 +168,12 @@
\param Map vector map
\param isle isle id
+ \param box isle bbox
\return area id
\return 0 if not found
*/
-int Vect_isle_find_area(struct Map_info *Map, int isle)
+int Vect_isle_find_area(struct Map_info *Map, int isle, const struct bound_box *box)
{
int i, j, line, sel_area, area, poly;
const struct Plus_head *plus;
@@ -181,11 +182,13 @@
struct P_isle *Isle;
struct P_area *Area;
struct P_topo_b *topo;
- struct bound_box box, *abox;
+ struct bound_box *abox, nbox;
static struct boxlist *List = NULL;
static BOX_SIZE *size_list;
static int alloc_size_list = 0;
+ /* see also Vect_find_area() */
+
/* Note: We should check all isle points (at least) because if topology is not clean
* and two areas overlap, isle which is not completely within area may be attached,
* but it would take long time */
@@ -211,17 +214,15 @@
Node = plus->Node[topo->N1];
/* select areas by box */
- box.E = Node->x;
- box.W = Node->x;
- box.N = Node->y;
- box.S = Node->y;
- box.T = PORT_DOUBLE_MAX;
- box.B = -PORT_DOUBLE_MAX;
- Vect_select_areas_by_box(Map, &box, List);
+ nbox.E = Node->x;
+ nbox.W = Node->x;
+ nbox.N = Node->y;
+ nbox.S = Node->y;
+ nbox.T = PORT_DOUBLE_MAX;
+ nbox.B = -PORT_DOUBLE_MAX;
+ Vect_select_areas_by_box(Map, &nbox, List);
G_debug(3, "%d areas overlap island boundary point", List->n_values);
- Vect_get_isle_box(Map, isle, &box);
-
/* sort areas by bbox size
* get the smallest area that contains the isle
* using the bbox size is working because if 2 areas both contain
@@ -238,8 +239,8 @@
for (i = 0; i < List->n_values; i++) {
abox = &List->box[i];
- if (box.E > abox->E || box.W < abox->W || box.N > abox->N ||
- box.S < abox->S) {
+ 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;
}
@@ -289,8 +290,8 @@
abox = &size_list[i].box;
- if (box.E > abox->E || box.W < abox->W || box.N > abox->N ||
- box.S < abox->S) {
+ 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;
}
@@ -369,10 +370,11 @@
\param Map vector map
\param isle isle id
+ \param box isle bbox
\return 0
*/
-int Vect_attach_isle(struct Map_info *Map, int isle)
+int Vect_attach_isle(struct Map_info *Map, int isle, const struct bound_box *box)
{
int area;
struct P_isle *Isle;
@@ -385,7 +387,7 @@
plus = &(Map->plus);
- area = Vect_isle_find_area(Map, isle);
+ area = Vect_isle_find_area(Map, isle, box);
G_debug(3, "\tisle = %d -> area outside = %d", isle, area);
if (area > 0) {
Isle = plus->Isle[isle];
@@ -403,6 +405,8 @@
/*!
\brief (Re)Attach isles in given bounding box to areas
+
+ The warning for Vect_attach_centroids() applies here as well
\param Map vector map
\param box bounding box
@@ -421,7 +425,7 @@
plus = &(Map->plus);
if (!List)
- List = Vect_new_boxlist(FALSE);
+ List = Vect_new_boxlist(TRUE);
Vect_select_isles_by_box(Map, box, List);
G_debug(3, " number of isles to attach = %d", List->n_values);
@@ -449,7 +453,7 @@
}
if (area == 0)
- Vect_attach_isle(Map, isle);
+ Vect_attach_isle(Map, isle, &List->box[i]);
}
return 0;
}
Modified: grass/branches/releasebranch_7_0/lib/vector/Vlib/build_nat.c
===================================================================
--- grass/branches/releasebranch_7_0/lib/vector/Vlib/build_nat.c 2015-01-15 21:34:22 UTC (rev 64207)
+++ grass/branches/releasebranch_7_0/lib/vector/Vlib/build_nat.c 2015-01-15 21:34:34 UTC (rev 64208)
@@ -127,6 +127,7 @@
/* Build areas */
/* Go through all bundaries and try to build area for both sides */
G_important_message(_("Building areas..."));
+ G_percent(0, plus->n_lines, 1);
for (line = 1; line <= plus->n_lines; line++) {
G_percent(line, plus->n_lines, 1);
@@ -162,7 +163,8 @@
G_important_message(_("Attaching islands..."));
for (i = 1; i <= plus->n_isles; i++) {
G_percent(i, plus->n_isles, 1);
- Vect_attach_isle(Map, i);
+ Vect_get_isle_box(Map, i, &box);
+ Vect_attach_isle(Map, i, &box);
}
plus->built = GV_BUILD_ATTACH_ISLES;
}
More information about the grass-commit
mailing list