Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into renovate/ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
echoix committed Nov 23, 2024
2 parents 35afe4e + b4e4cb0 commit 1c33365
Show file tree
Hide file tree
Showing 12 changed files with 67 additions and 15 deletions.
15 changes: 10 additions & 5 deletions lib/vector/Vlib/dbcolumns.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const char *Vect_get_column_names_types(struct Map_info *Map, int field)
dbHandle handle;
dbString table_name;
dbTable *table;
const char **col_type_names;
char **col_type_names;
char *list;

num_dblinks = Vect_get_num_dblinks(Map);
Expand All @@ -180,16 +180,21 @@ const char *Vect_get_column_names_types(struct Map_info *Map, int field)
ncols = db_get_table_number_of_columns(table);
col_type_names = G_malloc(ncols * sizeof(char *));
for (col = 0; col < ncols; col++) {
char buf[256];
col_type_names[col] = (char *)G_calloc(256, sizeof(char));

sprintf(buf, "%s(%s)",
sprintf(col_type_names[col], "%s(%s)",
db_get_column_name(db_get_table_column(table, col)),
db_sqltype_name(
db_get_column_sqltype(db_get_table_column(table, col))));
col_type_names[col] = buf;
}
if ((list = G_str_concat(col_type_names, ncols, ",", BUFF_MAX)) == NULL)

if ((list = G_str_concat((const char **)col_type_names, ncols, ",",
BUFF_MAX)) == NULL)
list = G_store("");

for (col = 0; col < ncols; col++) {
G_free(col_type_names[col]);
}
G_free(col_type_names);
G_debug(3, "%s", list);

Expand Down
2 changes: 1 addition & 1 deletion man/build_md.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,6 @@ def get_desc(cmd):

############################################################################

man_dir = os.path.join(os.environ["MDDIR"], "source")
man_dir = os.path.join(os.environ["ARCH_DISTDIR"], "docs", "mkdocs", "source")

############################################################################
19 changes: 19 additions & 0 deletions raster/r.to.vect/areas_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ int write_area(

catNum = 1;

if (centroid_flag) {
Vect_build_partial(&Map, GV_BUILD_ATTACH_ISLES);
}

G_important_message(_("Writing areas..."));
for (i = 0, p = a_list; i < n_areas; i++, p++) {
G_percent(i, n_areas, 3);
Expand Down Expand Up @@ -327,6 +331,21 @@ int write_area(
break;
}

if (centroid_flag) {
int area, ret;

area = Vect_find_area(&Map, x, y);
if (area == 0) {
G_warning(_("No area for centroid %d"), i);
}
else {
ret = Vect_get_point_in_area(&Map, area, &x, &y);
if (ret < 0) {
G_warning(_("Unable to calculate area centroid"));
}
}
}

Vect_reset_line(points);
Vect_append_point(points, x, y, 0.0);

Expand Down
3 changes: 2 additions & 1 deletion raster/r.to.vect/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ extern int n_alloced_ptrs;

extern int
smooth_flag; /* this is 0 for no smoothing, 1 for smoothing of lines */
extern int value_flag; /* use raster values as categories */
extern int value_flag; /* use raster values as categories */
extern int centroid_flag; /* re-center centroids */

extern struct Categories RastCats;
extern int has_cats; /* Category labels available */
Expand Down
15 changes: 13 additions & 2 deletions raster/r.to.vect/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ int row_length, row_count, n_rows;
int total_areas;
int n_alloced_ptrs;

int smooth_flag; /* this is 0 for no smoothing, 1 for smoothing of lines */
int value_flag; /* use raster values as categories */
int smooth_flag; /* this is 0 for no smoothing, 1 for smoothing of lines */
int value_flag; /* use raster values as categories */
int centroid_flag; /* re-center centroids */

struct Categories RastCats;
int has_cats; /* Category labels available */
struct field_info *Fi;
Expand All @@ -66,6 +68,7 @@ int main(int argc, char *argv[])
struct GModule *module;
struct Option *in_opt, *out_opt, *feature_opt, *column_name;
struct Flag *smooth_flg, *value_flg, *z_flg, *no_topol, *notab_flg;
struct Flag *centroid_flg;
int feature, notab_flag;

G_gisinit(argv[0]);
Expand Down Expand Up @@ -115,6 +118,13 @@ int main(int argc, char *argv[])
no_topol->label = _("Do not build vector topology");
no_topol->description = _("Recommended for massive point conversion");

centroid_flg = G_define_flag();
centroid_flg->key = 'c';
centroid_flg->label =
_("Move centroids to more central locations within areas");
centroid_flg->description = _("Default: centroids are located anywhere in "
"areas, often close to boundaries");

notab_flg = G_define_standard_flag(G_FLG_V_TABLE);

if (G_parser(argc, argv))
Expand All @@ -123,6 +133,7 @@ int main(int argc, char *argv[])
feature = Vect_option_to_types(feature_opt);
smooth_flag = (smooth_flg->answer) ? SMOOTH : NO_SMOOTH;
value_flag = value_flg->answer;
centroid_flag = centroid_flg->answer;
notab_flag = notab_flg->answer;

if (z_flg->answer && (feature != GV_POINT))
Expand Down
5 changes: 5 additions & 0 deletions raster/r.to.vect/r.to.vect.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ <h3>Area conversion</h3>
input file. If the raster map contains other data (i.e., line edges,
or point data) the output may be wrong.

<p>
By default, area centroids are often located close to boundaries and not
in the middle of an area. Centroids can be more centrally located with
the <em>-c</em> flag.

<h2>EXAMPLES</h2>

The examples are based on the North Carolina sample dataset:
Expand Down
3 changes: 3 additions & 0 deletions raster/r.watershed/ram/do_cum.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ int do_cum(void)
}
}
G_free(astar_pts);
G_free(contour);
G_free(dist_to_nbr);

return 0;
}
Expand Down Expand Up @@ -632,6 +634,7 @@ int do_cum_mfd(void)

G_free(dist_to_nbr);
G_free(weight);
G_free(contour);

return 0;
}
Expand Down
2 changes: 2 additions & 0 deletions raster/r.watershed/seg/do_cum.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ int do_cum(void)
G_percent(do_points, do_points, 1); /* finish it */

seg_close(&astar_pts);
G_free(dist_to_nbr);
G_free(contour);

return 0;
}
Expand Down
3 changes: 3 additions & 0 deletions vector/v.in.ascii/points.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,9 @@ int points_to_bin(FILE *ascii, int rowlen, struct Map_info *Map,
G_free_tokens(tokens);
}
G_percent(nrows, nrows, 2);
Vect_destroy_line_struct(Points);
Vect_destroy_cats_struct(Cats);
G_free(buf);

return 0;
}
12 changes: 6 additions & 6 deletions vector/v.net.salesman/v.net.salesman.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ <h2>DESCRIPTION</h2>
<em>v.net.salesman</em> calculates the optimal route to visit nodes on a
vector network.

<p>Costs may be either line lengths, or attributes saved in a database
<p>Costs may be either line lengths or attributes saved in a database
table. These attribute values are taken as costs of whole segments, not
as costs to traverse a length unit (e.g. meter) of the segment.
For example, if the speed limit is 100 km / h, the cost to traverse a
Expand All @@ -14,16 +14,16 @@ <h2>DESCRIPTION</h2>
Supported are cost assignments for arcs,
and also different costs for both directions of a vector line.
For areas, costs will be calculated along boundary lines.

<p>The input vector needs to be prepared with <em>v.net operation=connect</em>
in order to connect points representing center nodes to the network.

<p>Points specified by category must be exactly on network nodes, and the
input vector map needs to be prepared with <em>v.net operation=connect</em>.

<p>Application of flag <b>-t</b> enables a turntable support.
This flag requires additional parameters <b>turn_layer</b> and <b>turn_cat_layer</b>
that are otherwise ignored.
The turntable allows
<p>The flag <b>-t</b> enables turntable support.
This flag requires additional parameters, <b>turn_layer</b> and <b>turn_cat_layer</b>,
that are otherwise ignored. The turntable allows
to model e.g. traffic code, where some turns may be prohibited.
This means that the input layer is expanded by
turntable with costs of every possible turn on any possible node
Expand Down Expand Up @@ -161,7 +161,7 @@ <h2>AUTHORS</h2>

<h3>TURNS SUPPORT</h3>

The turns support was implemnented as part of GRASS GIS turns cost project
The turns support was implemented as part of GRASS GIS turns cost project
at Czech Technical University in Prague, Czech Republic.<br>
Eliska Kyzlikova, Stepan Turek, Lukas Bocan and Viera Bejdova participated
in the project.
Expand Down
1 change: 1 addition & 0 deletions vector/v.net/arcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ int create_arcs(FILE *file, struct Map_info *Pnts, struct Map_info *Out,

Vect_destroy_line_struct(points);
Vect_destroy_cats_struct(cats);
Vect_destroy_line_struct(points2);

return narcs;
}
Expand Down
2 changes: 2 additions & 0 deletions vector/v.univar/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ void select_from_geometry(void)
G_debug(3, "i=%d j=%d sum = %f val=%f", i, j, sum, val);
}
}
Vect_destroy_line_struct(jPoints);
Vect_destroy_line_struct(iPoints);
}

void select_from_database(void)
Expand Down

0 comments on commit 1c33365

Please sign in to comment.