|
@@ -365,6 +365,10 @@ int Vect_attach_centroids(struct Map_info *Map, BOUND_BOX * box)
|
|
|
* to check if original area exist, unregister centroid from previous area.
|
|
|
* To simplify code, this is implemented so that centroid is always firs unregistered
|
|
|
* and if new area is found, it is registered again.
|
|
|
+ *
|
|
|
+ * This problem can be avoided altogether if properly attached centroids
|
|
|
+ * are skipped
|
|
|
+ * MM 2009
|
|
|
*/
|
|
|
|
|
|
Vect_select_lines_by_box(Map, box, GV_CENTROID, List);
|
|
@@ -376,14 +380,15 @@ int Vect_attach_centroids(struct Map_info *Map, BOUND_BOX * box)
|
|
|
Line = plus->Line[centr];
|
|
|
Node = plus->Node[Line->N1];
|
|
|
|
|
|
- /* Unregister centroid */
|
|
|
+ /* only attach unregistered and duplicate centroids because
|
|
|
+ * 1) all properly attached centroids are properly attached, really! Don't touch.
|
|
|
+ * 2) Vect_find_area() below does not always return the correct area
|
|
|
+ * 3) it's faster
|
|
|
+ */
|
|
|
+ if (Line->left > 0)
|
|
|
+ continue;
|
|
|
+
|
|
|
orig_area = Line->left;
|
|
|
- if (orig_area > 0) {
|
|
|
- if (plus->Area[orig_area] != NULL) {
|
|
|
- plus->Area[orig_area]->centroid = 0;
|
|
|
- }
|
|
|
- }
|
|
|
- Line->left = 0;
|
|
|
|
|
|
sel_area = Vect_find_area(Map, Node->x, Node->y);
|
|
|
G_debug(3, " centroid %d is in area %d", centr, sel_area);
|
|
@@ -396,7 +401,7 @@ int Vect_attach_centroids(struct Map_info *Map, BOUND_BOX * box)
|
|
|
}
|
|
|
else if (Area->centroid != centr) { /* duplicate centroid */
|
|
|
/* Note: it cannot happen that Area->centroid == centr, because the centroid
|
|
|
- * was previously unregistered */
|
|
|
+ * was not registered or a duplicate */
|
|
|
G_debug(3, " duplicate centroid -> do not attach to area");
|
|
|
Line->left = -sel_area;
|
|
|
}
|