Skip to content

Commit

Permalink
Merge branch 'OSGeo:main' into issue#2187
Browse files Browse the repository at this point in the history
  • Loading branch information
ldesousa committed Sep 6, 2024
2 parents 1c96ce0 + 98f38fc commit 6fd87bc
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 22 deletions.
7 changes: 3 additions & 4 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,10 @@ per-file-ignores =
gui/wxpython/core/settings.py: E722
gui/wxpython/core/watchdog.py: E402
gui/wxpython/datacatalog/tree.py: E731, E402
gui/wxpython/dbmgr/base.py: E722, F841
gui/wxpython/dbmgr/dialogs.py: F841, E722
gui/wxpython/dbmgr/sqlbuilder.py: E722, F841
gui/wxpython/dbmgr/base.py: E722
gui/wxpython/dbmgr/dialogs.py: E722
gui/wxpython/dbmgr/sqlbuilder.py: E722
gui/wxpython/dbmgr/manager.py: E722
gui/wxpython/dbmgr/vinfo.py: F841
gui/wxpython/docs/wxgui_sphinx/conf.py: E402, W291
gui/wxpython/gcp/g.gui.gcp.py: F841
gui/wxpython/gcp/manager.py: F841, E722
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/clang-format-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
persist-credentials: false
- uses: DoozyX/clang-format-lint-action@caa179272c6ee7f1d25dfb503ee0c410c26ebd98 # v0.18.1
- uses: DoozyX/clang-format-lint-action@c71d0bf4e21876ebec3e5647491186f8797fde31 # v0.18.2
with:
source: "."
clangFormatVersion: 18.1.8
Expand Down
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@4320041ed380b20e97d388d56a7fb4f9b8c20e79 # v7.0.0
uses: peter-evans/create-pull-request@8867c4aba1b742c39f8d0ba35429c2dfa4b6cb20 # v7.0.1
with:
commit-message: "config.guess + config.sub: updated from http://git.savannah.gnu.org/cgit/config.git/plain/"
branch: periodic/update-configure
Expand Down
8 changes: 3 additions & 5 deletions gui/wxpython/dbmgr/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def LoadData(self, layer, columns=None, where=None, sql=None):

if sql:
cmdParams.update({"sql": sql, "output": outFile.name, "overwrite": True})
ret = RunCommand("db.select", **cmdParams)
RunCommand("db.select", **cmdParams)
self.sqlFilter = {"sql": sql}
else:
cmdParams.update(
Expand All @@ -246,7 +246,7 @@ def LoadData(self, layer, columns=None, where=None, sql=None):
# Enclose column name with SQL standard double quotes
cmdParams.update({"columns": ",".join([f'"{col}"' for col in columns])})

ret = RunCommand("v.db.select", **cmdParams)
RunCommand("v.db.select", **cmdParams)

# These two should probably be passed to init more cleanly
# setting the numbers of items = number of elements in the dictionary
Expand Down Expand Up @@ -296,7 +296,7 @@ def LoadData(self, layer, columns=None, where=None, sql=None):
record = (
decode(outFile.readline(), encoding=enc).strip().replace("\n", "")
)
except UnicodeDecodeError as e:
except UnicodeDecodeError:
record = (
outFile.readline()
.decode(encoding=enc, errors="replace")
Expand Down Expand Up @@ -965,7 +965,6 @@ def OnLayerPageChanged(self, event):
pass

if idCol:
winCol = self.FindWindowById(idCol)
table = self.dbMgrData["mapDBInfo"].layers[self.selLayer]["table"]
self.dbMgrData["mapDBInfo"].GetColumns(table)

Expand Down Expand Up @@ -2687,7 +2686,6 @@ def OnTableItemDelete(self, event):
tlist = self.FindWindowById(self.layerPage[self.selLayer]["tableData"])

item = tlist.GetFirstSelected()
countSelected = tlist.GetSelectedItemCount()
if UserSettings.Get(group="atm", key="askOnDeleteRec", subkey="enabled"):
# if the user select more columns to delete, all the columns name
# will appear the the warning dialog
Expand Down
1 change: 0 additions & 1 deletion gui/wxpython/dbmgr/dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ def OnReset(self, event=None):
columns = self.mapDBInfo.tables[table]
for idx in range(len(columns[key]["values"])):
for name in columns.keys():
type = columns[name]["type"]
value = columns[name]["values"][idx]
if value is None:
value = ""
Expand Down
7 changes: 0 additions & 7 deletions gui/wxpython/dbmgr/sqlbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ def _doLayout(self, modeChoices, showDbInfo=False):

def OnUniqueValues(self, event, justsample=False):
"""Get unique values"""
vals = []
try:
idx = self.list_columns.GetSelections()[0]
column = self.list_columns.GetString(idx)
Expand Down Expand Up @@ -415,12 +414,6 @@ def OnAddValue(self, event):

idx = selection[0]
value = self.list_values.GetString(idx)
idx = self.list_columns.GetSelections()[0]
column = self.list_columns.GetString(idx)

ctype = self.dbInfo.GetTableDesc(self.dbInfo.GetTable(self.layer))[column][
"type"
]

self._add(element="value", value=value)

Expand Down
3 changes: 0 additions & 3 deletions gui/wxpython/dbmgr/vinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ def SelectByPoint(self, queryCoords, qdist):
"""Get attributes by coordinates (all available layers)
Return line id or None if no line is found"""
line = None
nselected = 0

try:
data = gs.vector_what(
map=self.map,
Expand Down
4 changes: 4 additions & 0 deletions lib/raster/gdal.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ struct GDAL_link *Rast_get_gdal_link(const char *name, const char *mapset)

switch (type) {
case GDT_Byte:
/* GDT_Int8 was introduced in GDAL 3.7 */
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3, 7, 0)
case GDT_Int8:
#endif
case GDT_Int16:
case GDT_UInt16:
case GDT_Int32:
Expand Down
7 changes: 7 additions & 0 deletions lib/raster/get_row.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
\author Original author CERL
*/

#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
Expand Down Expand Up @@ -368,6 +369,12 @@ static void gdal_values_int(int fd, const unsigned char *data,
case GDT_Byte:
c[i] = *(GByte *)d;
break;
/* GDT_Int8 was introduced in GDAL 3.7 */
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3, 7, 0)
case GDT_Int8:
c[i] = *(int8_t *)d;
break;
#endif
case GDT_Int16:
c[i] = *(GInt16 *)d;
break;
Expand Down
8 changes: 8 additions & 0 deletions raster/r.external/link.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ void query_band(GDALRasterBandH hBand, const char *output,
cellhd->format = 0;
break;

/* GDT_Int8 was introduced in GDAL 3.7 */
#if GDAL_VERSION_NUM >= GDAL_COMPUTE_VERSION(3, 7, 0)
case GDT_Int8:
info->data_type = CELL_TYPE;
cellhd->format = 1;
break;
#endif

case GDT_Int16:
case GDT_UInt16:
info->data_type = CELL_TYPE;
Expand Down
Binary file added raster/r.in.gdal/testsuite/data/int8.tif
Binary file not shown.
20 changes: 20 additions & 0 deletions raster/r.in.gdal/testsuite/data/int8.vrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<VRTDataset rasterXSize="24" rasterYSize="24">
<SRS dataAxisToSRSAxisMapping="1,2">PROJCS["NAD83(HARN) / North Carolina",GEOGCS["NAD83(HARN)",DATUM["NAD83_High_Accuracy_Reference_Network",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6152"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4152"]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["latitude_of_origin",33.75],PARAMETER["central_meridian",-79],PARAMETER["standard_parallel_1",36.1666666666667],PARAMETER["standard_parallel_2",34.3333333333333],PARAMETER["false_easting",609601.22],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","3358"]]</SRS>
<GeoTransform> 0.0000000000000000e+00, 1.0000000000000000e+00, 0.0000000000000000e+00, 2.4000000000000000e+01, 0.0000000000000000e+00, -1.0000000000000000e+00</GeoTransform>
<Metadata>
<MDI key="AREA_OR_POINT">Area</MDI>
</Metadata>
<Metadata domain="IMAGE_STRUCTURE">
<MDI key="INTERLEAVE">BAND</MDI>
</Metadata>
<VRTRasterBand dataType="Int8" band="1">
<ColorInterp>Gray</ColorInterp>
<SimpleSource>
<SourceFilename relativeToVRT="1">./int8.tif</SourceFilename>
<SourceBand>1</SourceBand>
<SourceProperties RasterXSize="24" RasterYSize="24" DataType="Int8" BlockXSize="24" BlockYSize="24" />
<SrcRect xOff="0" yOff="0" xSize="24" ySize="24" />
<DstRect xOff="0" yOff="0" xSize="24" ySize="24" />
</SimpleSource>
</VRTRasterBand>
</VRTDataset>
42 changes: 42 additions & 0 deletions raster/r.in.gdal/testsuite/test_r_in_gdal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
@author Soeren Gebbert
"""

import unittest

from subprocess import check_output

from grass.gunittest.case import TestCase


Expand Down Expand Up @@ -306,6 +310,44 @@ def test_netCDF_3d_5(self):

self.assertLooksLike(map_list, text_from_file)

@unittest.skipIf(
tuple(
map(
int,
check_output(["gdal-config", "--version"])
.decode("UTF8")
.split(".")[0:2],
)
)
< (3, 7),
"GDAL version too old. Int8 support was introduced in GDAL 3.7",
)
def test_int8_data(self):
"""Test that Int8 VRTs are imported"""

self.assertModule(
"r.in.gdal",
input="data/int8.vrt",
output="test_gdal_import_map",
)

# Output of r.info
info_string = """north=24
south=0
east=24
west=0
nsres=1
ewres=1
rows=24
cols=24
cells=576
datatype=CELL
ncats=0"""

self.assertRasterFitsInfo(
raster="test_gdal_import_map", reference=info_string, precision=3
)


class TestGdalImportFails(TestCase):
def test_error_handling_1(self):
Expand Down

0 comments on commit 6fd87bc

Please sign in to comment.