GRASS GIS 8 Programmer's Manual  8.4.0dev(2024)-535c39c9fc
vector/Vlib/area.c File Reference

Vector library - area-related functions. More...

#include <stdlib.h>
#include <grass/vector.h>
#include <grass/glocale.h>
#include "pg_local_proto.h"
#include "local_proto.h"
Include dependency graph for vector/Vlib/area.c:

Go to the source code of this file.

Functions

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. More...
 
int Vect_get_isle_points (struct Map_info *Map, int isle, struct line_pnts *BPoints)
 Returns polygon array of points for given isle. More...
 
int Vect_get_area_centroid (struct Map_info *Map, int area)
 Returns centroid id for given area. More...
 
int Vect_get_area_boundaries (struct Map_info *Map, int area, struct ilist *List)
 Creates list of boundaries for given area. More...
 
int Vect_get_isle_boundaries (struct Map_info *Map, int isle, struct ilist *List)
 Creates list of boundaries for given isle. More...
 
int Vect_get_area_num_isles (struct Map_info *Map, int area)
 Returns number of isles for given area. More...
 
int Vect_get_area_isle (struct Map_info *Map, int area, int isle)
 Returns isle id for area. More...
 
int Vect_get_isle_area (struct Map_info *Map, int isle)
 Returns area id for isle. More...
 
double Vect_get_area_perimeter (struct Map_info *Map, int area)
 Returns perimeter of area with perimeter of isles. More...
 
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. More...
 
double Vect_get_area_area (struct Map_info *Map, int area)
 Returns area of area without areas of isles. More...
 
int Vect_get_area_cats (struct Map_info *Map, int area, struct line_cats *Cats)
 Get area categories. More...
 
int Vect_get_area_cat (struct Map_info *Map, int area, int field)
 Find FIRST category of given field and area. More...
 
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) More...
 
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) More...
 

Detailed Description

Vector library - area-related functions.

Higher level functions for reading/writing/manipulating vectors.

(C) 2001-2009, 2011-2013 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
Original author CERL, probably Dave Gerdes or Mike Higgins.
Update to GRASS 5.7 Radim Blazek and David D. Gray.

Definition in file vector/Vlib/area.c.

Function Documentation

◆ Vect__get_area_points()

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)

For PostGIS Topology calls Vect__get_area_points_pg() otherwise Vect__get_area_points_nat(),

Parameters
Mappointer to Map_info struct
linesarray of boundary lines
n_linesnumber of lines in array
[out]APointspointer to output line_pnts struct
Returns
number of points
-1 on error

Definition at line 487 of file vector/Vlib/area.c.

References _, Format_info_pg::cache, Format_info_cache::ctype, Map_info::fInfo, Map_info::format, G_fatal_error(), GV_FORMAT_POSTGIS, Format_info::pg, Format_info_pg::toposchema_name, Vect__get_area_points_nat(), and Vect__get_area_points_pg().

Referenced by Vect_build_line_area(), and Vect_get_area_points().

◆ Vect__get_area_points_nat()

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)

Used by Vect_build_line_area() and Vect_get_area_points().

Parameters
Mappointer to Map_info struct
linesarray of boundary lines
n_linesnumber of lines in array
[out]APointspointer to output line_pnts struct
Returns
number of points
-1 on error

Definition at line 516 of file vector/Vlib/area.c.

Referenced by Vect__get_area_points(), and Vect_get_isle_points().

◆ Vect_get_area_area()

double Vect_get_area_area ( struct Map_info Map,
int  area 
)

Returns area of area without areas of isles.

Parameters
Mappointer to Map_info structure
areaarea id
Returns
area of area without areas of isles

Definition at line 375 of file vector/Vlib/area.c.

◆ Vect_get_area_boundaries()

int Vect_get_area_boundaries ( struct Map_info Map,
int  area,
struct ilist List 
)

Creates list of boundaries for given area.

Note that ids in List can be negative. The sign indicates in which direction the boundary should be read (negative for backward).

Parameters
Mappointer to Map_info structure
areaarea id
[out]Listpointer to list of boundaries
Returns
number of boundaries

Definition at line 139 of file vector/Vlib/area.c.

◆ Vect_get_area_cat()

int Vect_get_area_cat ( struct Map_info Map,
int  area,
int  field 
)

Find FIRST category of given field and area.

Parameters
Mappointer to Map_info structure
areaarea id
fieldlayer number
Returns
first found category of given field
-1 no centroid or no category found

Definition at line 450 of file vector/Vlib/area.c.

References line_cats::cat, line_cats::field, line_cats::n_cats, NULL, Vect_get_area_cats(), Vect_new_cats_struct(), and Vect_reset_cats().

Referenced by vector2perimeters(), and Vedit_delete_areas_cat().

◆ Vect_get_area_cats()

int Vect_get_area_cats ( struct Map_info Map,
int  area,
struct line_cats Cats 
)

Get area categories.

Parameters
Mappointer to Map_info structure
areaarea id
[out]Catslist of categories
Returns
0 centroid found (but may be without categories)
1 no centroid found

Definition at line 423 of file vector/Vlib/area.c.

References NULL, Vect_get_area_centroid(), Vect_read_line(), and Vect_reset_cats().

Referenced by Vect_get_area_cat().

◆ Vect_get_area_centroid()

int Vect_get_area_centroid ( struct Map_info Map,
int  area 
)

Returns centroid id for given area.

Parameters
Mappointer to Map_info structure
areaarea id
Returns
centroid id of area
0 if no centroid found

Definition at line 110 of file vector/Vlib/area.c.

References _, Plus_head::Area, P_area::centroid, G_debug(), G_fatal_error(), NULL, and Map_info::plus.

Referenced by Vect_get_area_cats().

◆ Vect_get_area_isle()

int Vect_get_area_isle ( struct Map_info Map,
int  area,
int  isle 
)

Returns isle id for area.

Parameters
Mappointer to Map_info structure
areaarea id
isleisle index (0 .. nisles - 1)
Returns
isle id
0 if no isle found

Definition at line 236 of file vector/Vlib/area.c.

References _, Plus_head::Area, G_debug(), G_fatal_error(), P_area::isles, NULL, and Map_info::plus.

◆ Vect_get_area_num_isles()

int Vect_get_area_num_isles ( struct Map_info Map,
int  area 
)

Returns number of isles for given area.

Parameters
Mappointer to Map_info structure
areaarea id
Returns
number of isles for area
0 if area not found

Definition at line 208 of file vector/Vlib/area.c.

References _, Plus_head::Area, G_debug(), G_fatal_error(), P_area::n_isles, NULL, and Map_info::plus.

◆ Vect_get_area_perimeter()

double Vect_get_area_perimeter ( struct Map_info Map,
int  area 
)

Returns perimeter of area with perimeter of isles.

Parameters
Mappointer to Map_info structure
areaarea id
Returns
perimeter of area with perimeters of isles in meters

Definition at line 290 of file vector/Vlib/area.c.

◆ Vect_get_area_points()

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.

Parameters
Mappointer to Map_info structure
areaarea id
[out]BPointspoints array
Returns
number of points
-1 on error

Definition at line 37 of file vector/Vlib/area.c.

References _, Plus_head::Area, G_debug(), G_warning(), P_area::lines, P_area::n_lines, NULL, Map_info::plus, Vect__get_area_points(), and Vect_reset_line().

Referenced by vector2perimeters().

◆ Vect_get_isle_area()

int Vect_get_isle_area ( struct Map_info Map,
int  isle 
)

Returns area id for isle.

Parameters
Mapvector
isleisle number (0 .. nisles - 1)
Returns
area id
0 area not found

Definition at line 263 of file vector/Vlib/area.c.

References _, P_isle::area, G_debug(), G_fatal_error(), Plus_head::Isle, NULL, and Map_info::plus.

◆ Vect_get_isle_boundaries()

int Vect_get_isle_boundaries ( struct Map_info Map,
int  isle,
struct ilist List 
)

Creates list of boundaries for given isle.

Note that ids in List can be negative. The sign indicates in which direction the boundary should be read (negative for forward).

Parameters
Mappointer to Map_info structure
isleisland number
[out]Listpointer to list where boundaries are stored
Returns
number of boundaries

Definition at line 175 of file vector/Vlib/area.c.

◆ Vect_get_isle_points()

int Vect_get_isle_points ( struct Map_info Map,
int  isle,
struct line_pnts BPoints 
)

Returns polygon array of points for given isle.

Parameters
Mappointer to Map_info structure
isleisland id
[out]BPointspoints array
Returns
number of points
-1 on error

Definition at line 68 of file vector/Vlib/area.c.

References _, Format_info_pg::cache, Format_info_cache::ctype, Map_info::fInfo, Map_info::format, G_debug(), G_fatal_error(), G_warning(), GV_FORMAT_POSTGIS, Plus_head::Isle, P_isle::lines, P_isle::n_lines, NULL, Format_info::pg, Map_info::plus, Format_info_pg::toposchema_name, Vect__get_area_points_nat(), Vect__get_area_points_pg(), and Vect_reset_line().

◆ Vect_point_in_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.

Parameters
x,ypoint coordinates
Mappointer to Map_info structure
areaarea id
boxarea bounding box
Returns
0 if point is outside area
1 if point is inside area
2 if point is on the area's outer ring

Definition at line 334 of file vector/Vlib/area.c.