GRASS 8 Programmer's Manual 8.6.0dev(2026)-4bb960b182
Loading...
Searching...
No Matches
flip.c
Go to the documentation of this file.
1/*!
2 \file lib/vector/vedit/flip.c
3
4 \brief Vedit library - flip lines
5
6 SPDX-FileCopyrightText: 2007-2008 GRASS Development Team
7 SPDX-License-Identifier: GPL-2.0-or-later
8
9 \author Martin Landa <landa.martin gmail.com>
10 */
11
12#include <grass/vedit.h>
13
14/*!
15 \brief Flip direction of selected lines
16
17 \param Map pointer to Map_info
18 \param List list of selected lines
19
20 \return number of modified lines
21 \return -1 on error
22 */
23int Vedit_flip_lines(struct Map_info *Map, struct ilist *List)
24{
25 struct line_cats *Cats;
26 struct line_pnts *Points;
27 int i, line, type;
29
31
32 Points = Vect_new_line_struct();
34
35 for (i = 0; i < List->n_values; i++) {
36 line = List->value[i];
37
38 if (!Vect_line_alive(Map, line))
39 continue;
40
41 type = Vect_read_line(Map, Points, Cats, line);
42
43 if (!(type & GV_LINES))
44 continue;
45
46 Vect_line_reverse(Points);
47
48 if (Vect_rewrite_line(Map, line, type, Points, Cats) < 0) {
49 return -1;
50 }
51
52 G_debug(3, "Vedit_flip_lines(): line=%d", line);
53
55 }
56
57 /* destroy structures */
60
61 return nlines_flipped;
62}
int G_debug(int, const char *,...) __attribute__((format(printf
void Vect_destroy_line_struct(struct line_pnts *)
Frees all memory associated with a line_pnts structure, including the structure itself.
Definition line.c:75
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)
void Vect_line_reverse(struct line_pnts *)
Reverse the order of vertices.
Definition line.c:896
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)
struct line_cats * Vect_new_cats_struct(void)
Creates and initializes line_cats structure.
struct line_pnts * Vect_new_line_struct(void)
Creates and initializes a line_pnts structure.
Definition line.c:43
#define GV_LINES
int Vedit_flip_lines(struct Map_info *Map, struct ilist *List)
Flip direction of selected lines.
Definition flip.c:23
Vector map info.
List of integers.
Definition gis.h:712
Feature category info.
Feature geometry info - coordinates.