Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib/vector: reading files with 'struct Map_info*' objects is technically not const #2894

Merged
merged 3 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
280 changes: 137 additions & 143 deletions include/grass/defs/vector.h

Large diffs are not rendered by default.

33 changes: 15 additions & 18 deletions lib/vector/Vlib/area.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
\return number of points
\return -1 on error
*/
int Vect_get_area_points(const struct Map_info *Map, int area,
int Vect_get_area_points(struct Map_info *Map, int area,
struct line_pnts *BPoints)
{
const struct Plus_head *Plus;
Expand Down Expand Up @@ -65,7 +65,7 @@ int Vect_get_area_points(const struct Map_info *Map, int area,
\return number of points
\return -1 on error
*/
int Vect_get_isle_points(const struct Map_info *Map, int isle,
int Vect_get_isle_points(struct Map_info *Map, int isle,
struct line_pnts *BPoints)
{
const struct Plus_head *Plus;
Expand Down Expand Up @@ -107,7 +107,7 @@ int Vect_get_isle_points(const struct Map_info *Map, int isle,
\return centroid id of area
\return 0 if no centroid found
*/
int Vect_get_area_centroid(const struct Map_info *Map, int area)
int Vect_get_area_centroid(struct Map_info *Map, int area)
{
const struct Plus_head *Plus;
struct P_area *Area;
Expand Down Expand Up @@ -136,8 +136,7 @@ int Vect_get_area_centroid(const struct Map_info *Map, int area)
\return number of boundaries
*/
int Vect_get_area_boundaries(const struct Map_info *Map, int area,
struct ilist *List)
int Vect_get_area_boundaries(struct Map_info *Map, int area, struct ilist *List)
{
int i, line;
const struct Plus_head *Plus;
Expand Down Expand Up @@ -173,8 +172,7 @@ int Vect_get_area_boundaries(const struct Map_info *Map, int area,
\return number of boundaries
*/
int Vect_get_isle_boundaries(const struct Map_info *Map, int isle,
struct ilist *List)
int Vect_get_isle_boundaries(struct Map_info *Map, int isle, struct ilist *List)
{
int i, line;
const struct Plus_head *Plus;
Expand Down Expand Up @@ -207,7 +205,7 @@ int Vect_get_isle_boundaries(const struct Map_info *Map, int isle,
\return number of isles for area
\return 0 if area not found
*/
int Vect_get_area_num_isles(const struct Map_info *Map, int area)
int Vect_get_area_num_isles(struct Map_info *Map, int area)
{
const struct Plus_head *Plus;
struct P_area *Area;
Expand Down Expand Up @@ -235,7 +233,7 @@ int Vect_get_area_num_isles(const struct Map_info *Map, int area)
\return isle id
\return 0 if no isle found
*/
int Vect_get_area_isle(const struct Map_info *Map, int area, int isle)
int Vect_get_area_isle(struct Map_info *Map, int area, int isle)
{
const struct Plus_head *Plus;
struct P_area *Area;
Expand All @@ -262,7 +260,7 @@ int Vect_get_area_isle(const struct Map_info *Map, int area, int isle)
\return area id
\return 0 area not found
*/
int Vect_get_isle_area(const struct Map_info *Map, int isle)
int Vect_get_isle_area(struct Map_info *Map, int isle)
{
const struct Plus_head *Plus;
struct P_isle *Isle;
Expand All @@ -289,7 +287,7 @@ int Vect_get_isle_area(const struct Map_info *Map, int isle)
\return perimeter of area with perimeters of isles in meters
*/

double Vect_get_area_perimeter(const struct Map_info *Map, int area)
double Vect_get_area_perimeter(struct Map_info *Map, int area)
{
const struct Plus_head *Plus;
struct P_area *Area;
Expand Down Expand Up @@ -333,7 +331,7 @@ double Vect_get_area_perimeter(const struct Map_info *Map, int area)
\return 1 if point is inside area
\return 2 if point is on the area's outer ring
*/
int Vect_point_in_area(double x, double y, const struct Map_info *Map, int area,
int Vect_point_in_area(double x, double y, struct Map_info *Map, int area,
struct bound_box *box)
{
int i, isle;
Expand Down Expand Up @@ -374,7 +372,7 @@ int Vect_point_in_area(double x, double y, const struct Map_info *Map, int area,
\return area of area without areas of isles
*/
double Vect_get_area_area(const struct Map_info *Map, int area)
double Vect_get_area_area(struct Map_info *Map, int area)
{
const struct Plus_head *Plus;
struct P_area *Area;
Expand Down Expand Up @@ -422,8 +420,7 @@ double Vect_get_area_area(const struct Map_info *Map, int area)
\return 0 centroid found (but may be without categories)
\return 1 no centroid found
*/
int Vect_get_area_cats(const struct Map_info *Map, int area,
struct line_cats *Cats)
int Vect_get_area_cats(struct Map_info *Map, int area, struct line_cats *Cats)
{
int centroid;

Expand All @@ -450,7 +447,7 @@ int Vect_get_area_cats(const struct Map_info *Map, int area,
\return first found category of given field
\return -1 no centroid or no category found
*/
int Vect_get_area_cat(const struct Map_info *Map, int area, int field)
int Vect_get_area_cat(struct Map_info *Map, int area, int field)
{
int i;
static struct line_cats *Cats = NULL;
Expand Down Expand Up @@ -487,7 +484,7 @@ int Vect_get_area_cat(const struct Map_info *Map, int area, int field)
\return number of points
\return -1 on error
*/
int Vect__get_area_points(const struct Map_info *Map, const plus_t *lines,
int Vect__get_area_points(struct Map_info *Map, const plus_t *lines,
int n_lines, struct line_pnts *BPoints)
{
if (Map->format == GV_FORMAT_POSTGIS && Map->fInfo.pg.toposchema_name &&
Expand Down Expand Up @@ -516,7 +513,7 @@ int Vect__get_area_points(const struct Map_info *Map, const plus_t *lines,
\return number of points
\return -1 on error
*/
int Vect__get_area_points_nat(const struct Map_info *Map, const plus_t *lines,
int Vect__get_area_points_nat(struct Map_info *Map, const plus_t *lines,
int n_lines, struct line_pnts *BPoints)
{
int i, line, aline, dir;
Expand Down
2 changes: 1 addition & 1 deletion lib/vector/Vlib/area_pg.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static PGresult *build_stmt(const struct Plus_head *,
\return number of points
\return -1 on error
*/
int Vect__get_area_points_pg(const struct Map_info *Map, const plus_t *lines,
int Vect__get_area_points_pg(struct Map_info *Map, const plus_t *lines,
int n_lines, struct line_pnts *APoints)
{
int i, direction;
Expand Down
9 changes: 4 additions & 5 deletions lib/vector/Vlib/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct varray *Vect_new_varray(int size)
\return number of items set
\return -1 on error
*/
int Vect_set_varray_from_cat_string(const struct Map_info *Map, int field,
int Vect_set_varray_from_cat_string(struct Map_info *Map, int field,
const char *cstring, int type, int value,
struct varray *varray)
{
Expand Down Expand Up @@ -121,7 +121,7 @@ int Vect_set_varray_from_cat_string(const struct Map_info *Map, int field,
\return number of items set
\return -1 on error
*/
int Vect_set_varray_from_cat_list(const struct Map_info *Map, int field,
int Vect_set_varray_from_cat_list(struct Map_info *Map, int field,
struct cat_list *clist, int type, int value,
struct varray *varray)
{
Expand Down Expand Up @@ -239,9 +239,8 @@ static int in_array(int *cats, size_t ncats, int cat)
\return number of items set
\return -1 on error
*/
int Vect_set_varray_from_db(const struct Map_info *Map, int field,
const char *where, int type, int value,
struct varray *varray)
int Vect_set_varray_from_db(struct Map_info *Map, int field, const char *where,
int type, int value, struct varray *varray)
{
int i, n, c, centr, *cats;
int ncats;
Expand Down
11 changes: 4 additions & 7 deletions lib/vector/Vlib/box.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,7 @@ int Vect_box_clip(double *x, double *y, double *c_x, double *c_y,
\return 0 line is dead
\return -1 on error
*/
int Vect_get_line_box(const struct Map_info *Map, int line,
struct bound_box *Box)
int Vect_get_line_box(struct Map_info *Map, int line, struct bound_box *Box)
{
struct Plus_head *Plus;
struct P_line *Line;
Expand Down Expand Up @@ -298,8 +297,7 @@ int Vect_get_line_box(const struct Map_info *Map, int line,
\return 0 area is dead
\return -1 on error
*/
int Vect_get_area_box(const struct Map_info *Map, int area,
struct bound_box *Box)
int Vect_get_area_box(struct Map_info *Map, int area, struct bound_box *Box)
{
struct Plus_head *Plus;
struct P_area *Area;
Expand Down Expand Up @@ -344,8 +342,7 @@ int Vect_get_area_box(const struct Map_info *Map, int area,
\return 0 isle is dead / bounding box not found
\return -1 on error
*/
int Vect_get_isle_box(const struct Map_info *Map, int isle,
struct bound_box *Box)
int Vect_get_isle_box(struct Map_info *Map, int isle, struct bound_box *Box)
{
struct Plus_head *Plus;
struct P_isle *Isle;
Expand Down Expand Up @@ -388,7 +385,7 @@ int Vect_get_isle_box(const struct Map_info *Map, int isle,
\return 1 on success
\return 0 on error
*/
int Vect_get_map_box(const struct Map_info *Map, struct bound_box *Box)
int Vect_get_map_box(struct Map_info *Map, struct bound_box *Box)
{
const struct Plus_head *Plus;

Expand Down
8 changes: 4 additions & 4 deletions lib/vector/Vlib/buffer2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1071,10 +1071,10 @@ void Vect_line_buffer2(const struct line_pnts *Points, double da, double db,
\param[out] inner_count number of holes
\param[out] iPoints array of output polygon's holes (cw order)
*/
void Vect_area_buffer2(const struct Map_info *Map, int area, double da,
double db, double dalpha, int round, int caps,
double tol, struct line_pnts **oPoints,
struct line_pnts ***iPoints, int *inner_count)
void Vect_area_buffer2(struct Map_info *Map, int area, double da, double db,
double dalpha, int round, int caps, double tol,
struct line_pnts **oPoints, struct line_pnts ***iPoints,
int *inner_count)
{
struct line_pnts *tPoints, *outer;
struct line_pnts **isles;
Expand Down
8 changes: 4 additions & 4 deletions lib/vector/Vlib/build.c
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ int Vect_topo_check(struct Map_info *Map, struct Map_info *Err)
\return current highest built level
*/
int Vect_get_built(const struct Map_info *Map)
int Vect_get_built(struct Map_info *Map)
{
return Map->plus.built;
}
Expand Down Expand Up @@ -1051,7 +1051,7 @@ int Vect_save_topo(struct Map_info *Map)
\return 1 on success
\return 0 on error
*/
int Vect_topo_dump(const struct Map_info *Map, FILE *out)
int Vect_topo_dump(struct Map_info *Map, FILE *out)
{
int i, j, line, isle;
float angle_deg;
Expand Down Expand Up @@ -1241,7 +1241,7 @@ int Vect_build_sidx(struct Map_info *Map)
\return 1
*/
int Vect_build_sidx_from_topo(const struct Map_info *Map)
int Vect_build_sidx_from_topo(struct Map_info *Map)
{
G_debug(3, "Vect_build_sidx_from_topo(): name=%s", Vect_get_full_name(Map));

Expand Down Expand Up @@ -1312,7 +1312,7 @@ int Vect_save_sidx(struct Map_info *Map)
\return 1 on success
\return 0 on error
*/
int Vect_sidx_dump(const struct Map_info *Map, FILE *out)
int Vect_sidx_dump(struct Map_info *Map, FILE *out)
{
if (!(Map->plus.Spidx_built)) {
Vect_build_sidx_from_topo(Map);
Expand Down
2 changes: 1 addition & 1 deletion lib/vector/Vlib/build_sfa.c
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ int Vect__build_sfa(struct Map_info *Map, int build)
\return 1 on success
\return 0 on error
*/
int Vect_fidx_dump(const struct Map_info *Map, FILE *out)
int Vect_fidx_dump(struct Map_info *Map, FILE *out)
{
int i;
const struct Format_info_offset *offset;
Expand Down
Loading
Loading