|
@@ -33,7 +33,7 @@ static struct line_pnts *Points;
|
|
|
int Vect_build_nat(struct Map_info *Map, int build)
|
|
|
{
|
|
|
struct Plus_head *plus;
|
|
|
- int i, s, type, line;
|
|
|
+ int i, s, type, line, counter;
|
|
|
off_t offset;
|
|
|
int side, area;
|
|
|
struct line_cats *Cats;
|
|
@@ -127,32 +127,35 @@ int Vect_build_nat(struct Map_info *Map, int build)
|
|
|
if (plus->built < GV_BUILD_AREAS) {
|
|
|
/* 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);
|
|
|
-
|
|
|
- /* build */
|
|
|
- if (plus->Line[line] == NULL) {
|
|
|
- continue;
|
|
|
- } /* dead line */
|
|
|
- Line = plus->Line[line];
|
|
|
- if (Line->type != GV_BOUNDARY) {
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- for (s = 0; s < 2; s++) {
|
|
|
- if (s == 0)
|
|
|
- side = GV_LEFT;
|
|
|
- else
|
|
|
- side = GV_RIGHT;
|
|
|
-
|
|
|
- G_debug(3, "Build area for line = %d, side = %d", line, side);
|
|
|
- Vect_build_line_area(Map, line, side);
|
|
|
+ if (plus->n_blines > 0) {
|
|
|
+ counter = 1;
|
|
|
+ G_important_message(_("Building areas..."));
|
|
|
+ G_percent(0, plus->n_blines, 1);
|
|
|
+ for (line = 1; line <= plus->n_lines; line++) {
|
|
|
+
|
|
|
+ /* build */
|
|
|
+ if (plus->Line[line] == NULL)
|
|
|
+ continue; /* dead */
|
|
|
+
|
|
|
+ Line = plus->Line[line];
|
|
|
+ if (Line->type != GV_BOUNDARY)
|
|
|
+ continue;
|
|
|
+
|
|
|
+ G_percent(counter++, plus->n_blines, 1);
|
|
|
+
|
|
|
+ for (s = 0; s < 2; s++) {
|
|
|
+ if (s == 0)
|
|
|
+ side = GV_LEFT;
|
|
|
+ else
|
|
|
+ side = GV_RIGHT;
|
|
|
+
|
|
|
+ G_debug(3, "Build area for line = %d, side = %d", line, side);
|
|
|
+ Vect_build_line_area(Map, line, side);
|
|
|
+ }
|
|
|
}
|
|
|
+ G_verbose_message(n_("One area built", "%d areas built", plus->n_areas), plus->n_areas);
|
|
|
+ G_verbose_message(n_("One isle built", "%d isles built", plus->n_isles), plus->n_isles);
|
|
|
}
|
|
|
- G_verbose_message(n_("One area built", "%d areas built", plus->n_areas), plus->n_areas);
|
|
|
- G_verbose_message(n_("One isle built", "%d isles built", plus->n_isles), plus->n_isles);
|
|
|
plus->built = GV_BUILD_AREAS;
|
|
|
}
|
|
|
|
|
@@ -161,11 +164,14 @@ int Vect_build_nat(struct Map_info *Map, int build)
|
|
|
|
|
|
/* Attach isles to areas */
|
|
|
if (plus->built < GV_BUILD_ATTACH_ISLES) {
|
|
|
- G_important_message(_("Attaching islands..."));
|
|
|
- for (i = 1; i <= plus->n_isles; i++) {
|
|
|
- G_percent(i, plus->n_isles, 1);
|
|
|
- Vect_get_isle_box(Map, i, &box);
|
|
|
- Vect_attach_isle(Map, i, &box);
|
|
|
+ if (plus->n_isles > 0) {
|
|
|
+ G_important_message(_("Attaching islands..."));
|
|
|
+ G_percent(0, plus->n_isles, 1);
|
|
|
+ for (i = 1; i <= plus->n_isles; i++) {
|
|
|
+ G_percent(i, plus->n_isles, 1);
|
|
|
+ Vect_get_isle_box(Map, i, &box);
|
|
|
+ Vect_attach_isle(Map, i, &box);
|
|
|
+ }
|
|
|
}
|
|
|
plus->built = GV_BUILD_ATTACH_ISLES;
|
|
|
}
|
|
@@ -175,37 +181,40 @@ int Vect_build_nat(struct Map_info *Map, int build)
|
|
|
|
|
|
/* Attach centroids to areas */
|
|
|
if (plus->built < GV_BUILD_CENTROIDS) {
|
|
|
- int nlines;
|
|
|
struct P_topo_c *topo;
|
|
|
|
|
|
- G_important_message(_("Attaching centroids..."));
|
|
|
+ if (plus->n_blines > 0) {
|
|
|
+ counter = 1;
|
|
|
+ G_important_message(_("Attaching centroids..."));
|
|
|
+ G_percent(0, plus->n_clines, 1);
|
|
|
|
|
|
- nlines = Vect_get_num_lines(Map);
|
|
|
- for (line = 1; line <= nlines; line++) {
|
|
|
- G_percent(line, nlines, 1);
|
|
|
+ for (line = 1; line <= plus->n_lines; line++) {
|
|
|
|
|
|
- Line = plus->Line[line];
|
|
|
- if (!Line)
|
|
|
- continue; /* Dead */
|
|
|
+ Line = plus->Line[line];
|
|
|
+ if (!Line)
|
|
|
+ continue; /* dead */
|
|
|
|
|
|
- if (Line->type != GV_CENTROID)
|
|
|
- continue;
|
|
|
+ if (Line->type != GV_CENTROID)
|
|
|
+ continue;
|
|
|
|
|
|
- Vect_read_line(Map, Points, NULL, line);
|
|
|
- area = Vect_find_area(Map, Points->x[0], Points->y[0]);
|
|
|
+ G_percent(counter++, plus->n_clines, 1);
|
|
|
|
|
|
- if (area > 0) {
|
|
|
- G_debug(3, "Centroid (line=%d) in area %d", line, area);
|
|
|
+ Vect_read_line(Map, Points, NULL, line);
|
|
|
+ area = Vect_find_area(Map, Points->x[0], Points->y[0]);
|
|
|
|
|
|
- Area = plus->Area[area];
|
|
|
- topo = (struct P_topo_c *)Line->topo;
|
|
|
+ if (area > 0) {
|
|
|
+ G_debug(3, "Centroid (line=%d) in area %d", line, area);
|
|
|
|
|
|
- if (Area->centroid == 0) { /* first */
|
|
|
- Area->centroid = line;
|
|
|
- topo->area = area;
|
|
|
- }
|
|
|
- else { /* duplicate */
|
|
|
- topo->area = -area;
|
|
|
+ Area = plus->Area[area];
|
|
|
+ topo = (struct P_topo_c *)Line->topo;
|
|
|
+
|
|
|
+ if (Area->centroid == 0) { /* first */
|
|
|
+ Area->centroid = line;
|
|
|
+ topo->area = area;
|
|
|
+ }
|
|
|
+ else { /* duplicate */
|
|
|
+ topo->area = -area;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -213,6 +222,8 @@ int Vect_build_nat(struct Map_info *Map, int build)
|
|
|
}
|
|
|
|
|
|
/* Add areas to category index */
|
|
|
+ /* add message and G_percent() ?
|
|
|
+ * it seems fast enough, no message / precent needed */
|
|
|
for (i = 1; i <= plus->n_areas; i++) {
|
|
|
int c;
|
|
|
|