28 #include "local_proto.h"
31 #include "pg_local_proto.h"
34 #if defined HAVE_OGR || defined HAVE_POSTGRES
35 static void V2__add_line_to_topo_sfa(
struct Map_info *,
int,
56 #if defined HAVE_OGR || defined HAVE_POSTGRES
66 G_debug(3,
"V2_write_line_sfa(): type = %d (format = %d)", type,
88 G_debug(3,
"\tline added to topo with line = %d", line);
108 fid = offset_info->
array[offset];
112 G_debug(4,
"\tCentroid: x = %f, y = %f, cat = %lu, line = %d",
119 G_warning(
_(
"Unable to calculate centroid for area"));
122 V2__add_line_to_topo_sfa(Map, line, points, cats);
125 G_debug(3,
"updated lines : %d , updated nodes : %d",
132 G_fatal_error(
_(
"GRASS is not compiled with OGR/PostgreSQL support"));
156 G_debug(3,
"V2_rewrite_line_sfa(): line=%d type=%d", (
int)line, type);
159 G_warning(
_(
"Attempt to access feature with invalid id (%d)"),
164 #if defined HAVE_OGR || defined HAVE_POSTGRES
166 G_warning(
_(
"Unable to rewrite feature (incompatible feature types)"));
175 G_fatal_error(
_(
"GRASS is not compiled with OGR/PostgreSQL support"));
195 #if defined HAVE_OGR || defined HAVE_POSTGRES
196 int ret, i, type, first;
202 G_debug(3,
"V2_delete_line_sfa(): line = %d", (
int)line);
209 G_warning(
_(
"Attempt to access feature with invalid id (%d)"),
239 for (i = 0; i < Cats->
n_cats; i++) {
276 G_fatal_error(
_(
"GRASS is not compiled with OGR/PostgreSQL support"));
294 int nparts,
const struct line_cats *cats)
308 G_fatal_error(
_(
"GRASS is not compiled with PostgreSQL support"));
318 #if defined HAVE_OGR || defined HAVE_POSTGRES
327 void V2__add_line_to_topo_sfa(
struct Map_info *Map,
int line,
332 int type, area, side;
339 G_debug(3,
"V2__add_line_to_topo_sfa(): line = %d npoints = %d", line,
344 Line = plus->
Line[line];
350 if (topo->
N1 != topo->
N2) {
351 G_warning(
_(
"Boundary is not closed. Skipping."));
356 for (s = 0; s < 2; s++) {
378 G_debug(4,
"Vect_build_line_area(): -> area = %d", area);
389 for (i = 0; i < cats->
n_cats; i++) {
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
void Vect_destroy_line_struct(struct line_pnts *)
Frees all memory associated with a line_pnts structure, including the structure itself.
int Vect_attach_centroids(struct Map_info *, const struct bound_box *)
(Re)Attach centroids in given bounding box to areas
int V1_delete_line_pg(struct Map_info *, off_t)
int Vect_build_line_area(struct Map_info *, int, int)
Build area on given side of line (GV_LEFT or GV_RIGHT)
off_t V1_write_line_ogr(struct Map_info *, int, const struct line_pnts *, const struct line_cats *)
Writes feature on level 1 (OGR interface)
int Vect_box_extend(struct bound_box *, const struct bound_box *)
Extend box A by box B.
int Vect_get_point_in_poly(const struct line_pnts *, double *, double *)
Get point inside polygon.
int Vect_get_area_box(struct Map_info *, int, struct bound_box *)
Get bounding box of area.
int V1_delete_line_ogr(struct Map_info *, off_t)
Deletes feature at the given offset on level 1 (OGR interface)
struct line_pnts * Vect_new_line_struct(void)
Creates and initializes a line_pnts 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
struct line_cats * Vect_new_cats_struct(void)
Creates and initializes line_cats structure.
int Vect_append_point(struct line_pnts *, double, double, double)
Appends one point to the end of a line.
int V2_read_line_sfa(struct Map_info *, struct line_pnts *, struct line_cats *, int)
Reads feature from OGR/PostGIS layer on topological level.
int Vect_box_copy(struct bound_box *, const struct bound_box *)
Copy box B to box A.
off_t V1_write_line_pg(struct Map_info *, int, const struct line_pnts *, const struct line_cats *)
#define GV_FORMAT_POSTGIS
PostGIS format.
#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_FORMAT_OGR
OGR format.
#define GV_LEFT
Boundary side indicator left/right.
int dig_cidx_add_cat(struct Plus_head *, int, int, int, int)
int dig_del_line(struct Plus_head *, int, double, double, double)
Delete line from Plus_head structure.
int dig_cidx_del_cat(struct Plus_head *, int, int, int, int)
int dig_cidx_add_cat_sorted(struct Plus_head *, int, int, int, int)
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 format
Map format (native, ogr, postgis)
struct Format_info fInfo
Format info for non-native formats.
struct Plus_head plus
Plus info (topology, version, ...)
off_t offset
Offset in coor file for line.
void * topo
Topology info.
Basic topology-related info.
struct P_line ** Line
Array of vector geometries.
plus_t n_lines
Current number of lines.
int n_upnodes
number of updated nodes
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.
int n_uplines
Number of updated lines.
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.
off_t V2__write_area_ogr(struct Map_info *Map, const struct line_pnts **points, int nparts, const struct line_cats *cats)
Writes area on topological level (OGR Simple Features interface, internal use only)
off_t V2__write_area_pg(struct Map_info *Map, const struct line_pnts **points, int nparts, const struct line_cats *cats)
Writes area on topological level (PostGIS Simple Features interface, internal use only)
int V2_delete_line_sfa(struct Map_info *Map, off_t line)
Deletes feature on level 2 (OGR/PostGIS interface)
off_t V2_rewrite_line_sfa(struct Map_info *Map, off_t line, int type, const struct line_pnts *points, const struct line_cats *cats)
Rewrites feature at the given offset on level 2 (OGR/PostGIS interface, pseudo-topological level)
off_t V2__write_area_sfa(struct Map_info *Map, const struct line_pnts **points, int nparts, const struct line_cats *cats)
Writes area on topological level (Simple Features interface, internal use only)
off_t V2_write_line_sfa(struct Map_info *Map, int type, const struct line_pnts *points, const struct line_cats *cats)
Writes feature on level 2 (OGR/PostGIS interface, pseudo-topological level)