24#include "local_proto.h"
29static void V2__delete_area_cats_from_cidx_nat(
struct Map_info *,
int);
30static void V2__add_area_cats_to_cidx_nat(
struct Map_info *,
int);
47 return V1__write_line_nat(
Map, -1, type, points, cats);
71 G_debug(3,
"V2_write_line_nat(): type=%d", type);
73 if (!(
Map->plus.update_cidx)) {
111 G_debug(3,
"V1_rewrite_line_nat(): offset = %" PRId64, offset);
130 return V1__write_line_nat(
Map, offset, type, points, cats);
137 return V1__write_line_nat(
Map, -1, type, points, cats);
177 if (plus->
uplist.do_uplist) {
186 G_warning(
_(
"Attempt to access feature with invalid id (%d)"),
230 offset = V1__write_line_nat(
Map, offset, type, points, cats);
251 G_debug(3,
"V1_delete_line_nat(): offset = %" PRId64, offset);
254 dig_fp = &(
Map->dig_fp);
296 G_debug(3,
"V2_delete_line_nat(): line = %d", (
int)line);
302 G_warning(
_(
"Attempt to access feature with invalid id (%d)"),
307 Line =
Map->plus.Line[line];
309 G_warning(
_(
"Attempt to access dead feature %d"), (
int)line);
354 "V1_restore_line_nat(): offset = %" PRId64
355 ", line (not used) = %" PRId64,
359 dig_fp = &(
Map->dig_fp);
418 G_warning(
_(
"Attempt to access alive feature %d"), (
int)line);
472 dig_fp = &(
Map->dig_fp);
484 G_debug(3,
"V1__rewrite_line_nat(): offset = %" PRId64, offset);
512 if (
Map->head.coor_version.minor == 1) {
523 if (
Map->head.coor_version.minor == 1) {
528 for (i = 0; i < cats->
n_cats; i++) {
553 if (
Map->head.with_z) {
573void V2__delete_area_cats_from_cidx_nat(
struct Map_info *
Map,
int area)
579 G_debug(3,
"V2__delete_area_cats_from_cidx_nat(), area = %d", area);
581 Area =
Map->plus.Area[area];
584 "delete_area_cats_from_cidx()", area);
594 for (i = 0; i <
Cats->n_cats; i++) {
609void V2__add_area_cats_to_cidx_nat(
struct Map_info *
Map,
int area)
615 G_debug(3,
"V2__add_area_cats_to_cidx_nat(), area = %d", area);
617 Area =
Map->plus.Area[area];
620 "add_area_cats_to_cidx():", area);
630 for (i = 0; i <
Cats->n_cats; i++) {
670 G_warning(
_(
"Attempt to access feature with invalid id (%d)"), line);
674 Line =
Map->plus.Line[line];
676 G_warning(
_(
"Attempt to access dead feature %d"), line);
682 for (i = 0; i < cats->
n_cats; i++) {
701 if (next_line != 0 &&
abs(next_line) != line) {
708 if (next_line != 0 &&
abs(next_line) != line) {
716 if (next_line != 0 &&
abs(next_line) != line) {
724 if (next_line != 0 &&
abs(next_line) != line) {
733 if (topo->
left > 0) {
743 V2__delete_area_cats_from_cidx_nat(
Map, topo->
left);
747 else if (topo->
left < 0) {
750 if (topo->
right > 0) {
760 V2__delete_area_cats_from_cidx_nat(
Map, topo->
right);
764 else if (topo->
right < 0) {
775 if (topo->
area > 0) {
776 G_debug(3,
"Remove centroid %d from area %d", (
int)line,
779 V2__delete_area_cats_from_cidx_nat(
Map, topo->
area);
781 Area =
Map->plus.Area[topo->
area];
790 if (0 !=
dig_del_line(plus, line, points->
x[0], points->
y[0], points->
z[0]))
849 if (plus->
uplist.do_uplist) {
850 G_debug(3,
"updated lines : %d , updated nodes : %d",
910 int first, s, n, i, line;
923 "V2__add_line_to_topo_nat(): offset = %" PRId64
924 " (build level = %d)",
925 offset, plus->
built);
936 G_debug(3,
" line added to topo with id = %d", line);
938 Line = plus->
Line[line];
952 for (s = 0; s < 2; s++) {
953 node = (s == 0 ? topo->
N1 : topo->
N2);
954 G_debug(3,
" delete neighbour areas/isles: %s node = %d",
955 (s == 0 ?
"first" :
"second"), node);
956 Node = plus->
Node[node];
958 for (i = 0; i < Node->
n_lines; i++) {
964 G_debug(3,
" number of boundaries at node = %d", n);
977 if (next_line != 0) {
989 G_debug(3,
" next_line = %d area = %d", next_line, area);
1000 V2__delete_area_cats_from_cidx_nat(
Map, area);
1007 else if (area < 0) {
1021 for (s = 0; s < 2; s++) {
1034 else if (area < 0) {
1060 for (s = 0; s < 2; s++) {
1077 Line = plus->
Line[line];
1080 G_debug(3,
" first centroid -> attach to area");
1088 G_debug(3,
" duplicate centroid -> do not attach to area");
1097 for (i = 0; i < cats->
n_cats; i++) {
1103 if (plus->
uplist.do_uplist) {
1104 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)