83static int compare_xpnts(
const void *
Xpnta,
const void *
Xpntb)
103 G_warning(
_(
"Break polygons: Bug in binary tree!"));
118 double dx, dy, a1 = 0, a2 = 0;
131 G_debug(1,
"File-based version of Vect_break_polygons()");
157 G_debug(3,
"nlines = %d", nlines);
165 G_message(
_(
"Breaking polygons (pass 1: select break points)..."));
167 for (i = 1; i <= nlines; i++) {
209 G_debug(3,
"fpoint = %d", fpoint);
221 dx = Points->
x[1] - Points->
x[0];
222 dy = Points->
y[1] - Points->
y[0];
226 dx = Points->
x[
j - 1] - Points->
x[
j];
227 dy = Points->
y[
j - 1] - Points->
y[
j];
229 dx = Points->
x[
j + 1] - Points->
x[
j];
230 dy = Points->
y[
j + 1] - Points->
y[
j];
241 _(
"File read/write operation failed: %s (%d)"),
258 _(
"File read/write operation failed: %s (%d)"),
266 G_debug(3,
"a1 = %f xa1 = %f a2 = %f xa2 = %f", a1,
XPnt.a1,
268 if ((a1 ==
XPnt.a1 && a2 ==
XPnt.a2) ||
278 _(
"File read/write operation failed: %s (%d)"),
306 _(
"File read/write operation failed: %s (%d)"),
323 G_message(
_(
"Breaking polygons (pass 2: break at selected points)..."));
325 for (i = 1; i <= nlines; i++) {
364 G_debug(3,
"fpoint = %d", fpoint);
380 for (k = last; k <=
j; k++) {
390 "Line %d written j = %d n_points(orig,pruned) = %d "
391 "n_points(new) = %d",
413 _(
"File read/write operation failed: %s (%d)"),
436 G_debug(3,
"Line %d was deleted", i);
440 G_debug(3,
"Line %d was not changed", i);
464 double dx, dy, a1 = 0, a2 = 0;
467 G_debug(1,
"Memory-based version of Vect_break_polygons()");
478 G_debug(3,
"nlines = %d", nlines);
485 G_message(
_(
"Breaking polygons (pass 1: select break points)..."));
487 for (i = 1; i <= nlines; i++) {
534 dx = Points->
x[1] - Points->
x[0];
535 dy = Points->
y[1] - Points->
y[0];
539 dx = Points->
x[
j - 1] - Points->
x[
j];
540 dy = Points->
y[
j - 1] - Points->
y[
j];
542 dx = Points->
x[
j + 1] - Points->
x[
j];
543 dy = Points->
y[
j + 1] - Points->
y[
j];
557 G_debug(3,
"a1 = %f xa1 = %f a2 = %f xa2 = %f", a1,
588 G_debug(2,
"Break polygons: unique vertices: %ld", (
long int)
RBTree->count);
597 G_message(
_(
"Breaking polygons (pass 2: break at selected points)..."));
599 for (i = 1; i <= nlines; i++) {
641 for (k = last; k <=
j; k++) {
651 "Line %d written j = %d n_points(orig,pruned) = %d "
652 "n_points(new) = %d",
684 G_debug(3,
"Line %d was deleted", i);
688 G_debug(3,
"Line %d was not changed", i);
720 if (
getenv(
"GRASS_VECTOR_LOWMEM"))
void Vect_break_polygons_mem(struct Map_info *Map, int type, struct Map_info *Err)
void Vect_break_polygons_file(struct Map_info *Map, int type, struct Map_info *Err)
void Vect_break_polygons(struct Map_info *Map, int type, struct Map_info *Err)
Break polygons in vector map.
void G_percent(long, long, int)
Print percent complete messages.
void G_free(void *)
Free allocated memory.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
void G_warning(const char *,...) __attribute__((format(printf
void void G_verbose_message(const char *,...) __attribute__((format(printf
char * G_tempfile(void)
Returns a temporary file name.
void G_message(const char *,...) __attribute__((format(printf
int G_debug(int, const char *,...) __attribute__((format(printf
int rbtree_insert(struct RB_TREE *, void *)
struct RB_TREE * rbtree_create(rb_compare_fn *, size_t)
void * rbtree_find(struct RB_TREE *, const void *)
void rbtree_destroy(struct RB_TREE *)
void Vect_destroy_line_struct(struct line_pnts *)
Frees all memory associated with a line_pnts structure, including the structure itself.
off_t Vect_rewrite_line(struct Map_info *, off_t, int, const struct line_pnts *, const struct line_cats *)
Rewrites existing feature (topological level required)
plus_t Vect_get_num_lines(struct Map_info *)
Fetch number of features (points, lines, boundaries, centroids) in vector map.
void Vect_destroy_cats_struct(struct line_cats *)
Frees all memory associated with line_cats structure, including the struct itself.
int Vect_read_line(struct Map_info *, struct line_pnts *, struct line_cats *, int)
Read vector feature (topological level required)
int Vect_line_alive(struct Map_info *, int)
Check if feature is alive or dead (topological level required)
int Vect_delete_line(struct Map_info *, off_t)
Delete existing feature (topological level required)
struct line_cats * Vect_new_cats_struct(void)
Creates and initializes line_cats structure.
off_t Vect_write_line(struct Map_info *, int, const struct line_pnts *, const struct line_cats *)
Writes a new feature.
void Vect_reset_line(struct line_pnts *)
Reset line.
int Vect_line_prune(struct line_pnts *)
Remove duplicate points, i.e. zero length segments.
struct line_pnts * Vect_new_line_struct(void)
Creates and initializes a line_pnts structure.
int Vect_append_point(struct line_pnts *, double, double, double)
Appends one point to the end of a line.
#define GV_POINT
Feature types used in memory on run time (may change)
Header file for msvc/fcntl.c.
#define G_UNUSED
A macro for an attribute, if attached to a variable, indicating that the variable is not used.
Feature geometry info - coordinates.
double * y
Array of Y coordinates.
double * x
Array of X coordinates.
int n_points
Number of points.
double * z
Array of Z coordinates.
SYMBOL * err(FILE *fp, SYMBOL *s, char *msg)
struct RTree * RTreeCreateTree(int fd, off_t rootpos, int ndims)
Create new empty R*-Tree.
int RTreeInsertRect(struct RTree_Rect *r, int tid, struct RTree *t)
Insert an item into a R*-Tree.
void RTreeDestroyTree(struct RTree *t)
Destroy an R*-Tree.
int RTreeSearch(struct RTree *t, struct RTree_Rect *r, SearchHitCallback *shcb, void *cbarg)
Search an R*-Tree.