42 struct Map_info *Err,
double *removed_area)
52 struct Map_info *Err,
double *removed_area)
60 double size_removed = 0.0;
68 for (area = 1; area <= nareas; area++) {
69 int i, j, centroid, dissolve_neighbour;
100 for (i = 0; i < List->
n_values; i++) {
101 int line, left, right, neighbour;
103 line = List->
value[i];
114 G_debug(4,
" line = %d left = %d right = %d neighbour = %d", line,
115 left, right, neighbour);
123 dissolve_neighbour = 0;
125 for (i = 0; i < AList->
n_values; i++) {
129 neighbour1 = AList->
value[i];
130 G_debug(4,
" neighbour1 = %d", neighbour1);
132 for (j = 0; j < List->
n_values; j++) {
133 int line, left, right, neighbour2;
135 line = List->
value[j];
142 if (neighbour2 == neighbour1) {
149 dissolve_neighbour = neighbour1;
153 G_debug(3,
"dissolve_neighbour = %d", dissolve_neighbour);
157 for (i = 0; i < List->
n_values; i++) {
158 int line, left, right, neighbour;
160 line = List->
value[i];
167 G_debug(3,
" neighbour = %d", neighbour);
169 if (neighbour == dissolve_neighbour) {
175 for (i = 0; i < AList->
n_values; i++) {
178 line = AList->
value[i];
192 *removed_area = size_removed;
194 G_message(
_(
"%d areas of total size %g removed"), nremoved, size_removed);
205 struct Map_info *Err,
double *removed_area)
216 double size_removed = 0.0;
217 int dissolve_neighbour;
218 int line, left, right, neighbour;
230 for (area = 1; area <= nareas; area++) {
231 int i, j, centroid, ncentroid;
232 double length,
l, size;
234 int narea, same_atype = 0;
244 size_removed += size;
264 for (i = 0; i < List->
n_values; i++) {
266 line = List->
value[i];
277 G_debug(4,
" line = %d left = %d right = %d neighbour = %d", line,
278 left, right, neighbour);
289 if ((centroid != 0) + (ncentroid != 0) != 1)
301 dissolve_neighbour = 0;
303 for (i = 0; i < AList->
n_values; i++) {
307 neighbour1 = AList->
value[i];
308 G_debug(4,
" neighbour1 = %d", neighbour1);
312 if (neighbour1 > 0) {
315 if (neighbour1 < 0) {
320 if ((centroid != 0) + (ncentroid != 0) == 1)
324 for (j = 0; j < List->
n_values; j++) {
327 line = List->
value[j];
334 if (neighbour2 == neighbour1) {
341 dissolve_neighbour = neighbour1;
345 G_debug(3,
"dissolve_neighbour = %d", dissolve_neighbour);
347 if (dissolve_neighbour == 0) {
354 for (i = 0; i < List->
n_values; i++) {
356 line = List->
value[i];
363 G_debug(3,
" neighbour = %d", neighbour);
365 if (neighbour == dissolve_neighbour) {
377 for (i = 0; i < nisles; i++) {
383 for (i = 0; i < AList->
n_values; i++) {
386 line = AList->
value[i];
403 if (dissolve_neighbour > 0) {
405 G_debug(3,
"dissolve with neighbour area");
412 for (i = 0; i < nnisles; i++) {
426 for (i = 0; i < AList->
n_values; i++) {
430 line = AList->
value[i];
436 for (i = 0; i < BList->
n_values; i++) {
440 line = BList->
value[i];
443 if (topo->
left == 0 || topo->
right == 0) {
449 "has already been created");
450 outer_area = new_isle;
457 ctopo->
area = outer_area;
460 else if (new_isle < 0) {
473 _(
"Dissolve with neighbour area: corrupt topology"));
476 for (i = 0; i < NList->
n_values; i++) {
479 line = NList->
value[i];
485 if (topo->
left == 0 || topo->
right == 0) {
493 "has already been created");
494 outer_area = new_isle;
501 ctopo->
area = outer_area;
504 else if (new_isle < 0) {
515 _(
"Dissolve with neighbour area: corrupt topology"));
519 else if (dissolve_neighbour < 0) {
521 G_debug(3,
"dissolve with outer isle");
533 for (i = 0; i < AList->
n_values; i++) {
537 line = AList->
value[i];
543 for (i = 0; i < BList->
n_values; i++) {
546 line = BList->
value[i];
549 if (topo->
left == 0 || topo->
right == 0) {
565 _(
"Dissolve with outer isle: corrupt topology"));
569 for (i = 0; i < NList->
n_values; i++) {
572 line = NList->
value[i];
578 if (topo->
left == 0 || topo->
right == 0) {
594 _(
"Dissolve with outer isle: corrupt topology"));
598 if (dissolve_neighbour > 0 && outer_area <= 0) {
603 if (outer_area >= 0) {
604 for (i = 0; i < IList->
n_values; i++) {
619 *removed_area = size_removed;
621 G_message(
_(
"%d areas of total size %g removed"), nremoved, size_removed);
void G_percent(long, long, int)
Print percent complete messages.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
void G_message(const char *,...) __attribute__((format(printf
int G_debug(int, const char *,...) __attribute__((format(printf
void Vect_destroy_line_struct(struct line_pnts *)
Frees all memory associated with a line_pnts structure, including the structure itself.
double Vect_line_length(const struct line_pnts *)
Calculate line length, 3D-length in case of 3D vector line.
plus_t Vect_get_num_areas(struct Map_info *)
Get number of areas in vector map.
int Vect_area_alive(struct Map_info *, int)
Check if area is alive or dead (topological level required)
int Vect_build_line_area(struct Map_info *, int, int)
Build area on given side of line (GV_LEFT or GV_RIGHT)
int Vect_get_area_boundaries(struct Map_info *, int, struct ilist *)
Creates list of boundaries for given area.
void Vect_destroy_list(struct ilist *)
Frees all memory associated with a struct ilist, including the struct itself.
void Vect_destroy_cats_struct(struct line_cats *)
Frees all memory associated with line_cats structure, including the struct itself.
int Vect_list_append(struct ilist *, int)
Append new item to the end of list if not yet present.
int Vect_get_area_isle(struct Map_info *, int, int)
Returns isle id for area.
int Vect_read_line(struct Map_info *, struct line_pnts *, struct line_cats *, int)
Read vector feature (topological level required)
struct ilist * Vect_new_list(void)
Creates and initializes a struct ilist.
int Vect_get_area_num_isles(struct Map_info *, int)
Returns number of isles for given area.
int Vect_line_alive(struct Map_info *, int)
Check if feature is alive or dead (topological level required)
int Vect_get_isle_boundaries(struct Map_info *, int, struct ilist *)
Creates list of boundaries for given isle.
int Vect_delete_line(struct Map_info *, off_t)
Delete existing feature (topological level required)
off_t Vect_write_line(struct Map_info *, int, const struct line_pnts *, const struct line_cats *)
Writes a new feature.
struct line_pnts * Vect_new_line_struct(void)
Creates and initializes a line_pnts structure.
int Vect_get_area_centroid(struct Map_info *, int)
Returns centroid id for given area.
double Vect_get_area_area(struct Map_info *, int)
Returns area of area without areas of isles.
struct line_cats * Vect_new_cats_struct(void)
Creates and initializes line_cats structure.
int V1_delete_line_nat(struct Map_info *, off_t)
Deletes feature at level 1 (internal use only)
int Vect_get_line_areas(struct Map_info *, int, int *, int *)
Get area id on the left and right side of the boundary.
int Vect_reset_list(struct ilist *)
Reset ilist structure.
int Vect_get_isle_area(struct Map_info *, int)
Returns area id for isle.
#define GV_LEFT
Boundary side indicator left/right.
#define GV_FORMAT_NATIVE
Geometry data formats supported by lib Don't change GV_FORMAT_* values, this order is hardcoded in li...
int dig_area_add_isle(struct Plus_head *, int, int)
Add isle to area if does not exist yet.
int dig_del_line(struct Plus_head *, int, double, double, double)
Delete line from Plus_head structure.
int dig_del_area(struct Plus_head *, int)
Delete area from Plus_head structure.
int dig_del_isle(struct Plus_head *, int)
Delete island from Plus_head structure.
int Vect_remove_small_areas_nat(struct Map_info *, double, struct Map_info *, double *)
int Vect_remove_small_areas_ext(struct Map_info *, double, struct Map_info *, double *)
int Vect_remove_small_areas(struct Map_info *Map, double thresh, struct Map_info *Err, double *removed_area)
Remove small areas from the map map.
int format
Map format (native, ogr, postgis)
struct Plus_head plus
Plus info (topology, version, ...)
plus_t centroid
Number of first centroid within area.
plus_t area
Area it exists w/in, if any.
off_t offset
Offset in coor file for line.
void * topo
Topology info.
Topological feature - node.
double z
Z coordinate (used only for 3D data)
plus_t left
Area number to the left, negative for isle.
plus_t right
Area number to the right, negative for isle.
plus_t area
Area number, negative for duplicate centroid.
struct P_line ** Line
Array of vector geometries.
struct P_area ** Area
Array of areas.
struct P_isle ** Isle
Array of isles.
struct P_node ** Node
Array of nodes.
int n_values
Number of values in the list.
int * value
Array of values.
Feature geometry info - coordinates.