#include <stdlib.h>
#include <math.h>
#include <grass/gis.h>
#include <grass/Vect.h>
Go to the source code of this file.
Functions | |
struct line_pnts * | Vect__new_line_struct (void) |
struct line_pnts * | Vect_new_line_struct () |
creates and initializes a struct line_pnts. This structure is used for reading and writing vector lines and polygons. The library routines handle all memory allocation. If 3 lines in memory are needed at the same time, then simply 3 line_pnts structures have to be used | |
int | Vect_destroy_line_struct (struct line_pnts *p) |
frees all memory associated with a struct line_pnts, including the struct itself | |
int | Vect_copy_xyz_to_pnts (struct line_pnts *Points, double *x, double *y, double *z, int n) |
ADD. | |
int | Vect_reset_line (struct line_pnts *Points) |
ADD. Make sure line structure is clean to be re-used, i.e. it has no points associated with it Points must have previously been created with Vect_new_line_struct (). | |
int | Vect_append_point (struct line_pnts *Points, double x, double y, double z) |
appends one point to the end of a Points structure returns new number of points or -1 on out of memory Note, this will append to whatever is in line struct. If you are re-using a line struct, be sure to clear out old data first by calling Vect_reset_line () | |
int | Vect_line_insert_point (struct line_pnts *Points, int index, double x, double y, double z) |
insert new point at index position and move all old points at that position and above up | |
int | Vect_line_delete_point (struct line_pnts *Points, int index) |
delete point at given index and move all points above down | |
int | Vect_line_prune (struct line_pnts *Points) |
remove duplicate points, i.e. zero length segments | |
int | Vect_line_prune_thresh (struct line_pnts *Points, double threshold) |
remove points in threshold | |
int | Vect_append_points (struct line_pnts *Points, struct line_pnts *APoints, int direction) |
appends points to the end of a Points structure. Note, this will append to whatever is in line struct. If you are re-using a line struct, be sure to clear out old data first by calling Vect_reset_line () | |
int | Vect_copy_pnts_to_xyz (struct line_pnts *Points, double *x, double *y, double *z, int *n) |
ADD. NOTE! x/y arrays MUST be at least as large as Points->n_points. | |
int | Vect_point_on_line (struct line_pnts *Points, double distance, double *x, double *y, double *z, double *angle, double *slope) |
Find point on line in the specified distance from the begining, measured along line. | |
int | Vect_line_segment (struct line_pnts *InPoints, double start, double end, struct line_pnts *OutPoints) |
Create segment of InPoints from start to end measured along the line and write it to OutPoints. | |
double | Vect_line_length (struct line_pnts *Points) |
calculate line length, 3D-length in case of 3D vector line | |
double | Vect_line_geodesic_length (struct line_pnts *Points) |
calculate line length. If projection is LL, the length is measured along the geodesic. | |
int | Vect_line_distance (struct line_pnts *points, double ux, double uy, double uz, int with_z, double *px, double *py, double *pz, double *dist, double *spdist, double *lpdist) |
calculate line distance. Sets (if not null): px, py - point on line, dist - distance to line, spdist - distance to point on line from segment beginning, sldist - distance to point on line form line beginning along line | |
double | Vect_points_distance (double x1, double y1, double z1, double x2, double y2, double z2, int with_z) |
distance of 2 points. with_z - use z coordinate | |
int | Vect_line_box (struct line_pnts *Points, BOUND_BOX *Box) |
get bounding box of line | |
void | Vect_line_reverse (struct line_pnts *Points) |
reverse the order of vertices | |
int | Vect_get_line_cat (struct Map_info *Map, int line, int field) |
fetches FIRST category number for given vector line and field |
struct line_pnts * Vect__new_line_struct | ( | void | ) | [read] |
int Vect_append_point | ( | struct line_pnts * | Points, | |
double | x, | |||
double | y, | |||
double | z | |||
) |
appends one point to the end of a Points structure returns new number of points or -1 on out of memory Note, this will append to whatever is in line struct. If you are re-using a line struct, be sure to clear out old data first by calling Vect_reset_line ()
line_pnts | * structure, x, y, z |
Definition at line 143 of file line.c.
References dig_alloc_points().
Referenced by clean_parallel(), parallel_line(), Vect__intersect_line_with_poly(), Vect_break_lines(), Vect_break_polygons(), Vect_clean_small_angles_at_nodes(), Vect_line_buffer(), Vect_line_intersection(), Vect_line_segment(), Vect_net_nearest_nodes(), Vect_net_shortest_path_coor(), and Vect_snap_lines().
int Vect_append_points | ( | struct line_pnts * | Points, | |
struct line_pnts * | APoints, | |||
int | direction | |||
) |
appends points to the end of a Points structure. Note, this will append to whatever is in line struct. If you are re-using a line struct, be sure to clear out old data first by calling Vect_reset_line ()
line_pnts | * structure, line_pntsA * structure, direction (GV_FORWARD, GV_BACKWARD) |
Definition at line 278 of file line.c.
References dig_alloc_points().
Referenced by Vect_build_line_area(), Vect_get_area_points(), Vect_get_isle_points(), Vect_line_buffer(), and Vect_net_shortest_path_coor().
int Vect_copy_pnts_to_xyz | ( | struct line_pnts * | Points, | |
double * | x, | |||
double * | y, | |||
double * | z, | |||
int * | n | |||
) |
int Vect_copy_xyz_to_pnts | ( | struct line_pnts * | Points, | |
double * | x, | |||
double * | y, | |||
double * | z, | |||
int | n | |||
) |
ADD.
line_pnts | * structure, x, y, z, number of points |
Definition at line 93 of file line.c.
References dig_alloc_points().
Referenced by parallel_line().
int Vect_destroy_line_struct | ( | struct line_pnts * | p | ) |
frees all memory associated with a struct line_pnts, including the struct itself
line_pnts | * structure |
Definition at line 69 of file line.c.
Referenced by Vect_break_lines(), Vect_copy_map_lines(), Vect_get_area_area(), Vect_line_intersection(), and Vect_snap_lines().
int Vect_get_line_cat | ( | struct Map_info * | Map, | |
int | line, | |||
int | field | |||
) |
fetches FIRST category number for given vector line and field
vmap,: | Map input | |
varea,: | line number | |
vfield,: | field number |
category number (>=0)
Definition at line 735 of file line.c.
References Vect_cat_get(), Vect_new_cats_struct(), and Vect_read_line().
int Vect_line_box | ( | struct line_pnts * | Points, | |
BOUND_BOX * | Box | |||
) |
get bounding box of line
line_pnts | * structure, BOUND_BOX |
Definition at line 692 of file line.c.
References dig_line_box().
Referenced by V1_read_next_line_nat(), and Vect_remove_duplicates().
int Vect_line_delete_point | ( | struct line_pnts * | Points, | |
int | index | |||
) |
delete point at given index and move all points above down
Points | line structure | |
index | (from 0 to Points->n_points-1) |
Definition at line 199 of file line.c.
Referenced by Vect_clean_small_angles_at_nodes().
int Vect_line_distance | ( | struct line_pnts * | points, | |
double | ux, | |||
double | uy, | |||
double | uz, | |||
int | with_z, | |||
double * | px, | |||
double * | py, | |||
double * | pz, | |||
double * | dist, | |||
double * | spdist, | |||
double * | lpdist | |||
) |
calculate line distance. Sets (if not null): px, py - point on line, dist - distance to line, spdist - distance to point on line from segment beginning, sldist - distance to point on line form line beginning along line
line_pnts | * structure, x, y, z of point, flag if to use z coordinate, (3D calculation), point on line, distance to line, distance of point from segment beginning, distance of point from line beginning |
Definition at line 567 of file line.c.
References dig_distance2_point_to_line().
Referenced by Vect_find_line(), Vect_line_check_intersection(), Vect_net_nearest_nodes(), and Vect_net_shortest_path_coor().
double Vect_line_geodesic_length | ( | struct line_pnts * | Points | ) |
calculate line length. If projection is LL, the length is measured along the geodesic.
line_pnts | * structure |
Definition at line 521 of file line.c.
Referenced by Vect_net_build_graph().
int Vect_line_insert_point | ( | struct line_pnts * | Points, | |
int | index, | |||
double | x, | |||
double | y, | |||
double | z | |||
) |
insert new point at index position and move all old points at that position and above up
Points | line structure | |
index | (from 0 to Points->n_points-1) | |
x | ||
y | ||
z |
Definition at line 168 of file line.c.
References dig_alloc_points().
double Vect_line_length | ( | struct line_pnts * | Points | ) |
calculate line length, 3D-length in case of 3D vector line
line_pnts | * structure |
Definition at line 496 of file line.c.
Referenced by remove_dangles(), Vect_area_perimeter(), Vect_line_segment(), Vect_net_build_graph(), Vect_net_nearest_nodes(), Vect_net_shortest_path_coor(), Vect_point_on_line(), and Vect_remove_small_areas().
int Vect_line_prune | ( | struct line_pnts * | Points | ) |
remove duplicate points, i.e. zero length segments
Points | line structure |
Definition at line 226 of file line.c.
Referenced by parallel_line(), Vect_break_lines(), Vect_break_polygons(), Vect_clean_small_angles_at_nodes(), Vect_line_buffer(), and Vect_snap_lines().
int Vect_line_prune_thresh | ( | struct line_pnts * | Points, | |
double | threshold | |||
) |
remove points in threshold
Points | line structure |
Definition at line 255 of file line.c.
References dig_prune().
void Vect_line_reverse | ( | struct line_pnts * | Points | ) |
int Vect_line_segment | ( | struct line_pnts * | InPoints, | |
double | start, | |||
double | end, | |||
struct line_pnts * | OutPoints | |||
) |
Create segment of InPoints from start to end measured along the line and write it to OutPoints.
If the distance is greater than line length or negative, error is returned.
line_pnts | * structure, start, end, line_pnts * structure |
Definition at line 445 of file line.c.
References Vect_append_point(), Vect_line_length(), Vect_point_on_line(), and Vect_reset_line().
struct line_pnts * Vect_new_line_struct | ( | void | ) | [read] |
creates and initializes a struct line_pnts. This structure is used for reading and writing vector lines and polygons. The library routines handle all memory allocation. If 3 lines in memory are needed at the same time, then simply 3 line_pnts structures have to be used
void |
Definition at line 35 of file line.c.
References Vect__new_line_struct().
Referenced by clean_parallel(), remove_bridges(), remove_dangles(), V1_rewrite_line_nat(), Vect_break_lines(), Vect_break_polygons(), Vect_build_line_area(), Vect_build_nat(), Vect_clean_small_angles_at_nodes(), Vect_copy_map_lines(), Vect_find_island(), Vect_find_line(), Vect_get_area_area(), Vect_get_area_points(), Vect_get_isle_points(), Vect_get_point_in_area(), Vect_get_point_in_poly_isl(), Vect_isle_find_area(), Vect_line_buffer(), Vect_line_intersection(), Vect_net_build_graph(), Vect_net_nearest_nodes(), Vect_net_shortest_path_coor(), Vect_overlay_and(), Vect_point_in_area_outer_ring(), Vect_point_in_island(), Vect_remove_duplicates(), Vect_remove_small_areas(), Vect_select_lines_by_polygon(), Vect_snap_lines(), and Vect_tin_get_z().
int Vect_point_on_line | ( | struct line_pnts * | Points, | |
double | distance, | |||
double * | x, | |||
double * | y, | |||
double * | z, | |||
double * | angle, | |||
double * | slope | |||
) |
Find point on line in the specified distance from the begining, measured along line.
If the distance is greater than line length or negative, error is returned.
( G_begin_distance_calculations() must be called before. - Is not true because G_distance is not used (no 3D support) )
x, *y, *z - pointers to point coordinates or NULL angle - pointer to angle of line in that point (radians, counter clockwise from x axis) or NULL slope - pointer to slope angle in radians (positive up)
line_pnts | * structure, distance, x, y, z, angle, slope |
Definition at line 355 of file line.c.
References Vect_line_length().
Referenced by Vect_line_segment().
double Vect_points_distance | ( | double | x1, | |
double | y1, | |||
double | z1, | |||
double | x2, | |||
double | y2, | |||
double | z2, | |||
int | with_z | |||
) |
distance of 2 points. with_z - use z coordinate
x1,y1,z1,x2,y2,z2,with_z |
Definition at line 666 of file line.c.
Referenced by Vect_clean_small_angles_at_nodes(), and Vect_find_node().
int Vect_reset_line | ( | struct line_pnts * | Points | ) |
ADD. Make sure line structure is clean to be re-used, i.e. it has no points associated with it Points must have previously been created with Vect_new_line_struct ().
line_pnts | * structure |
Definition at line 126 of file line.c.
Referenced by clean_parallel(), parallel_line(), Vect_break_lines(), Vect_break_polygons(), Vect_build_line_area(), Vect_clean_small_angles_at_nodes(), Vect_line_buffer(), Vect_line_segment(), Vect_net_nearest_nodes(), Vect_net_shortest_path_coor(), and Vect_snap_lines().