27 #include "local_proto.h" 30 #include "pg_local_proto.h" 33 #if defined HAVE_OGR || defined HAVE_POSTGRES 34 static void V2__add_line_to_topo_sfa(
struct Map_info *,
int,
const struct line_pnts *,
52 #if defined HAVE_OGR || defined HAVE_POSTGRES 62 G_debug(3,
"V2_write_line_sfa(): type = %d (format = %d)",
84 G_debug(3,
"\tline added to topo with line = %d", line);
104 fid = offset_info->
array[offset];
109 G_debug(4,
"\tCentroid: x = %f, y = %f, cat = %lu, line = %d",
117 G_warning(
_(
"Unable to calculate centroid for area"));
120 V2__add_line_to_topo_sfa(Map, line, points, cats);
131 G_fatal_error(
_(
"GRASS is not compiled with OGR/PostgreSQL support"));
154 G_debug(3,
"V2_rewrite_line_sfa(): line=%d type=%d",
158 G_warning(
_(
"Attempt to access feature with invalid id (%d)"), (
int)line);
162 #if defined HAVE_OGR || defined HAVE_POSTGRES 164 G_warning(
_(
"Unable to rewrite feature (incompatible feature types)"));
173 G_fatal_error(
_(
"GRASS is not compiled with OGR/PostgreSQL support"));
193 #if defined HAVE_OGR || defined HAVE_POSTGRES 194 int ret, i, type, first;
200 G_debug(3,
"V2_delete_line_sfa(): line = %d", (
int)line);
207 G_warning(
_(
"Attempt to access feature with invalid id (%d)"), (
int)line);
236 for (i = 0; i < Cats->
n_cats; i++) {
273 G_fatal_error(
_(
"GRASS is not compiled with OGR/PostgreSQL support"));
291 const struct line_pnts **points,
int nparts,
306 G_fatal_error(
_(
"GRASS is not compiled with PostgreSQL support"));
316 #if defined HAVE_OGR || defined HAVE_POSTGRES 325 void V2__add_line_to_topo_sfa(
struct Map_info *Map,
int line,
330 int type, area, side;
337 G_debug(3,
"V2__add_line_to_topo_sfa(): line = %d npoints = %d", line,
341 Line = plus->
Line[line];
348 if (topo->
N1 != topo->
N2) {
349 G_warning(
_(
"Boundary is not closed. Skipping."));
354 for (s = 0; s < 2; s++) {
376 G_debug(4,
"Vect_build_line_area(): -> area = %d", area);
387 for (i = 0; i < cats->
n_cats; i++) {
int Vect_get_area_box(const struct Map_info *, int, struct bound_box *)
Get bounding box of area.
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
int built
Highest level of topology currently available.
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) ...
#define GV_LEFT
Boundary side indicator left/right.
int Vect_attach_isles(struct Map_info *, const struct bound_box *)
(Re)Attach isles in given bounding box to areas
int n_uplines
Number of updated lines.
off_t offset
Offset in coor file for 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.
struct P_line ** Line
Array of vector geometries.
int Vect_box_copy(struct bound_box *, const struct bound_box *)
Copy box B to box A.
int Vect_attach_centroids(struct Map_info *, const struct bound_box *)
(Re)Attach centroids in given bounding box to areas
#define GV_BUILD_BASE
Topology levels - basic level (without areas and isles)
int V1_delete_line_pg(struct Map_info *, off_t)
Deletes feature at the given offset (level 1)
int V1_delete_line_ogr(struct Map_info *, off_t)
Deletes feature at the given offset on level 1 (OGR interface)
int dig_line_box(const struct line_pnts *, struct bound_box *)
int n_points
Number of points.
#define GV_FORMAT_OGR
OGR format.
struct Format_info fInfo
Format info for non-native formats.
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) ...
int dig_del_line(struct Plus_head *, int, double, double, double)
Delete line from Plus_head structure.
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)
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) ...
plus_t n_lines
Current number of lines.
int dig_cidx_add_cat(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.
off_t V1_write_line_pg(struct Map_info *, int, const struct line_pnts *, const struct line_cats *)
Writes feature on level 1 (PostGIS interface)
double * x
Array of X coordinates.
int cidx_up_to_date
Category index to be updated.
Feature geometry info - coordinates.
Basic topology-related info.
int dig_cidx_del_cat(struct Plus_head *, int, int, int, int)
#define GV_BUILD_AREAS
Topology levels - build areas.
int Vect_get_point_in_poly(const struct line_pnts *, double *, double *)
Get point inside polygon.
struct line_pnts * Vect_new_line_struct(void)
Creates and initializes a line_pnts structure.
void * topo
Topology info.
int n_upnodes
number of updated nodes
int n_cats
Number of categories attached to element.
int * cat
Array of categories.
int Vect_append_point(struct line_pnts *, double, double, double)
Appends one point to the end of a line.
struct Plus_head plus
Plus info (topology, version, ...)
int Vect_box_extend(struct bound_box *, const struct bound_box *)
Extend box A by box B.
struct bound_box box
Bounding box of features.
int Vect_get_isle_box(const struct Map_info *, int, struct bound_box *)
Get bounding box of isle.
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)
#define GV_BUILD_ATTACH_ISLES
Topology levels - attach islands to areas.
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)
#define GV_FORMAT_POSTGIS
PostGIS format.
int V2_delete_line_sfa(struct Map_info *Map, off_t line)
Deletes feature on level 2 (OGR/PostGIS interface)
double * y
Array of Y coordinates.
struct line_cats * Vect_new_cats_struct(void)
Creates and initializes line_cats structure.
void G_warning(const char *,...) __attribute__((format(printf
double * z
Array of Z coordinates.
int format
Map format (native, ogr, postgis)
#define GV_BUILD_CENTROIDS
Topology levels - assign centroids to areas.
int * field
Array of layers (fields)
struct Plus_head::@10 uplist
List of updated lines/nodes.
void Vect_destroy_line_struct(struct line_pnts *)
Frees all memory associated with a line_pnts structure, including the structure itself.
int dig_cidx_add_cat_sorted(struct Plus_head *, int, int, int, int)
int update_cidx
Update category index if vector is modified.
int G_debug(int, const char *,...) __attribute__((format(printf