22 #include "pg_local_proto.h"
25 #include "local_proto.h"
43 G_debug(3,
"Vect_get_area_points(): area = %d", area);
47 Area = Plus->
Area[area];
50 G_warning(
_(
"Attempt to read points of nonexistent area"));
74 G_debug(3,
"Vect_get_isle_points(): isle = %d", isle);
78 Isle = Plus->
Isle[isle];
81 G_warning(
_(
"Attempt to read points of nonexistent isle"));
115 G_debug(3,
"Vect_get_area_centroid(): area = %d", area);
118 Area = Plus->
Area[area];
121 G_fatal_error(
_(
"Attempt to read topo for dead area (%d)"), area);
145 G_debug(3,
"Vect_get_area_boundaries(): area = %d", area);
150 Area = Plus->
Area[area];
153 G_fatal_error(
_(
"Attempt to read topo for dead area (%d)"), area);
155 for (i = 0; i < Area->
n_lines; i++) {
156 line = Area->
lines[i];
181 G_debug(3,
"Vect_get_isle_boundaries(): isle = %d", isle);
186 Isle = Plus->
Isle[isle];
189 G_fatal_error(
_(
"Attempt to read topo for dead isle (%d)"), isle);
191 for (i = 0; i < Isle->
n_lines; i++) {
192 line = Isle->
lines[i];
213 G_debug(3,
"Vect_get_area_num_isles(): area = %d", area);
216 Area = Plus->
Area[area];
219 G_fatal_error(
_(
"Attempt to read topo for dead area (%d)"), area);
241 G_debug(3,
"Vect_get_area_isle(): area = %d isle = %d", area, isle);
244 Area = Plus->
Area[area];
247 G_fatal_error(
_(
"Attempt to read topo for dead area (%d)"), area);
251 return (Area->
isles[isle]);
268 G_debug(3,
"Vect_get_isle_area(): isle = %d", isle);
271 Isle = Plus->
Isle[isle];
274 G_fatal_error(
_(
"Attempt to read topo for dead isle (%d)"), isle);
298 G_debug(3,
"Vect_get_area_perimeter(): area = %d", area);
302 Area = Plus->
Area[area];
309 for (i = 0; i < Area->
n_isles; i++) {
317 G_debug(3,
" perimeter = %f", d);
344 Area = Plus->
Area[area];
356 for (i = 0; i < Area->
n_isles; i++) {
357 isle = Area->
isles[i];
382 static int first_time = 1;
384 G_debug(3,
"Vect_get_area_area(): area = %d", area);
386 if (first_time == 1) {
393 Area = Plus->
Area[area];
400 for (i = 0; i < Area->
n_isles; i++) {
408 G_debug(3,
" area = %f", size);
464 for (i = 0; i < Cats->
n_cats; i++) {
496 G_fatal_error(
_(
"GRASS is not compiled with PostgreSQL support"));
519 int i, line, aline, dir;
526 for (i = 0; i < n_lines; i++) {
529 G_debug(5,
" append line(%d) = %d", i, line);
int Vect__get_area_points_pg(struct Map_info *Map, const plus_t *lines, int n_lines, struct line_pnts *APoints)
Get area boundary points (PostGIS Topology)
double G_area_of_polygon(const double *, const double *, int)
Area in square meters of polygon.
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 G_begin_polygon_area_calculations(void)
Begin polygon area calculations.
void Vect_destroy_line_struct(struct line_pnts *)
Frees all memory associated with a line_pnts structure, including the structure itself.
int Vect_reset_cats(struct line_cats *)
Reset category structure to make sure cats structure is clean to be re-used.
int Vect_point_in_island(double, double, struct Map_info *, int, struct bound_box *)
Determines if a point (X,Y) is inside an island.
double Vect_line_geodesic_length(const struct line_pnts *)
Calculate line length.
int Vect_list_append(struct ilist *, int)
Append new item to the end of list if not yet present.
int Vect_read_line(struct Map_info *, struct line_pnts *, struct line_cats *, int)
Read vector feature (topological level required)
int Vect_point_in_area_outer_ring(double, double, struct Map_info *, int, struct bound_box *)
Determines if a point (X,Y) is inside an area outer ring. Islands are not considered.
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.
void Vect_reset_line(struct line_pnts *)
Reset line.
int Vect_line_prune(struct line_pnts *)
Remove duplicate points, i.e. zero length segments.
struct line_cats * Vect_new_cats_struct(void)
Creates and initializes line_cats structure.
int Vect_reset_list(struct ilist *)
Reset ilist structure.
int Vect_append_points(struct line_pnts *, const struct line_pnts *, int)
Appends points to the end of a line.
#define GV_FORMAT_POSTGIS
PostGIS format.
#define GV_FORWARD
Line direction indicator forward/backward.
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, ...)
plus_t n_isles
Number of islands inside.
plus_t * isles
1st generation interior islands
plus_t n_lines
Number of boundary lines.
plus_t * lines
List of boundary lines.
plus_t centroid
Number of first centroid within area.
plus_t * lines
List of boundary lines.
plus_t n_lines
Number of boundary lines.
plus_t area
Area it exists w/in, if any.
Basic topology-related info.
struct P_area ** Area
Array of areas.
struct P_isle ** Isle
Array of isles.
int n_values
Number of values in the list.
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 Vect_get_area_perimeter(struct Map_info *Map, int area)
Returns perimeter of area with perimeter of isles.
int Vect_get_area_isle(struct Map_info *Map, int area, int isle)
Returns isle id for area.
int Vect_point_in_area(double x, double y, struct Map_info *Map, int area, struct bound_box *box)
Check if point is in area.
int Vect_get_area_points(struct Map_info *Map, int area, struct line_pnts *BPoints)
Returns polygon array of points (outer ring) of given area.
int Vect_get_area_cat(struct Map_info *Map, int area, int field)
Find FIRST category of given field and area.
int Vect_get_area_boundaries(struct Map_info *Map, int area, struct ilist *List)
Creates list of boundaries for given area.
int Vect_get_area_num_isles(struct Map_info *Map, int area)
Returns number of isles for given area.
int Vect__get_area_points(struct Map_info *Map, const plus_t *lines, int n_lines, struct line_pnts *BPoints)
Get area boundary points (internal use only)
int Vect_get_area_centroid(struct Map_info *Map, int area)
Returns centroid id for given area.
int Vect_get_isle_points(struct Map_info *Map, int isle, struct line_pnts *BPoints)
Returns polygon array of points for given isle.
int Vect_get_area_cats(struct Map_info *Map, int area, struct line_cats *Cats)
Get area categories.
int Vect_get_isle_boundaries(struct Map_info *Map, int isle, struct ilist *List)
Creates list of boundaries for given isle.
int Vect__get_area_points_nat(struct Map_info *Map, const plus_t *lines, int n_lines, struct line_pnts *BPoints)
Get area boundary points (native format)
double Vect_get_area_area(struct Map_info *Map, int area)
Returns area of area without areas of isles.
int Vect_get_isle_area(struct Map_info *Map, int isle)
Returns area id for isle.