Skip to content

Commit

Permalink
Merge branch 'OSGeo:main' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
a0x8o authored Feb 1, 2024
2 parents 496b74b + 581f0c4 commit da35550
Show file tree
Hide file tree
Showing 18 changed files with 316 additions and 165 deletions.
1 change: 1 addition & 0 deletions .github/workflows/optional_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
folium
jupyter
PyVirtualDisplay
ipyleaflet
2 changes: 1 addition & 1 deletion .github/workflows/periodic_update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
run: git status --ignored
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # v5.0.2
uses: peter-evans/create-pull-request@b1ddad2c994a25fbc81a28b3ec0e368bb2021c50 # v6.0.0
with:
commit-message: "config.guess + config.sub: updated from http://git.savannah.gnu.org/cgit/config.git/plain/"
branch: periodic/update-configure
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/super-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@ jobs:

steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
with:
# super-linter needs the full git history to get the
# list of files that changed across commits
fetch-depth: 0
- name: Lint code base
uses: super-linter/super-linter/slim@v5.7.2
uses: super-linter/super-linter/slim@v6.0.0
env:
DEFAULT_BRANCH: main
# To report GitHub Actions status checks
Expand Down
4 changes: 2 additions & 2 deletions db/db.connect/db.connect.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ <h2>DESCRIPTION</h2>
These parameters are then taken as default values by modules so that the
user does not need to enter the parameters each time.
<p>
The default database backend in GRASS GIS 7
is <a href="grass-sqlite.html">SQLite</a>.
The default database backend in GRASS GIS
is <a href="grass-sqlite.html">SQLite</a> (since version 7).

<h2>NOTES</h2>

Expand Down
23 changes: 14 additions & 9 deletions display/d.vect.thematic/legend.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void write_into_legend_file(const char *legfile, const char *icon,
double stats_max, double *breakpoints, int nbreaks,
int size, struct color_rgb bcolor,
struct color_rgb *colors, int default_width,
int *frequencies, const char *topo)
int *frequencies, int c_type, const char *topo)
{
FILE *fd;
int i;
Expand All @@ -33,29 +33,34 @@ void write_into_legend_file(const char *legfile, const char *icon,
/* Title */
fprintf(fd, "||||||%s\n", title);

// Do not show decimal places for integers.
int n_places = c_type == DB_C_TYPE_INT ? 0 : 2;

/* First line */
if (stats_min > breakpoints[0]) {
fprintf(fd, "< %.2f|", breakpoints[0]);
fprintf(fd, "< %.*f|", n_places, breakpoints[0]);
}
else {
fprintf(fd, "%.2f - %.2f|", stats_min, breakpoints[0]);
fprintf(fd, "%.*f - %.*f|", n_places, stats_min, n_places,
breakpoints[0]);
}
fprintf(fd, "%s|%d|ps|%d:%d:%d|%d:%d:%d|%d|%s|%d\n", icon, size,
colors[0].r, colors[0].g, colors[0].b, bcolor.r, bcolor.g, bcolor.b,
default_width, topo, frequencies[0]);
/* Middle lines */
for (i = 1; i < nbreaks; i++) {
fprintf(fd, "%.2f - %.2f|%s|%d|ps|%d:%d:%d|%d:%d:%d|%d|%s|%d\n",
breakpoints[i - 1], breakpoints[i], icon, size, colors[i].r,
colors[i].g, colors[i].b, bcolor.r, bcolor.g, bcolor.b,
default_width, topo, frequencies[i]);
fprintf(fd, "%.*f - %.*f|%s|%d|ps|%d:%d:%d|%d:%d:%d|%d|%s|%d\n",
n_places, breakpoints[i - 1], n_places, breakpoints[i], icon,
size, colors[i].r, colors[i].g, colors[i].b, bcolor.r, bcolor.g,
bcolor.b, default_width, topo, frequencies[i]);
}
/* Last one */
if (stats_max < breakpoints[nbreaks - 1]) {
fprintf(fd, ">%.2f|", breakpoints[nbreaks - 1]);
fprintf(fd, ">%.*f|", n_places, breakpoints[nbreaks - 1]);
}
else {
fprintf(fd, "%.2f - %.2f|", breakpoints[nbreaks - 1], stats_max);
fprintf(fd, "%.*f - %.*f|", n_places, breakpoints[nbreaks - 1],
n_places, stats_max);
}
fprintf(fd, "%s|%d|ps|%d:%d:%d|%d:%d:%d|%d|%s|%d\n", icon, size,
colors[nbreaks].r, colors[nbreaks].g, colors[nbreaks].b, bcolor.r,
Expand Down
2 changes: 1 addition & 1 deletion display/d.vect.thematic/local_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ int display_lines(struct Map_info *, struct cat_list *, int, const char *,
/* legend.c */
void write_into_legend_file(const char *, const char *, const char *, double,
double, double *, int, int, struct color_rgb,
struct color_rgb *, int, int *, const char *);
struct color_rgb *, int, int *, int, const char *);
54 changes: 27 additions & 27 deletions display/d.vect.thematic/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -533,26 +533,26 @@ int main(int argc, char **argv)
while (TRUE) {
nfeatures = Vect_get_num_primitives(&Map, GV_POINT);
if (nfeatures > 0) {
write_into_legend_file("stdout", icon_opt->answer, title,
stats.min, stats.max, breakpoints,
nbreaks, size, bcolor, colors,
default_width, frequencies, "point");
write_into_legend_file(
"stdout", icon_opt->answer, title, stats.min, stats.max,
breakpoints, nbreaks, size, bcolor, colors, default_width,
frequencies, ctype, "point");
break;
}
nfeatures = Vect_get_num_primitives(&Map, GV_LINE);
if (nfeatures > 0) {
write_into_legend_file("stdout", icon_line_opt->answer, title,
stats.min, stats.max, breakpoints,
nbreaks, size, bcolor, colors,
default_width, frequencies, "line");
write_into_legend_file(
"stdout", icon_line_opt->answer, title, stats.min,
stats.max, breakpoints, nbreaks, size, bcolor, colors,
default_width, frequencies, ctype, "line");
break;
}
nfeatures = Vect_get_num_primitives(&Map, GV_BOUNDARY);
if (nfeatures > 0) {
write_into_legend_file("stdout", icon_area_opt->answer, title,
stats.min, stats.max, breakpoints,
nbreaks, size, bcolor, colors,
default_width, frequencies, "area");
write_into_legend_file(
"stdout", icon_area_opt->answer, title, stats.min,
stats.max, breakpoints, nbreaks, size, bcolor, colors,
default_width, frequencies, ctype, "area");
break;
}
}
Expand All @@ -564,26 +564,26 @@ int main(int argc, char **argv)
while (TRUE) {
nfeatures = Vect_get_num_primitives(&Map, GV_POINT);
if (nfeatures > 0) {
write_into_legend_file(leg_file, icon_opt->answer, title,
stats.min, stats.max, breakpoints,
nbreaks, size, bcolor, colors,
default_width, frequencies, "point");
write_into_legend_file(
leg_file, icon_opt->answer, title, stats.min, stats.max,
breakpoints, nbreaks, size, bcolor, colors, default_width,
frequencies, ctype, "point");
break;
}
nfeatures = Vect_get_num_primitives(&Map, GV_LINE);
if (nfeatures > 0) {
write_into_legend_file(leg_file, icon_line_opt->answer, title,
stats.min, stats.max, breakpoints,
nbreaks, size, bcolor, colors,
default_width, frequencies, "line");
write_into_legend_file(
leg_file, icon_line_opt->answer, title, stats.min,
stats.max, breakpoints, nbreaks, size, bcolor, colors,
default_width, frequencies, ctype, "line");
break;
}
nfeatures = Vect_get_num_primitives(&Map, GV_BOUNDARY);
if (nfeatures > 0) {
write_into_legend_file(leg_file, icon_area_opt->answer, title,
stats.min, stats.max, breakpoints,
nbreaks, size, bcolor, colors,
default_width, frequencies, "area");
write_into_legend_file(
leg_file, icon_area_opt->answer, title, stats.min,
stats.max, breakpoints, nbreaks, size, bcolor, colors,
default_width, frequencies, ctype, "area");
break;
}
}
Expand All @@ -598,23 +598,23 @@ int main(int argc, char **argv)
write_into_legend_file(
legend_file_opt->answer, icon_opt->answer, title, stats.min,
stats.max, breakpoints, nbreaks, size, bcolor, colors,
default_width, frequencies, "point");
default_width, frequencies, ctype, "point");
break;
}
nfeatures = Vect_get_num_primitives(&Map, GV_LINE);
if (nfeatures > 0) {
write_into_legend_file(
legend_file_opt->answer, icon_line_opt->answer, title,
stats.min, stats.max, breakpoints, nbreaks, size, bcolor,
colors, default_width, frequencies, "line");
colors, default_width, frequencies, ctype, "line");
break;
}
nfeatures = Vect_get_num_primitives(&Map, GV_BOUNDARY);
if (nfeatures > 0) {
write_into_legend_file(
legend_file_opt->answer, icon_area_opt->answer, title,
stats.min, stats.max, breakpoints, nbreaks, size, bcolor,
colors, default_width, frequencies, "area");
colors, default_width, frequencies, ctype, "area");
break;
}
}
Expand Down
56 changes: 44 additions & 12 deletions doc/notebooks/jupyter_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"\n",
"The _grass.jupyter_ package was initially written as part of [Google Summer of Code in 2021](https://trac.osgeo.org/grass/wiki/GSoC/2021/JupyterAndGRASS) by Caitlin Haedrich and was experimentally included in version 8.0.0. Caitlin further improved it thanks to the [GRASS Mini Grant 2022](https://trac.osgeo.org/grass/wiki/GSoC/2021/JupyterAndGRASS/MiniGrant2022). The package was officially released for the first time as part of version 8.2.0. Credits for mentoring and additional development go to Vaclav Petras, Helena Mitasova, Stefan Blumentrath, and Anna Petrasova as well as to many members of the GRASS community who provided important feedback.\n",
"\n",
"In addition to simplifying the launch of *GRASS GIS* with a dedicated _init_ function, _grass.jupyter_ has two main display classes, _Map_ and _InteractiveMap_. Using the GRASS rendering engine in the background, _Map_ creates maps as PNG images. _InteractiveMap_ displays GRASS rasters and vectors with [*folium*](http://python-visualization.github.io/folium/), a [*leaflet*](https://leafletjs.com/) library for Python. The package includes also _Map3D_ and [_TimeSeriesMap_](temporal.ipynb).\n",
"In addition to simplifying the launch of *GRASS GIS* with a dedicated _init_ function, _grass.jupyter_ has two main display classes, _Map_ and _InteractiveMap_. Using the GRASS rendering engine in the background, _Map_ creates maps as PNG images. _InteractiveMap_ displays GRASS rasters and vectors either with [*folium*](http://python-visualization.github.io/folium/), or [*ipyleaflet*](https://ipyleaflet.readthedocs.io/en/latest/), both are [*leaflet*](https://leafletjs.com/)-based libraries for Python. The package includes also _Map3D_ and [_TimeSeriesMap_](temporal.ipynb).\n",
"\n",
"This interactive notebook is available online thanks to the [Binder](https://mybinder.org) service. To run the select part (called a *cell*), hit `Shift + Enter`."
]
Expand Down Expand Up @@ -210,7 +210,7 @@
"source": [
"## Interactive Map Display\n",
"\n",
"The `InteractiveMap` class displays *GRASS GIS* rasters and vectors with [*folium*](http://python-visualization.github.io/folium/), a [*leaflet*](https://leafletjs.com/) library for *Python*."
"The `InteractiveMap` class displays *GRASS GIS* rasters and vectors with [*folium*](http://python-visualization.github.io/folium/) or [*ipyleaflet*](https://ipyleaflet.readthedocs.io/en/latest/)."
]
},
{
Expand All @@ -220,7 +220,7 @@
"outputs": [],
"source": [
"# Create Interactive Map\n",
"raleigh_map = gj.InteractiveMap(width = 600)"
"raleigh_map = gj.InteractiveMap(width=600)"
]
},
{
Expand All @@ -232,7 +232,7 @@
"# Add raster, vector and layer control to map\n",
"raleigh_map.add_raster(\"elevation\")\n",
"raleigh_map.add_vector(\"roadsmajor\")\n",
"raleigh_map.add_layer_control(position = \"bottomright\")"
"raleigh_map.add_layer_control(position=\"bottomright\")"
]
},
{
Expand Down Expand Up @@ -279,11 +279,9 @@
"source": [
"import folium \n",
"\n",
"# Create figure\n",
"fig = folium.Figure(width=600, height=400)\n",
"\n",
"# Create a map to add to the figure later\n",
"m = folium.Map(tiles=\"Stamen Terrain\", location=[35.761168,-78.668271], zoom_start=13)\n",
"# Create a map\n",
"m = folium.Map(location=[35.761168,-78.668271], zoom_start=13)\n",
"\n",
"# Create and add elevation layer to map\n",
"gj.Raster(\"elevation\", opacity=0.5).add_to(m)\n",
Expand All @@ -296,11 +294,45 @@
" [35.781608,-78.675800], popup=\"<i>Point of Interest</i>\", tooltip=tooltip\n",
").add_to(m)\n",
"\n",
"# Add the map to the figure\n",
"fig.add_child(m)\n",
"# Display map\n",
"m"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## GRASS-ipyleaflet Integration\n",
"\n",
"We can also pass GRASS rasters and vectors directly to ipyleaflet with the Raster and Vector classes. This provides much more flexibility when creating maps since we can access all of ipyleaflet's capabilities."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import ipyleaflet \n",
"\n",
"# Create map\n",
"m = ipyleaflet.Map(center=[35.761168,-78.668271], zoom=13)\n",
"\n",
"# Create and add elevation layer to map\n",
"gj.Raster(\"elevation\", opacity=0.5).add_to(m)\n",
"\n",
"# Do some cool ipyleaflet stuff!\n",
"# Like make a tooltip\n",
"title = \"Click me!\"\n",
"# and add a marker\n",
"marker = ipyleaflet.Marker(name='marker', location=(35.781608,-78.675800), title=title)\n",
"\n",
"# Add the marker to the map\n",
"m.add(marker)\n",
"\n",
"# Display figure\n",
"fig"
"control = ipyleaflet.LayersControl(position='topright')\n",
"m.add(control)\n",
"m"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions gui/wxpython/gmodeler/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ def Run(self, log, onDone, parent=None):
# split condition
# TODO: this part needs some better solution
condVar, condText = map(
lambda x: x.strip(), re.split("\s* in \s*", cond)
lambda x: x.strip(), re.split(r"\s* in \s*", cond)
)
pattern = re.compile("%" + condVar)
# for vars()[condVar] in eval(condText): ?
Expand Down Expand Up @@ -2578,7 +2578,7 @@ def _writeItem(self, item, ignoreBlock=True, variables={}):
cond = pattern.sub(value, cond)
if isinstance(item, ModelLoop):
condVar, condText = map(
lambda x: x.strip(), re.split("\s* in \s*", cond)
lambda x: x.strip(), re.split(r"\s* in \s*", cond)
)
cond = "%sfor %s in " % (" " * self.indent, condVar)
if condText[0] == "`" and condText[-1] == "`":
Expand Down Expand Up @@ -3362,7 +3362,7 @@ def _substituteVariable(self, string, variable, data):
:return: modified string
"""
result = ""
ss = re.split("\w*(%" + variable + ")w*", string)
ss = re.split(r"\w*(%" + variable + ")w*", string)

if not ss[0] and not ss[-1]:
if data:
Expand Down
6 changes: 3 additions & 3 deletions gui/wxpython/modules/mcalc_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ def _getCommand(self):
if self.overwrite.IsChecked():
overwrite = " --overwrite"
seed_flag = seed = ""
if re.search(pattern="rand *\(.+\)", string=expr):
if re.search(pattern=r"rand *\(.+\)", string=expr):
if self.randomSeed.IsChecked():
seed_flag = " -s"
else:
Expand Down Expand Up @@ -624,7 +624,7 @@ def _addSomething(self, what):

self.text_mcalc.SetValue(newmcalcstr)
if len(what) > 0:
match = re.search(pattern="\(.*\)", string=what)
match = re.search(pattern=r"\(.*\)", string=what)
if match:
position_offset += match.start() + 1
else:
Expand Down Expand Up @@ -665,7 +665,7 @@ def OnMCalcRun(self, event):
return

seed_flag = seed = None
if re.search(pattern="rand *\(.+\)", string=expr):
if re.search(pattern=r"rand *\(.+\)", string=expr):
if self.randomSeed.IsChecked():
seed_flag = "-s"
else:
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/web_services/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ def addlayer(layer, item):
# self.ExpandAll(self.GetRootItem())

def GetSelectedLayers(self):
"""Get selected layers/styles in LayersList
r"""Get selected layers/styles in LayersList
:return: dict with these items:
* 'name' : layer name used for request
Expand Down
2 changes: 1 addition & 1 deletion python/grass/gunittest/gmodules.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


class SimpleModule(Module):
"""Simple wrapper around pygrass.modules.Module to make sure that
r"""Simple wrapper around pygrass.modules.Module to make sure that
run\_, finish\_, stdout and stderr are set correctly.
>>> mapcalc = SimpleModule('r.mapcalc', expression='test_a = 1',
Expand Down
Loading

0 comments on commit da35550

Please sign in to comment.