42 struct Map_info *Err,
double *removed_area)
53 struct Map_info *Err,
double *removed_area)
61 double size_removed = 0.0;
69 for (area = 1; area <= nareas; area++) {
70 int i, j, centroid, dissolve_neighbour;
101 for (i = 0; i < List->
n_values; i++) {
102 int line, left, right, neighbour;
104 line = List->
value[i];
115 G_debug(4,
" line = %d left = %d right = %d neighbour = %d",
116 line, 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,
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",
277 line, left, right, neighbour);
288 if ((centroid != 0) + (ncentroid != 0) != 1)
299 dissolve_neighbour = 0;
301 for (i = 0; i < AList->
n_values; i++) {
305 neighbour1 = AList->
value[i];
306 G_debug(4,
" neighbour1 = %d", neighbour1);
310 if (neighbour1 > 0) {
313 if (neighbour1 < 0) {
318 if ((centroid != 0) + (ncentroid != 0) == 1)
322 for (j = 0; j < List->
n_values; j++) {
325 line = List->
value[j];
332 if (neighbour2 == neighbour1) {
339 dissolve_neighbour = neighbour1;
343 G_debug(3,
"dissolve_neighbour = %d", dissolve_neighbour);
345 if (dissolve_neighbour == 0) {
352 for (i = 0; i < List->
n_values; i++) {
354 line = List->
value[i];
361 G_debug(3,
" neighbour = %d", neighbour);
363 if (neighbour == dissolve_neighbour) {
374 for (i = 0; i < nisles; i++) {
380 for (i = 0; i < AList->
n_values; i++) {
383 line = AList->
value[i];
400 if (dissolve_neighbour > 0) {
402 G_debug(3,
"dissolve with neighbour area");
408 for (i = 0; i < nnisles; i++) {
421 for (i = 0; i < AList->
n_values; i++) {
425 line = AList->
value[i];
431 for (i = 0; i < BList->
n_values; i++) {
435 line = BList->
value[i];
438 if (topo->
left == 0 || topo->
right == 0) {
442 G_fatal_error(
"dissolve_neighbour > 0, new area has already been created");
443 outer_area = new_isle;
449 ctopo->
area = outer_area;
452 else if (new_isle < 0) {
458 G_fatal_error(
_(
"dissolve_neighbour > 0, failed to build new area"));
463 G_fatal_error(
_(
"Dissolve with neighbour area: corrupt topology"));
466 for (i = 0; i < NList->
n_values; i++) {
469 line = NList->
value[i];
475 if (topo->
left == 0 || topo->
right == 0) {
481 G_fatal_error(
"dissolve_neighbour > 0, new area has already been created");
482 outer_area = new_isle;
488 ctopo->
area = outer_area;
491 else if (new_isle < 0) {
501 G_fatal_error(
_(
"Dissolve with neighbour area: corrupt topology"));
505 else if (dissolve_neighbour < 0) {
507 G_debug(3,
"dissolve with outer isle");
519 for (i = 0; i < AList->
n_values; i++) {
523 line = AList->
value[i];
529 for (i = 0; i < BList->
n_values; i++) {
532 line = BList->
value[i];
535 if (topo->
left == 0 || topo->
right == 0) {
553 for (i = 0; i < NList->
n_values; i++) {
556 line = NList->
value[i];
562 if (topo->
left == 0 || topo->
right == 0) {
580 if (dissolve_neighbour > 0 && outer_area <= 0) {
585 if (outer_area >= 0) {
586 for (i = 0; i < IList->
n_values; i++) {
600 *removed_area = size_removed;
602 G_message(
_(
"%d areas of total size %g removed"), nremoved,
int Vect_build_line_area(struct Map_info *, int, int)
Build area on given side of line (GV_LEFT or GV_RIGHT)
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
plus_t area
Area number, negative for duplicate centroid.
#define GV_LEFT
Boundary side indicator left/right.
int Vect_get_area_isle(const struct Map_info *, int, int)
Returns isle id for area.
int Vect_reset_list(struct ilist *)
Reset ilist structure.
off_t offset
Offset in coor file for line.
#define GV_FORMAT_NATIVE
Geometry data formats supported by lib Don't change GV_FORMAT_* values, this order is hardcoded in li...
struct P_line ** Line
Array of vector geometries.
int Vect_get_area_centroid(const struct Map_info *, int)
Returns centroid id for given area.
plus_t right
Area number to the right, negative for isle.
struct P_area ** Area
Array of areas.
struct P_node ** Node
Array of nodes.
int dig_area_add_isle(struct Plus_head *, int, int)
Add isle to area if does not exist yet.
int n_values
Number of values in the list.
plus_t left
Area number to the left, negative for isle.
int Vect_get_area_num_isles(const struct Map_info *, int)
Returns number of isles for given area.
struct P_isle ** Isle
Array of isles.
plus_t centroid
Number of first centroid within area.
double Vect_line_length(const struct line_pnts *)
Calculate line length, 3D-length in case of 3D vector line.
int dig_del_line(struct Plus_head *, int, double, double, double)
Delete line from Plus_head structure.
void G_message(const char *,...) __attribute__((format(printf
double z
Z coordinate (used only for 3D data)
Feature geometry info - coordinates.
void Vect_destroy_list(struct ilist *)
Frees all memory associated with a struct ilist, including the struct itself.
struct line_pnts * Vect_new_line_struct(void)
Creates and initializes a line_pnts structure.
void Vect_destroy_cats_struct(struct line_cats *)
Frees all memory associated with line_cats structure, including the struct itself.
void * topo
Topology info.
int dig_del_isle(struct Plus_head *, int)
Delete island from Plus_head structure.
off_t Vect_write_line(struct Map_info *, int, const struct line_pnts *, const struct line_cats *)
Writes a new feature.
struct Plus_head plus
Plus info (topology, version, ...)
int Vect_get_area_boundaries(const struct Map_info *, int, struct ilist *)
Creates list of boundaries for given area.
plus_t Vect_get_num_areas(const struct Map_info *)
Get number of areas in vector map.
int Vect_get_isle_boundaries(const struct Map_info *, int, struct ilist *)
Creates list of boundaries for given isle.
int Vect_area_alive(const struct Map_info *, int)
Check if area is alive or dead (topological level required)
Topological feature - node.
int Vect_get_isle_area(const struct Map_info *, int)
Returns area id for isle.
int Vect_remove_small_areas_ext(struct Map_info *, double, struct Map_info *, double *)
void G_percent(long, long, int)
Print percent complete messages.
int V1_delete_line_nat(struct Map_info *, off_t)
Deletes feature at level 1 (internal use only)
struct ilist * Vect_new_list(void)
Creates and initializes a struct ilist.
int Vect_delete_line(struct Map_info *, off_t)
Delete existing feature (topological level required)
struct line_cats * Vect_new_cats_struct(void)
Creates and initializes line_cats structure.
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 Vect_list_append(struct ilist *, int)
Append new item to the end of list if not yet present.
int Vect_line_alive(const struct Map_info *, int)
Check if feature is alive or dead (topological level required)
int format
Map format (native, ogr, postgis)
int * value
Array of values.
int Vect_remove_small_areas_nat(struct Map_info *, double, struct Map_info *, double *)
void Vect_destroy_line_struct(struct line_pnts *)
Frees all memory associated with a line_pnts structure, including the structure itself.
int dig_del_area(struct Plus_head *, int)
Delete area from Plus_head structure.
double Vect_get_area_area(const struct Map_info *, int)
Returns area of area without areas of isles.
int Vect_read_line(const struct Map_info *, struct line_pnts *, struct line_cats *, int)
Read vector feature (topological level required)
plus_t area
Area it exists w/in, if any.
int G_debug(int, const char *,...) __attribute__((format(printf
int Vect_get_line_areas(const struct Map_info *, int, int *, int *)
Get area id on the left and right side of the boundary.