Skip to content

Commit

Permalink
TGIS: add semantic label to list of maps (#2231)
Browse files Browse the repository at this point in the history
* add semantic label to list of maps as objects
  • Loading branch information
metzm committed Feb 25, 2022
1 parent 58e5b8e commit 31afeac
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions python/grass/temporal/abstract_space_time_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1480,18 +1480,26 @@ def get_registered_maps_as_objects(self, where=None, order="start_time", dbif=No
if row["key"] == "tgis_db_version":
db_version = int(float(row["value"]))

if db_version >= 1:
has_bt_columns = True
columns = "id,start_time,end_time, west,east,south,north,bottom,top"
else:
has_bt_columns = False
columns = "id,start_time,end_time, west,east,south,north"

rows = self.get_registered_maps(columns, where, order, dbif)
# use all columns
rows = self.get_registered_maps(None, where, order, dbif)

if rows is not None:
has_bt_columns = False
has_semantic_label = False
first_row = True
for row in rows:
if first_row:
first_row = False
# check keys in first row
# note that 'if "bottom" in row' does not work
# because row is not a dict but some db backend object
if "bottom" in row.keys() and "top" in row.keys():
has_bt_columns = True
if "semantic_label" in row.keys():
has_semantic_label = True

map = self.get_new_map_instance(row["id"])
# time
if self.is_time_absolute():
map.set_absolute_time(row["start_time"], row["end_time"])
elif self.is_time_relative():
Expand All @@ -1500,6 +1508,7 @@ def get_registered_maps_as_objects(self, where=None, order="start_time", dbif=No
row["end_time"],
self.get_relative_time_unit(),
)
# space
# The fast way
if has_bt_columns:
map.set_spatial_extent_from_values(
Expand All @@ -1514,6 +1523,14 @@ def get_registered_maps_as_objects(self, where=None, order="start_time", dbif=No
else:
map.spatial_extent.select(dbif)

# labels
if (
has_semantic_label
and row["semantic_label"] is not None
and row["semantic_label"] != "None"
):
map.metadata.set_semantic_label(row["semantic_label"])

obj_list.append(copy.copy(map))

if connection_state_changed:
Expand Down

0 comments on commit 31afeac

Please sign in to comment.