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);
201 struct Map_info *Err,
double *removed_area)
212 double size_removed = 0.0;
213 int dissolve_neighbour;
214 int line, left, right, neighbour;
226 for (area = 1; area <= nareas; area++) {
227 int i, j, centroid, ncentroid;
228 double length,
l, size;
230 int narea, same_atype = 0;
240 size_removed += size;
260 for (i = 0; i < List->
n_values; i++) {
262 line = List->
value[i];
273 G_debug(4,
" line = %d left = %d right = %d neighbour = %d", line,
274 left, right, neighbour);
285 if ((centroid != 0) + (ncentroid != 0) != 1)
297 dissolve_neighbour = 0;
299 for (i = 0; i < AList->
n_values; i++) {
303 neighbour1 = AList->
value[i];
304 G_debug(4,
" neighbour1 = %d", neighbour1);
308 if (neighbour1 > 0) {
311 if (neighbour1 < 0) {
316 if ((centroid != 0) + (ncentroid != 0) == 1)
320 for (j = 0; j < List->
n_values; j++) {
323 line = List->
value[j];
330 if (neighbour2 == neighbour1) {
337 dissolve_neighbour = neighbour1;
341 G_debug(3,
"dissolve_neighbour = %d", dissolve_neighbour);
343 if (dissolve_neighbour == 0) {
350 for (i = 0; i < List->
n_values; i++) {
352 line = List->
value[i];
359 G_debug(3,
" neighbour = %d", neighbour);
361 if (neighbour == dissolve_neighbour) {
373 for (i = 0; i < nisles; i++) {
379 for (i = 0; i < AList->
n_values; i++) {
382 line = AList->
value[i];
399 if (dissolve_neighbour > 0) {
401 G_debug(3,
"dissolve with neighbour area");
408 for (i = 0; i < nnisles; i++) {
422 for (i = 0; i < AList->
n_values; i++) {
426 line = AList->
value[i];
432 for (i = 0; i < BList->
n_values; i++) {
436 line = BList->
value[i];
439 if (topo->
left == 0 || topo->
right == 0) {
445 "has already been created");
446 outer_area = new_isle;
453 ctopo->
area = outer_area;
456 else if (new_isle < 0) {
469 _(
"Dissolve with neighbour area: corrupt topology"));
472 for (i = 0; i < NList->
n_values; i++) {
475 line = NList->
value[i];
481 if (topo->
left == 0 || topo->
right == 0) {
489 "has already been created");
490 outer_area = new_isle;
497 ctopo->
area = outer_area;
500 else if (new_isle < 0) {
511 _(
"Dissolve with neighbour area: corrupt topology"));
515 else if (dissolve_neighbour < 0) {
517 G_debug(3,
"dissolve with outer isle");
529 for (i = 0; i < AList->
n_values; i++) {
533 line = AList->
value[i];
539 for (i = 0; i < BList->
n_values; i++) {
542 line = BList->
value[i];
545 if (topo->
left == 0 || topo->
right == 0) {
561 _(
"Dissolve with outer isle: corrupt topology"));
565 for (i = 0; i < NList->
n_values; i++) {
568 line = NList->
value[i];
574 if (topo->
left == 0 || topo->
right == 0) {
590 _(
"Dissolve with outer isle: corrupt topology"));
594 if (dissolve_neighbour > 0 && outer_area <= 0) {
599 if (outer_area >= 0) {
600 for (i = 0; i < IList->
n_values; i++) {
615 *removed_area = size_removed;
617 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.