GRASS GIS 7 Programmer's Manual  7.7.svn(2018)-r73373
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
vector/Vlib/area.c File Reference

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

#include <stdlib.h>
#include <grass/vector.h>
#include <grass/glocale.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 (const 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 (const struct Map_info *Map, int isle, struct line_pnts *BPoints)
 Returns polygon array of points for given isle. More...
 
int Vect_get_area_centroid (const struct Map_info *Map, int area)
 Returns centroid id for given area. More...
 
int Vect_get_area_boundaries (const struct Map_info *Map, int area, struct ilist *List)
 Creates list of boundaries for given area. More...
 
int Vect_get_isle_boundaries (const struct Map_info *Map, int isle, struct ilist *List)
 Creates list of boundaries for given isle. More...
 
int Vect_get_area_num_isles (const struct Map_info *Map, int area)
 Returns number of isles for given area. More...
 
int Vect_get_area_isle (const struct Map_info *Map, int area, int isle)
 Returns isle id for area. More...
 
int Vect_get_isle_area (const struct Map_info *Map, int isle)
 Returns area id for isle. More...
 
double Vect_get_area_perimeter (const struct Map_info *Map, int area)
 Returns perimeter of area with perimeter of isles. More...
 
int Vect_point_in_area (double x, double y, const struct Map_info *Map, int area, struct bound_box *box)
 Check if point is in area. More...
 
double Vect_get_area_area (const struct Map_info *Map, int area)
 Returns area of area without areas of isles. More...
 
int Vect_get_area_cats (const struct Map_info *Map, int area, struct line_cats *Cats)
 Get area categories. More...
 
int Vect_get_area_cat (const struct Map_info *Map, int area, int field)
 Find FIRST category of given field and area. More...
 
int Vect__get_area_points (const 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 (const 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

int Vect__get_area_points ( const 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 489 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, and Vect__get_area_points_nat().

Referenced by Vect_build_line_area(), and Vect_get_area_points().

int Vect__get_area_points_nat ( const 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 520 of file vector/Vlib/area.c.

References G_debug(), GV_BACKWARD, GV_FORWARD, line_pnts::n_points, NULL, Vect_append_points(), Vect_new_line_struct(), Vect_read_line(), and Vect_reset_line().

Referenced by Vect__get_area_points(), and Vect_get_isle_points().

double Vect_get_area_area ( const struct Map_info Map,
int  area 
)
int Vect_get_area_boundaries ( const 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.

References _, Plus_head::Area, G_debug(), G_fatal_error(), P_area::lines, P_area::n_lines, ilist::n_values, NULL, Map_info::plus, Vect_list_append(), and Vect_reset_list().

Referenced by Vect_remove_small_areas_ext(), Vect_remove_small_areas_nat(), Vect_topo_check(), and Vedit_delete_area().

int Vect_get_area_cat ( const 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 452 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 Vect__copy_areas(), Vect_write_ascii(), vector2perimeters(), and Vedit_delete_areas_cat().

int Vect_get_area_cats ( const 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 424 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(), and Vect_write_ascii().

int Vect_get_area_centroid ( const 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__copy_areas(), Vect_build_partial(), Vect_get_area_cats(), Vect_overlay_and(), Vect_remove_small_areas_ext(), Vect_remove_small_areas_nat(), Vect_set_varray_from_cat_list(), Vect_set_varray_from_db(), Vect_topo_check(), and Vedit_delete_area().

int Vect_get_area_isle ( const 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 237 of file vector/Vlib/area.c.

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

Referenced by Vect__copy_areas(), Vect_area_buffer2(), Vect_get_point_in_area(), Vect_read_area_geos(), Vect_remove_small_areas_nat(), and Vect_write_ascii().

int Vect_get_area_num_isles ( const 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.

Referenced by Vect__copy_areas(), Vect_area_buffer2(), Vect_get_point_in_area(), Vect_read_area_geos(), Vect_remove_small_areas_nat(), and Vect_write_ascii().

double Vect_get_area_perimeter ( const 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 291 of file vector/Vlib/area.c.

References Plus_head::Area, G_debug(), P_area::isles, P_area::n_isles, Map_info::plus, Vect_destroy_line_struct(), Vect_get_area_points(), Vect_get_isle_points(), Vect_line_geodesic_length(), Vect_line_prune(), and Vect_new_line_struct().

int Vect_get_area_points ( const 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 Gv_load_vect(), Vect__copy_areas(), Vect_area_buffer2(), Vect_get_area_area(), Vect_get_area_perimeter(), Vect_get_point_in_area(), Vect_isle_find_area(), Vect_tin_get_z(), Vect_write_ascii(), and vector2perimeters().

int Vect_get_isle_area ( const 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 264 of file vector/Vlib/area.c.

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

Referenced by Vect_remove_small_areas_nat(), Vect_select_areas_by_polygon(), Vect_topo_check(), and Vect_write_ascii().

int Vect_get_isle_boundaries ( const 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 structur
isleisland number
[out]Listpointer to list where boundaries are stored
Returns
number of boundaries

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

References _, G_debug(), G_fatal_error(), Plus_head::Isle, P_isle::lines, P_isle::n_lines, ilist::n_values, NULL, Map_info::plus, Vect_list_append(), and Vect_reset_list().

Referenced by Vect_remove_small_areas_nat().

int Vect_get_isle_points ( const struct Map_info Map,
int  isle,
struct line_pnts BPoints 
)
int Vect_point_in_area ( double  x,
double  y,
const 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 335 of file vector/Vlib/area.c.

References Plus_head::Area, P_area::isles, P_area::n_isles, NULL, Map_info::plus, Vect_get_isle_box(), Vect_point_in_area_outer_ring(), and Vect_point_in_island().