26#include "local_proto.h"
31static void V2__delete_area_cats_from_cidx_nat(
struct Map_info *,
int);
32static void V2__add_area_cats_to_cidx_nat(
struct Map_info *,
int);
49 return V1__write_line_nat(
Map, -1, type, points, cats);
73 G_debug(3,
"V2_write_line_nat(): type=%d", type);
75 if (!(
Map->plus.update_cidx)) {
113 G_debug(3,
"V1_rewrite_line_nat(): offset = %" PRId64, offset);
132 return V1__write_line_nat(
Map, offset, type, points, cats);
139 return V1__write_line_nat(
Map, -1, type, points, cats);
179 if (plus->
uplist.do_uplist) {
188 G_warning(
_(
"Attempt to access feature with invalid id (%d)"),
232 offset = V1__write_line_nat(
Map, offset, type, points, cats);
253 G_debug(3,
"V1_delete_line_nat(): offset = %" PRId64, offset);
256 dig_fp = &(
Map->dig_fp);
298 G_debug(3,
"V2_delete_line_nat(): line = %d", (
int)line);
304 G_warning(
_(
"Attempt to access feature with invalid id (%d)"),
309 Line =
Map->plus.Line[line];
311 G_warning(
_(
"Attempt to access dead feature %d"), (
int)line);
356 "V1_restore_line_nat(): offset = %" PRId64
357 ", line (not used) = %" PRId64,
361 dig_fp = &(
Map->dig_fp);
420 G_warning(
_(
"Attempt to access alive feature %d"), (
int)line);
474 dig_fp = &(
Map->dig_fp);
486 G_debug(3,
"V1__rewrite_line_nat(): offset = %" PRId64, offset);
514 if (
Map->head.coor_version.minor == 1) {
525 if (
Map->head.coor_version.minor == 1) {
530 for (i = 0; i < cats->
n_cats; i++) {
555 if (
Map->head.with_z) {
575void V2__delete_area_cats_from_cidx_nat(
struct Map_info *
Map,
int area)
581 G_debug(3,
"V2__delete_area_cats_from_cidx_nat(), area = %d", area);
583 Area =
Map->plus.Area[area];
586 "delete_area_cats_from_cidx()", area);
596 for (i = 0; i <
Cats->n_cats; i++) {
611void V2__add_area_cats_to_cidx_nat(
struct Map_info *
Map,
int area)
617 G_debug(3,
"V2__add_area_cats_to_cidx_nat(), area = %d", area);
619 Area =
Map->plus.Area[area];
622 "add_area_cats_to_cidx():", area);
632 for (i = 0; i <
Cats->n_cats; i++) {
672 G_warning(
_(
"Attempt to access feature with invalid id (%d)"), line);
676 Line =
Map->plus.Line[line];
678 G_warning(
_(
"Attempt to access dead feature %d"), line);
684 for (i = 0; i < cats->
n_cats; i++) {
703 if (next_line != 0 &&
abs(next_line) != line) {
710 if (next_line != 0 &&
abs(next_line) != line) {
718 if (next_line != 0 &&
abs(next_line) != line) {
726 if (next_line != 0 &&
abs(next_line) != line) {
735 if (topo->
left > 0) {
745 V2__delete_area_cats_from_cidx_nat(
Map, topo->
left);
749 else if (topo->
left < 0) {
752 if (topo->
right > 0) {
762 V2__delete_area_cats_from_cidx_nat(
Map, topo->
right);
766 else if (topo->
right < 0) {
777 if (topo->
area > 0) {
778 G_debug(3,
"Remove centroid %d from area %d", (
int)line,
781 V2__delete_area_cats_from_cidx_nat(
Map, topo->
area);
783 Area =
Map->plus.Area[topo->
area];
792 if (0 !=
dig_del_line(plus, line, points->
x[0], points->
y[0], points->
z[0]))
851 if (plus->
uplist.do_uplist) {
852 G_debug(3,
"updated lines : %d , updated nodes : %d",
912 int first, s, n, i, line;
925 "V2__add_line_to_topo_nat(): offset = %" PRId64
926 " (build level = %d)",
927 offset, plus->
built);
938 G_debug(3,
" line added to topo with id = %d", line);
940 Line = plus->
Line[line];
954 for (s = 0; s < 2; s++) {
955 node = (s == 0 ? topo->
N1 : topo->
N2);
956 G_debug(3,
" delete neighbour areas/isles: %s node = %d",
957 (s == 0 ?
"first" :
"second"), node);
958 Node = plus->
Node[node];
960 for (i = 0; i < Node->
n_lines; i++) {
966 G_debug(3,
" number of boundaries at node = %d", n);
979 if (next_line != 0) {
991 G_debug(3,
" next_line = %d area = %d", next_line, area);
1002 V2__delete_area_cats_from_cidx_nat(
Map, area);
1009 else if (area < 0) {
1023 for (s = 0; s < 2; s++) {
1036 else if (area < 0) {
1062 for (s = 0; s < 2; s++) {
1079 Line = plus->
Line[line];
1082 G_debug(3,
" first centroid -> attach to area");
1090 G_debug(3,
" duplicate centroid -> do not attach to area");
1099 for (i = 0; i < cats->
n_cats; i++) {
1105 if (plus->
uplist.do_uplist) {
1106 G_debug(3,
"updated lines : %d , updated nodes : %d",
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
void G_warning(const char *,...) __attribute__((format(printf
int G_debug(int, const char *,...) __attribute__((format(printf
int V2_read_line_nat(struct Map_info *, struct line_pnts *, struct line_cats *, int)
Read vector feature on topological level (level 2) - native format - internal use only.
int Vect_attach_centroids(struct Map_info *, const struct bound_box *)
(Re)Attach centroids in given bounding box to areas
int Vect_build_line_area(struct Map_info *, int, int)
Build area on given side of line (GV_LEFT or GV_RIGHT)
int Vect_box_extend(struct bound_box *, const struct bound_box *)
Extend box A by box B.
int Vect_read_line(struct Map_info *, struct line_pnts *, struct line_cats *, int)
Read vector feature (topological level required)
int Vect_get_area_box(struct Map_info *, int, struct bound_box *)
Get bounding box of area.
struct line_cats * Vect_new_cats_struct(void)
Creates and initializes line_cats structure.
int Vect_get_isle_box(struct Map_info *, int, struct bound_box *)
Get bounding box of isle.
int Vect_attach_isles(struct Map_info *, const struct bound_box *)
(Re)Attach isles in given bounding box to areas
int V1_read_line_nat(struct Map_info *, struct line_pnts *, struct line_cats *, off_t)
Read vector feature on non-topological level (level 1) - native format - internal use only.
struct line_pnts * Vect_new_line_struct(void)
Creates and initializes a line_pnts structure.
int Vect_find_area(struct Map_info *, double, double)
Find the nearest area.
int Vect_box_copy(struct bound_box *, const struct bound_box *)
Copy box B to box A.
#define GV_BUILD_ATTACH_ISLES
Topology levels - attach islands to areas.
#define GV_BUILD_BASE
Topology levels - basic level (without areas and isles)
#define GV_BUILD_AREAS
Topology levels - build areas.
#define GV_BUILD_CENTROIDS
Topology levels - assign centroids to areas.
#define GV_LEFT
Boundary side indicator left/right.
int dig_restore_line(struct Plus_head *, int, int, const struct line_pnts *, const struct bound_box *, off_t)
Restore line in Plus_head structure.
int dig_angle_next_line(struct Plus_head *, plus_t, int, int, float *)
Find line number of next angle to follow a line.
int dig__fwrite_port_C(const char *, size_t, struct gvfile *)
Write chars to the Portable Vector Format.
int dig_del_line(struct Plus_head *, int, double, double, double)
Delete line from Plus_head structure.
int dig__fwrite_port_I(const int *, size_t, struct gvfile *)
Write integers to the Portable Vector Format.
off_t dig_ftell(struct gvfile *file)
Get struct gvfile position.
int dig_del_area(struct Plus_head *, int)
Delete area from Plus_head structure.
int dig_set_cur_port(struct Port_info *)
Set current Port_info structure.
int dig__fwrite_port_D(const double *, size_t, struct gvfile *)
Write doubles to the Portable Vector Format.
int dig__fread_port_C(char *, size_t, struct gvfile *)
Read chars from the Portable Vector Format.
int dig_del_isle(struct Plus_head *, int)
Delete island from Plus_head structure.
int dig_cidx_del_cat(struct Plus_head *, int, int, int, int)
int dig_fseek(struct gvfile *file, off_t offset, int whence)
Set struct gvfile position.
int dig_cidx_add_cat_sorted(struct Plus_head *, int, int, int, int)
int dig_fflush(struct gvfile *file)
Flush struct gvfile.
int dig_add_line(struct Plus_head *, int, const struct line_pnts *, const struct bound_box *, off_t)
Add new line to Plus_head structure.
int dig_line_box(const struct line_pnts *, struct bound_box *)
int dig__fwrite_port_S(const short *, size_t, struct gvfile *)
Write shorts to the Portable Vector Format.
int dig_type_to_store(int)
Convert type to store type.
plus_t centroid
Number of first centroid within area.
off_t offset
Offset in coor file for line.
void * topo
Topology info.
Topological feature - node.
plus_t n_lines
Number of attached lines (size of lines, angle)
plus_t * lines
List of connected lines.
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.
Basic topology-related info.
struct P_line ** Line
Array of vector geometries.
plus_t n_lines
Current number of lines.
struct P_area ** Area
Array of areas.
int cidx_up_to_date
Category index to be updated.
int update_cidx
Update category index if vector is modified.
struct Plus_head::@10 uplist
List of updated lines/nodes.
struct bound_box box
Bounding box of features.
struct P_node ** Node
Array of nodes.
int built
Highest level of topology currently available.
int * field
Array of layers (fields)
int * cat
Array of categories.
int n_cats
Number of categories attached to element.
Feature geometry info - coordinates.
double * y
Array of Y coordinates.
double * x
Array of X coordinates.
int n_points
Number of points.
double * z
Array of Z coordinates.
int V2__add_line_to_topo_nat(struct Map_info *Map, off_t offset, int type, const struct line_pnts *points, const struct line_cats *cats, int restore_line, int(*external_routine)(struct Map_info *, int))
Add feature (line) to topology (internal use only)
off_t V2_rewrite_line_nat(struct Map_info *Map, off_t line, int type, const struct line_pnts *points, const struct line_cats *cats)
Rewrites feature to 'coor' file at topological level (internal use only)
int V1_delete_line_nat(struct Map_info *Map, off_t offset)
Deletes feature at level 1 (internal use only)
int V2_restore_line_nat(struct Map_info *Map, off_t offset, off_t line)
Restores feature at topological level (internal use only)
off_t V2_write_line_nat(struct Map_info *Map, int type, const struct line_pnts *points, const struct line_cats *cats)
Writes feature to 'coor' file at topological level (internal use only)
off_t V1_write_line_nat(struct Map_info *Map, int type, const struct line_pnts *points, const struct line_cats *cats)
Writes feature to 'coor' file at level 1 (internal use only)
int V2__delete_line_from_topo_nat(struct Map_info *Map, int line, int type, const struct line_pnts *points, const struct line_cats *cats)
Delete feature from topology (internal use only)
int V2_delete_line_nat(struct Map_info *Map, off_t line)
Deletes feature at topological level (internal use only)
off_t V1_rewrite_line_nat(struct Map_info *Map, off_t offset, int type, const struct line_pnts *points, const struct line_cats *cats)
Rewrites feature to 'coor' file at level 1 (internal use only)
int V1_restore_line_nat(struct Map_info *Map, off_t offset, off_t line)
Restores feature at level 1 (internal use only)