41 struct Map_info *Err,
double *removed_area)
51 struct Map_info *Err,
double *removed_area)
59 double size_removed = 0.0;
67 for (area = 1; area <= nareas; area++) {
68 int i, j, centroid, dissolve_neighbour;
99 for (i = 0; i < List->
n_values; i++) {
100 int line, left, right, neighbour;
102 line = List->
value[i];
113 G_debug(4,
" line = %d left = %d right = %d neighbour = %d", line,
114 left, right, neighbour);
122 dissolve_neighbour = 0;
124 for (i = 0; i < AList->
n_values; i++) {
128 neighbour1 = AList->
value[i];
129 G_debug(4,
" neighbour1 = %d", neighbour1);
131 for (j = 0; j < List->
n_values; j++) {
132 int line, left, right, neighbour2;
134 line = List->
value[j];
141 if (neighbour2 == neighbour1) {
148 dissolve_neighbour = neighbour1;
152 G_debug(3,
"dissolve_neighbour = %d", dissolve_neighbour);
156 for (i = 0; i < List->
n_values; i++) {
157 int line, left, right, neighbour;
159 line = List->
value[i];
166 G_debug(3,
" neighbour = %d", neighbour);
168 if (neighbour == dissolve_neighbour) {
174 for (i = 0; i < AList->
n_values; i++) {
177 line = AList->
value[i];
191 *removed_area = size_removed;
193 G_message(
_(
"%d areas of total size %g removed"), nremoved, size_removed);
204 struct Map_info *Err,
double *removed_area)
215 double size_removed = 0.0;
216 int dissolve_neighbour;
217 int line, left, right, neighbour;
229 for (area = 1; area <= nareas; area++) {
230 int i, j, centroid, ncentroid;
231 double length,
l, size;
233 int narea, same_atype = 0;
243 size_removed += size;
263 for (i = 0; i < List->
n_values; i++) {
265 line = List->
value[i];
276 G_debug(4,
" line = %d left = %d right = %d neighbour = %d", line,
277 left, right, neighbour);
288 if ((centroid != 0) + (ncentroid != 0) != 1)
300 dissolve_neighbour = 0;
302 for (i = 0; i < AList->
n_values; i++) {
306 neighbour1 = AList->
value[i];
307 G_debug(4,
" neighbour1 = %d", neighbour1);
311 if (neighbour1 > 0) {
314 if (neighbour1 < 0) {
319 if ((centroid != 0) + (ncentroid != 0) == 1)
323 for (j = 0; j < List->
n_values; j++) {
326 line = List->
value[j];
333 if (neighbour2 == neighbour1) {
340 dissolve_neighbour = neighbour1;
344 G_debug(3,
"dissolve_neighbour = %d", dissolve_neighbour);
346 if (dissolve_neighbour == 0) {
353 for (i = 0; i < List->
n_values; i++) {
355 line = List->
value[i];
362 G_debug(3,
" neighbour = %d", neighbour);
364 if (neighbour == dissolve_neighbour) {
376 for (i = 0; i < nisles; i++) {
382 for (i = 0; i < AList->
n_values; i++) {
385 line = AList->
value[i];
402 if (dissolve_neighbour > 0) {
404 G_debug(3,
"dissolve with neighbour area");
411 for (i = 0; i < nnisles; i++) {
425 for (i = 0; i < AList->
n_values; i++) {
429 line = AList->
value[i];
435 for (i = 0; i < BList->
n_values; i++) {
439 line = BList->
value[i];
442 if (topo->
left == 0 || topo->
right == 0) {
448 "has already been created");
449 outer_area = new_isle;
456 ctopo->
area = outer_area;
459 else if (new_isle < 0) {
472 _(
"Dissolve with neighbour area: corrupt topology"));
475 for (i = 0; i < NList->
n_values; i++) {
478 line = NList->
value[i];
484 if (topo->
left == 0 || topo->
right == 0) {
492 "has already been created");
493 outer_area = new_isle;
500 ctopo->
area = outer_area;
503 else if (new_isle < 0) {
514 _(
"Dissolve with neighbour area: corrupt topology"));
518 else if (dissolve_neighbour < 0) {
520 G_debug(3,
"dissolve with outer isle");
532 for (i = 0; i < AList->
n_values; i++) {
536 line = AList->
value[i];
542 for (i = 0; i < BList->
n_values; i++) {
545 line = BList->
value[i];
548 if (topo->
left == 0 || topo->
right == 0) {
564 _(
"Dissolve with outer isle: corrupt topology"));
568 for (i = 0; i < NList->
n_values; i++) {
571 line = NList->
value[i];
577 if (topo->
left == 0 || topo->
right == 0) {
593 _(
"Dissolve with outer isle: corrupt topology"));
597 if (dissolve_neighbour > 0 && outer_area <= 0) {
602 if (outer_area >= 0) {
603 for (i = 0; i < IList->
n_values; i++) {
618 *removed_area = size_removed;
620 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.