Skip to content

Commit

Permalink
Merge branch 'main' into ci_ubuntu-22.04_image
Browse files Browse the repository at this point in the history
  • Loading branch information
neteler authored Jan 7, 2023
2 parents 62a07f8 + 33f8333 commit 85a3d71
Show file tree
Hide file tree
Showing 24 changed files with 607 additions and 200 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
- name: Build
env:
# TODO: -pedantic-errors here won't go through ./configure (with GNU C)
CFLAGS: "-std=${{ matrix.c }} -fPIC -Wall -Wno-error=maybe-uninitialized"
CFLAGS: "-std=${{ matrix.c }} -fPIC -Wall"
# TODO: -pedantic-errors here won't compile
CXXFLAGS: "-std=${{ matrix.cpp }} -fPIC -Wall -Wno-error=class-memaccess"
run: .github/workflows/build_ubuntu-22.04.sh $HOME/install -Werror
87 changes: 26 additions & 61 deletions gui/wxpython/gui_core/goutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
)
from core.globalvar import CheckWxVersion, wxPythonPhoenix
from gui_core.prompt import GPromptSTC
from gui_core.wrap import Button, ClearButton, ToggleButton, StaticText, StaticBox
from gui_core.wrap import Button, ClearButton, StaticText, StaticBox
from core.settings import UserSettings


Expand Down Expand Up @@ -154,29 +154,21 @@ def __init__(
self.btnOutputSave.SetToolTip(_("Save output window content to the file"))
self.btnCmdAbort = Button(parent=self.panelProgress, id=wx.ID_STOP)
self.btnCmdAbort.SetToolTip(_("Abort running command"))
self.btnCmdProtocol = ToggleButton(
parent=self.panelOutput,
id=wx.ID_ANY,
label=_("&Log file"),
size=self.btnCmdClear.GetSize(),
)
self.btnCmdProtocol.SetToolTip(
_(
"Toggle to save list of executed commands into "
"a file; content saved when switching off."
)
self.btnCmdExportHistory = Button(parent=self.panelOutput, id=wx.ID_ANY)
self.btnCmdExportHistory.SetLabel(_("&Export history"))
self.btnCmdExportHistory.SetToolTip(
_("Export history of executed commands to a file")
)
self.cmdFileProtocol = None

if not self._gcstyle & GC_PROMPT:
self.btnCmdClear.Hide()
self.btnCmdProtocol.Hide()
self.btnCmdExportHistory.Hide()

self.btnCmdClear.Bind(wx.EVT_BUTTON, self.cmdPrompt.OnCmdErase)
self.btnOutputClear.Bind(wx.EVT_BUTTON, self.OnOutputClear)
self.btnOutputSave.Bind(wx.EVT_BUTTON, self.OnOutputSave)
self.btnCmdAbort.Bind(wx.EVT_BUTTON, self._gconsole.OnCmdAbort)
self.btnCmdProtocol.Bind(wx.EVT_TOGGLEBUTTON, self.OnCmdProtocol)
self.btnCmdExportHistory.Bind(wx.EVT_BUTTON, self.OnCmdExportHistory)

self._layout()

Expand Down Expand Up @@ -234,7 +226,7 @@ def _layout(self):
)

cmdBtnSizer.Add(
self.btnCmdProtocol,
self.btnCmdExportHistory,
proportion=1,
flag=wx.ALIGN_CENTER
| wx.ALIGN_CENTER_VERTICAL
Expand Down Expand Up @@ -473,54 +465,27 @@ def OnCmdProgress(self, event):
self.progressbar.SetValue(event.value)
event.Skip()

def CmdProtocolSave(self):
"""Save list of manually entered commands into a text log file"""
if self.cmdFileProtocol is None:
return # it should not happen

try:
with open(self.cmdFileProtocol, "a") as output:
cmds = self.cmdPrompt.GetCommands()
output.write("\n".join(cmds))
if len(cmds) > 0:
output.write("\n")
except IOError as e:
GError(
_("Unable to write file '{filePath}'.\n\nDetails: {error}").format(
filePath=self.cmdFileProtocol, error=e
)
)

self.showNotification.emit(
message=_("Command log saved to '{}'".format(self.cmdFileProtocol))
def OnCmdExportHistory(self, event):
"""Export the history of executed commands stored
in a .wxgui_history file to a selected file."""
dlg = wx.FileDialog(
self,
message=_("Save file as..."),
defaultFile="grass_cmd_log.txt",
wildcard=_("{txt} (*.txt)|*.txt|{files} (*)|*").format(
txt=_("Text files"), files=_("Files")
),
style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT,
)
self.cmdFileProtocol = None

def OnCmdProtocol(self, event=None):
"""Save commands into file"""
if not event.IsChecked():
# stop capturing commands, save list of commands to the
# protocol file
self.CmdProtocolSave()
else:
# start capturing commands
self.cmdPrompt.ClearCommands()
# ask for the file
dlg = wx.FileDialog(
self,
message=_("Save file as..."),
defaultFile="grass_cmd_log.txt",
wildcard=_("%(txt)s (*.txt)|*.txt|%(files)s (*)|*")
% {"txt": _("Text files"), "files": _("Files")},
style=wx.FD_SAVE,
)
if dlg.ShowModal() == wx.ID_OK:
self.cmdFileProtocol = dlg.GetPath()
else:
wx.CallAfter(self.btnCmdProtocol.SetValue, False)

dlg.Destroy()
if dlg.ShowModal() == wx.ID_OK:
path = dlg.GetPath()
if self.cmdPrompt.CopyHistory(path):
self.showNotification.emit(
message=_("Command history saved to '{}'".format(path))
)

dlg.Destroy()
event.Skip()

def OnCmdRun(self, event):
Expand Down
24 changes: 23 additions & 1 deletion gui/wxpython/gui_core/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import difflib
import codecs
import sys
import shutil

import wx
import wx.stc
Expand All @@ -33,7 +34,7 @@

from core import globalvar
from core import utils
from core.gcmd import EncodeString, DecodeString
from core.gcmd import EncodeString, DecodeString, GError


class GPrompt(object):
Expand Down Expand Up @@ -139,6 +140,27 @@ def _runCmd(self, cmdString):
self.OnCmdErase(None)
self.ShowStatusText("")

def CopyHistory(self, targetFile):
"""Copy history file to the target location.
Returns True if file is successfully copied."""
env = grass.gisenv()
historyFile = os.path.join(
env["GISDBASE"],
env["LOCATION_NAME"],
env["MAPSET"],
".wxgui_history",
)
try:
shutil.copyfile(historyFile, targetFile)
except (IOError, OSError) as e:
GError(
_("Unable to copy file {} to {}'.\n\nDetails: {}").format(
historyFile, targetFile, e
)
)
return False
return True

def GetCommands(self):
"""Get list of launched commands"""
return self.commands
Expand Down
4 changes: 0 additions & 4 deletions gui/wxpython/lmgr/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -2257,10 +2257,6 @@ def OnCloseWindowOrExit(self, event):

def _closeWindow(self, event):
"""Close wxGUI"""
# save command protocol if actived
if self.goutput.btnCmdProtocol.GetValue():
self.goutput.CmdProtocolSave()

if not self.currentPage:
self._auimgr.UnInit()
self.Destroy()
Expand Down
4 changes: 0 additions & 4 deletions gui/wxpython/main_window/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -2296,10 +2296,6 @@ def OnCloseWindowOrExit(self, event):

def _closeWindow(self, event):
"""Close wxGUI"""
# save command protocol if actived
if self.goutput.btnCmdProtocol.GetValue():
self.goutput.CmdProtocolSave()

if not self.currentPage:
self._auimgr.UnInit()
self.Destroy()
Expand Down
6 changes: 3 additions & 3 deletions imagery/i.ortho.photo/lib/orthophoto.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ int I_put_con_points(char *, struct Ortho_Control_Points *);
int I_convert_con_points(char *, struct Ortho_Control_Points *,
struct Ortho_Control_Points *, double[3], double[3]);
/* georef.c */
int I_compute_ref_equations(struct Ortho_Photo_Points *, double *, double *,
double *, double *);
int I_compute_ref_equations(struct Ortho_Photo_Points *, double[3], double[3],
double[3], double[3]);
/* orthoref.c */
int I_compute_ortho_equations(struct Ortho_Control_Points *,
struct Ortho_Camera_File_Ref *,
Expand All @@ -140,7 +140,7 @@ int I_put_ref_points(char *, struct Ortho_Photo_Points *);

/* cam_info.h */
int I_read_cam_info(FILE *, struct Ortho_Camera_File_Ref *);
int I_new_fid_point(struct Ortho_Camera_File_Ref *, char *, double, double);
int I_new_fid_point(struct Ortho_Camera_File_Ref *, char[30], double, double);
int I_write_cam_info(FILE *, struct Ortho_Camera_File_Ref *);
int I_get_cam_info(char *, struct Ortho_Camera_File_Ref *);
int I_put_cam_info(char *, struct Ortho_Camera_File_Ref *);
Expand Down
2 changes: 1 addition & 1 deletion imagery/i.segment/iseg.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ int open_files(struct globals *);

/* create_isegs.c */
int create_isegs(struct globals *);
void find_four_neighbors(int, int, int[][2]);
void find_four_neighbors(int, int, int[8][2]);
void find_eight_neighbors(int, int, int[8][2]);
double calculate_euclidean_similarity(struct ngbr_stats *, struct ngbr_stats *,
struct globals *);
Expand Down
2 changes: 1 addition & 1 deletion include/grass/defs/ogsf.h
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ void gsd_scale(float, float, float);
void gsd_translate(float, float, float);
void gsd_rot(float, char);
void gsd_checkwindow(int *, int *, double *, double *);
int gsd_checkpoint(float *, int *, int *, double *, double *);
int gsd_checkpoint(float[4], int[4], int[4], double[16], double[16]);
void gsd_litvert_func(float *, unsigned long, float *);
void gsd_litvert_func2(float *, unsigned long, float *);
void gsd_vert_func(float *);
Expand Down
4 changes: 2 additions & 2 deletions lib/ogsf/gpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ void gpd_obj(geosurf *gs, gvstyle *style, Point3 pt)
*/
int gpd_2dsite(geosite *gp, geosurf *gs, int do_fast)
{
float site[3], konst;
float site[4], konst;
int src, check;
geopoint *gpt;
typbuff *buf;
Expand Down Expand Up @@ -311,7 +311,7 @@ int gpd_2dsite(geosite *gp, geosurf *gs, int do_fast)
*/
int gpd_3dsite(geosite *gp, float xo, float yo, int do_fast)
{
float site[3], tz;
float site[4], tz;
int check;
geopoint *gpt;
GLdouble modelMatrix[16], projMatrix[16];
Expand Down
2 changes: 1 addition & 1 deletion lib/ogsf/gs2.c
Original file line number Diff line number Diff line change
Expand Up @@ -3282,7 +3282,7 @@ int GS_get_distance_alongsurf(int hs, float x1, float y1, float x2, float y2,
float *dist, int use_exag)
{
geosurf *gs;
float p1[2], p2[2];
Point3 p1, p2;

gs = gs_get_surf(hs);
if (gs == NULL) {
Expand Down
2 changes: 1 addition & 1 deletion raster/r.circle/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <grass/raster.h>
#include <grass/glocale.h>

static double distance(double *, double *, double, double, int);
static double distance(double[2], double[2], double, double, int);

#ifndef HUGE_VAL
#define HUGE_VAL 1.7976931348623157e+308
Expand Down
2 changes: 1 addition & 1 deletion raster/r.proj/r.proj.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ <h3>Design of r.proj</h3>
the cell based on a weighted distance average of the 4 surrounding
cells in the input map. The <b>method=bicubic</b> method determines the
new value of the cell based on a weighted distance average of the 16
surrounding cells in the input map. The <b>method=lanzcos</b> method
surrounding cells in the input map. The <b>method=lanczos</b> method
determines the new value of the cell based on a weighted distance
average of the 25 surrounding cells in the input map. Compared to
bicubic, lanczos puts a higher weight on cells close to the center and a
Expand Down
3 changes: 2 additions & 1 deletion raster/r.resamp.filter/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ MODULE_TOPDIR = ../..

PGM = r.resamp.filter

LIBES = $(RASTERLIB) $(GISLIB) $(MATHLIB)
LIBES = $(RASTERLIB) $(GISLIB) $(MATHLIB) $(OMPLIB)
DEPENDENCIES = $(RASTERDEP) $(GISDEP)
EXTRA_CFLAGS = $(OMPCFLAGS)

include $(MODULE_TOPDIR)/include/Make/Module.make

Expand Down
59 changes: 59 additions & 0 deletions raster/r.resamp.filter/benchmark/benchmark_r_resamp_filter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
"""Benchmarking of r.resamp.filter
@author Aaron Saw Min Sern
"""

from grass.exceptions import CalledModuleError
from grass.pygrass.modules import Module
from subprocess import DEVNULL

import grass.benchmark as bm


def main():
results = []

# Users can add more or modify existing reference maps
benchmark(7071, "r.resamp.filter_50M", results)
benchmark(10000, "r.resamp.filter_100M", results)
benchmark(14142, "r.resamp.filter_200M", results)
benchmark(20000, "r.resamp.filter_400M", results)

bm.nprocs_plot(results, filename="benchmark.svg")


def benchmark(size, label, results):
reference = "r_resamp_filter_reference_map"
output = "benchmark_r_resamp_filter_nprocs"

generate_map(rows=size, cols=size, fname=reference)
Module("g.region", flags="pa", s=0, n=size, w=0, e=size, res=1)
module = Module(
"r.resamp.filter",
input=reference,
filter=["gauss", "box"],
output=output,
radius=[6, 9],
memory=500,
run_=False,
stdout_=DEVNULL,
overwrite=True,
)
results.append(bm.benchmark_nprocs(module, label=label, max_nprocs=8, repeat=3))
Module("g.remove", quiet=True, flags="f", type="raster", name=reference)
Module("g.remove", quiet=True, flags="f", type="raster", name=output)


def generate_map(rows, cols, fname):
Module("g.region", flags="pa", s=0, n=rows, w=0, e=cols, res=3)
# Generate using r.random.surface if r.surf.fractal fails
try:
print("Generating reference map using r.surf.fractal...")
Module("r.surf.fractal", output=fname)
except CalledModuleError:
print("r.surf.fractal fails, using r.random.surface instead...")
Module("r.random.surface", output=fname)


if __name__ == "__main__":
main()
Loading

0 comments on commit 85a3d71

Please sign in to comment.