GRASS GIS 8 Programmer's Manual
8.5.0dev(2024)-602118adcc
|
Vector library - Building topology. More...
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
#include <math.h>
#include <grass/vector.h>
#include <grass/glocale.h>
#include "local_proto.h"
#include "pg_local_proto.h"
Go to the source code of this file.
Macros | |
#define | SEP "-----------------------------------\n" |
Functions | |
int | Vect_build_line_area (struct Map_info *Map, int iline, int side) |
Build area on given side of line (GV_LEFT or GV_RIGHT) More... | |
int | Vect_isle_find_area (struct Map_info *Map, int isle, const struct bound_box *box) |
Find area outside island. More... | |
int | Vect_attach_isle (struct Map_info *Map, int isle, const struct bound_box *box) |
(Re)Attach isle to area More... | |
int | Vect_attach_isles (struct Map_info *Map, const struct bound_box *box) |
(Re)Attach isles in given bounding box to areas More... | |
int | Vect_attach_centroids (struct Map_info *Map, const struct bound_box *box) |
(Re)Attach centroids in given bounding box to areas More... | |
int | Vect_build (struct Map_info *Map) |
Build topology for vector map. More... | |
int | Vect_topo_check (struct Map_info *Map, struct Map_info *Err) |
Extensive tests for correct topology. More... | |
int | Vect_get_built (struct Map_info *Map) |
Return current highest built level (part) More... | |
void | Vect__build_downgrade (struct Map_info *Map, int build) |
Downgrade build level (for internal use only) More... | |
int | Vect_build_partial (struct Map_info *Map, int build) |
Build partial topology for vector map. More... | |
int | Vect_save_topo (struct Map_info *Map) |
Save topology file for vector map. More... | |
int | Vect_topo_dump (struct Map_info *Map, FILE *out) |
Dump topology to file. More... | |
int | Vect_build_sidx (struct Map_info *Map) |
Create spatial index if necessary. More... | |
int | Vect_build_sidx_from_topo (struct Map_info *Map) |
Create spatial index from topology if necessary (not longer supported) More... | |
int | Vect_save_sidx (struct Map_info *Map) |
Save spatial index file for vector map. More... | |
int | Vect_sidx_dump (struct Map_info *Map, FILE *out) |
Dump spatial index to file. More... | |
Vector library - Building topology.
Higher level functions for reading/writing/manipulating vectors.
(C) 2001-2010, 2012-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.
Definition in file build.c.
void Vect__build_downgrade | ( | struct Map_info * | Map, |
int | build | ||
) |
Downgrade build level (for internal use only)
See Vect_build_nat(), Vect__build_sfa(), and Vect_build_pg() for implementation issues.
Map | pointer to Map_info |
build |
Definition at line 771 of file build.c.
Referenced by Vect__build_sfa().
(Re)Attach centroids in given bounding box to areas
Warning: If map is updated on level2, it may happen that previously correct island becomes incorrect. In that case, centroid of area forming the island is reattached to outer area, because island polygon is not excluded.
+-----------+ +-----------+ | 1 | | 1 | | +---+---+ | | +---+---+ | | | 2 | 3 | | | | 2 | | | | x | | | -> | | x | | | | | | | | | | | | +---+---+ | | +---+---+ | | | | | +-----------+ +-----------+ centroid is centroid is attached to 2 reattached to 1
Because of this, when the centroid is reattached to another area, it is always necessary to check if original area exist, unregister centroid from previous area. To simplify code, this is implemented so that centroid is always first unregistered and if new area is found, it is registered again.
Map | vector map |
box | bounding box |
(Re)Attach isle to area
Map | vector map |
isle | isle id |
box | isle bbox |
Definition at line 385 of file build.c.
References P_isle::area, Plus_head::box, dig_area_add_isle(), G_debug(), Plus_head::Isle, Map_info::plus, and Vect_isle_find_area().
Referenced by Vect_attach_isles().
(Re)Attach isles in given bounding box to areas
The warning for Vect_attach_centroids() applies here as well
Map | vector map |
box | bounding box |
Definition at line 427 of file build.c.
References P_isle::area, Plus_head::box, boxlist::box, dig_area_del_isle(), bound_box::E, G_debug(), boxlist::id, Plus_head::Isle, bound_box::N, boxlist::n_values, NULL, Map_info::plus, bound_box::S, TRUE, Vect_attach_isle(), Vect_get_area_box(), Vect_new_boxlist(), Vect_select_isles_by_box(), and bound_box::W.
int Vect_build | ( | struct Map_info * | Map | ) |
Build topology for vector map.
Map | vector map |
Definition at line 586 of file build.c.
References GV_BUILD_ALL, and Vect_build_partial().
Referenced by Vect_close().
int Vect_build_line_area | ( | struct Map_info * | Map, |
int | iline, | ||
int | side | ||
) |
Build area on given side of line (GV_LEFT or GV_RIGHT)
Map | pointer to Map_info structure |
iline | line id |
side | side (GV_LEFT or GV_RIGHT) |
Definition at line 79 of file build.c.
References _, dig_add_area(), dig_add_isle(), dig_build_area_with_line(), dig_find_area_poly(), dig_line_box(), dig_line_get_area(), G_debug(), G_fatal_error(), G_warning(), line_pnts::n_points, NULL, Map_info::plus, Vect__get_area_points(), Vect_line_prune(), and Vect_new_line_struct().
int Vect_build_partial | ( | struct Map_info * | Map, |
int | build | ||
) |
Build partial topology for vector map.
Should only be used in special cases of vector processing.
This functions optionally builds only some parts of topology. Highest level is specified by build parameter which may be:
If functions is called with build lower than current value of the Map, the level is downgraded to requested value.
All calls to Vect_write_line(), Vect_rewrite_line(), Vect_delete_line() respect the last value of build used in this function.
Note that the functions has effect only if requested level is higher than current level, to rebuild part of topology, call first downgrade and then upgrade, for example:
Map | vector map |
build | highest level of build |
Definition at line 861 of file build.c.
References _, Plus_head::built, dig_cidx_free(), dig_cidx_init(), Map_info::fInfo, Map_info::format, G_debug(), G_fatal_error(), G_message(), GV_BUILD_ALL, GV_BUILD_NONE, GV_FORMAT_OGR_DIRECT, GV_FORMAT_POSTGIS, Map_info::head, Map_info::level, LEVEL_1, Format_info::pg, Map_info::plus, Plus_head::Spidx_built, Plus_head::spidx_with_z, Map_info::support_updated, Map_info::temporary, Format_info_pg::toposchema_name, TRUE, Vect_get_full_name(), Vect_open_sidx(), dig_head::with_z, and Plus_head::with_z.
Referenced by Vect_build().
int Vect_build_sidx | ( | struct Map_info * | Map | ) |
Create spatial index if necessary.
To be used in modules. Map must be opened on level 2.
[in,out] | Map | pointer to vector map |
Definition at line 1224 of file build.c.
References _, G_fatal_error(), Map_info::level, Map_info::plus, Plus_head::Spidx_built, and Vect_build_sidx_from_topo().
int Vect_build_sidx_from_topo | ( | struct Map_info * | Map | ) |
Create spatial index from topology if necessary (not longer supported)
Map | pointer to vector map |
Definition at line 1244 of file build.c.
References _, G_debug(), G_warning(), and Vect_get_full_name().
Referenced by Vect_build_sidx(), and Vect_sidx_dump().
int Vect_get_built | ( | struct Map_info * | Map | ) |
Return current highest built level (part)
Map | vector map |
Definition at line 757 of file build.c.
References Plus_head::built, and Map_info::plus.
Find area outside island.
Map | vector map |
isle | isle id |
box | isle bbox |
Definition at line 179 of file build.c.
Referenced by Vect_attach_isle().
int Vect_save_sidx | ( | struct Map_info * | Map | ) |
Save spatial index file for vector map.
Map | vector map |
Definition at line 1261 of file build.c.
References _, dig__byte_order_out(), dig_file_init(), dig_init_portable(), dig_Wr_spidx(), FALSE, gvfile::file, G_debug(), G_warning(), GPATH_MAX, GV_SIDX_ELEMENT, NULL, Map_info::plus, Plus_head::Spidx_built, Plus_head::spidx_fp, Plus_head::Spidx_new, Plus_head::spidx_port, TRUE, Vect__get_element_path(), and Vect_get_name().
int Vect_save_topo | ( | struct Map_info * | Map | ) |
Save topology file for vector map.
Map | pointer to Map_info structure |
Definition at line 1012 of file build.c.
References _, dig__byte_order_out(), dig_file_init(), dig_init_portable(), dig_write_plus_file(), gvfile::file, G_debug(), G_fopen_new(), G_warning(), GPATH_MAX, GV_TOPO_ELEMENT, Map_info::name, NULL, Map_info::plus, Plus_head::port, and Vect__get_path().
int Vect_sidx_dump | ( | struct Map_info * | Map, |
FILE * | out | ||
) |
Dump spatial index to file.
Map | vector map |
out | file for output (stdout/stderr for example) |
Definition at line 1315 of file build.c.
References dig_dump_spidx(), Map_info::plus, Plus_head::Spidx_built, and Vect_build_sidx_from_topo().
Extensive tests for correct topology.
Map | vector map | |
[out] | Err | vector map where errors will be written or NULL |