22 #include <grass/gis.h>
23 #include <grass/Vect.h>
24 #include <grass/glocale.h>
38 int area,
struct line_pnts *BPoints)
40 int i, line, aline, dir;
41 struct Plus_head *Plus;
43 static int first_time = 1;
44 static struct line_pnts *Points;
46 G_debug(3,
"Vect_get_area_points(): area = %d", area);
47 BPoints->n_points = 0;
50 Area = Plus->Area[area];
53 G_warning(_(
"Attempt to read points of nonexistent area"));
57 if (first_time == 1) {
62 G_debug(3,
" n_lines = %d", Area->n_lines);
63 for (i = 0; i < Area->n_lines; i++) {
64 line = Area->lines[i];
66 G_debug(3,
" append line(%d) = %d", i, line);
72 G_debug(3,
" line n_points = %d", Points->n_points);
80 if (i != (Area->n_lines - 1))
82 G_debug(3,
" area n_points = %d", BPoints->n_points);
85 return (BPoints->n_points);
99 int isle,
struct line_pnts *BPoints)
101 int i, line, aline, dir;
102 struct Plus_head *Plus;
104 static int first_time = 1;
105 static struct line_pnts *Points;
107 G_debug(3,
"Vect_get_isle_points(): isle = %d", isle);
108 BPoints->n_points = 0;
111 Isle = Plus->Isle[isle];
113 if (first_time == 1) {
118 G_debug(3,
" n_lines = %d", Isle->n_lines);
119 for (i = 0; i < Isle->n_lines; i++) {
120 line = Isle->lines[i];
122 G_debug(3,
" append line(%d) = %d", i, line);
128 G_debug(3,
" line n_points = %d", Points->n_points);
136 if (i != (Isle->n_lines - 1))
138 G_debug(3,
" isle n_points = %d", BPoints->n_points);
141 return (BPoints->n_points);
155 struct Plus_head *Plus;
158 G_debug(3,
"Vect_get_area_centroid(): area = %d", area);
161 Area = Plus->Area[area];
164 G_fatal_error(_(
"Attempt to read topo for dead area (%d)"), area);
166 return (Area->centroid);
182 struct Plus_head *Plus;
185 G_debug(3,
"Vect_get_area_boundaries(): area = %d", area);
190 Area = Plus->Area[area];
193 G_fatal_error(_(
"Attempt to read topo for dead area (%d)"), area);
195 for (i = 0; i < Area->n_lines; i++) {
196 line = Area->lines[i];
200 return (List->n_values);
216 struct Plus_head *Plus;
219 G_debug(3,
"Vect_get_isle_boundaries(): isle = %d", isle);
224 Isle = Plus->Isle[isle];
227 G_fatal_error(
"Attempt to read topo for dead isle (%d)", isle);
229 for (i = 0; i < Isle->n_lines; i++) {
230 line = Isle->lines[i];
234 return (List->n_values);
248 struct Plus_head *Plus;
251 G_debug(3,
"Vect_get_area_num_isles(): area = %d", area);
254 Area = Plus->Area[area];
257 G_fatal_error(_(
"Attempt to read topo for dead area (%d)"), area);
259 G_debug(3,
" n_isles = %d", Area->n_isles);
261 return (Area->n_isles);
277 struct Plus_head *Plus;
280 G_debug(3,
"Vect_get_area_isle(): area = %d isle = %d", area, isle);
283 Area = Plus->Area[area];
286 G_fatal_error(_(
"Attempt to read topo for dead area (%d)"), area);
288 G_debug(3,
" -> isle = %d", Area->isles[isle]);
290 return (Area->isles[isle]);
304 struct Plus_head *Plus;
307 G_debug(3,
"Vect_get_isle_area(): isle = %d", isle);
310 Isle = Plus->Isle[isle];
313 G_fatal_error(_(
"Attempt to read topo for dead isle (%d)"), isle);
315 G_debug(3,
" -> area = %d", Isle->area);
347 struct Plus_head *Plus;
352 Area = Plus->Area[area];
361 for (i = 0; i < Area->n_isles; i++) {
362 isle = Area->isles[i];
381 struct Plus_head *Plus;
383 struct line_pnts *Points;
386 static int first_time = 1;
388 G_debug(3,
"Vect_get_area_area(): area = %d", area);
390 if (first_time == 1) {
397 Area = Plus->Area[area];
403 for (i = 0; i < Area->n_isles; i++) {
410 G_debug(3,
" area = %f", size);
456 static struct line_cats *Cats =
NULL;
467 for (i = 0; i < Cats->n_cats; i++) {
468 if (Cats->field[i] == field) {
int Vect_get_area_centroid(struct Map_info *Map, int area)
Returns centroid number of area.
int Vect_get_area_boundaries(struct Map_info *Map, int area, struct ilist *List)
Creates list of boundaries for area.
int Vect_get_isle_points(struct Map_info *Map, int isle, struct line_pnts *BPoints)
Returns the polygon array of points in BPoints.
double G_area_of_polygon(const double *x, const double *y, int n)
Area in square meters of polygon.
int Vect_get_isle_area(struct Map_info *Map, int isle)
Returns area for isle.
struct line_pnts * Vect_new_line_struct()
Creates and initializes a struct line_pnts.
int Vect_point_in_island(double X, double Y, struct Map_info *Map, int isle)
Determines if a point (X,Y) is inside an island.
int Vect_append_points(struct line_pnts *Points, struct line_pnts *APoints, int direction)
Appends points to the end of a line.
int Vect_reset_cats(struct line_cats *Cats)
Reset category structure to make sure cats structure is clean to be re-used.
int Vect_get_area_num_isles(struct Map_info *Map, int area)
Returns number of isles for area.
int Vect_get_area_isle(struct Map_info *Map, int area, int isle)
Returns isle for 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_points(struct Map_info *Map, int area, struct line_pnts *BPoints)
Returns the polygon array of points in BPoints.
int Vect_point_in_area_outer_ring(double X, double Y, struct Map_info *Map, int area)
Determines if a point (X,Y) is inside an area outer ring. Islands are not considered.
int G_begin_polygon_area_calculations(void)
Begin polygon area calculations.
int Vect_point_in_area(struct Map_info *Map, int area, double x, double y)
Returns 1 if point is in area.
int Vect_reset_list(struct ilist *list)
Reset ilist structure.
int Vect_get_isle_boundaries(struct Map_info *Map, int isle, struct ilist *List)
Creates list of boundaries for isle.
int Vect_list_append(struct ilist *list, int val)
Append new item to the end of list if not yet present.
int Vect_get_area_cats(struct Map_info *Map, int area, struct line_cats *Cats)
Get area categories.
struct line_cats * Vect_new_cats_struct()
Creates and initializes line_cats structure.
double Vect_line_length(struct line_pnts *Points)
Calculate line length, 3D-length in case of 3D vector line.
G_warning("category support for [%s] in mapset [%s] %s", name, mapset, type)
double Vect_get_area_area(struct Map_info *Map, int area)
Returns area of area without areas of isles.
int G_debug(int level, const char *msg,...)
Print debugging message.
double Vect_area_perimeter(struct line_pnts *Points)
Calculate area perimeter.
int G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.
int Vect_destroy_line_struct(struct line_pnts *p)
Frees all memory associated with a struct line_pnts, including the struct itself. ...
int Vect_read_line(struct Map_info *Map, struct line_pnts *line_p, struct line_cats *line_c, int line)
Read vector feature.