|
@@ -57,6 +57,7 @@ class RPCDefs(object):
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
+
|
|
|
def _read_map_full_info(lock, conn, data):
|
|
|
"""Read full map specific metadata from the spatial database using
|
|
|
PyGRASS functions.
|
|
@@ -79,6 +80,9 @@ def _read_map_full_info(lock, conn, data):
|
|
|
finally:
|
|
|
conn.send(info)
|
|
|
|
|
|
+###############################################################################
|
|
|
+
|
|
|
+
|
|
|
def _read_raster_full_info(name, mapset):
|
|
|
"""Read raster info, history and cats using PyGRASS RasterRow
|
|
|
and return a dictionary. Colors should be supported in the
|
|
@@ -103,9 +107,22 @@ def _read_raster_full_info(name, mapset):
|
|
|
info["cats"] = list(r.cats)
|
|
|
r.close()
|
|
|
|
|
|
+ ts = libgis.TimeStamp()
|
|
|
+ check = libgis.G_read_raster_timestamp(name, mapset, byref(ts))
|
|
|
+
|
|
|
+ if check:
|
|
|
+ dates = _convert_timestamp_from_grass(ts)
|
|
|
+ info["start_time"] = dates[0]
|
|
|
+ info["end_time"] = dates[1]
|
|
|
+ if len(dates) > 2:
|
|
|
+ info["time_unit"] = dates[2]
|
|
|
+
|
|
|
return(info)
|
|
|
|
|
|
-def _read_vector_full_info(name, mapset):
|
|
|
+###############################################################################
|
|
|
+
|
|
|
+
|
|
|
+def _read_vector_full_info(name, mapset, layer = None):
|
|
|
"""Read vector info using PyGRASS VectorTopo
|
|
|
and return a dictionary. C
|
|
|
"""
|
|
@@ -144,12 +161,24 @@ def _read_vector_full_info(name, mapset):
|
|
|
if v.table is not None:
|
|
|
info["columns"] = v.table.columns
|
|
|
|
|
|
+ ts = libgis.TimeStamp()
|
|
|
+ check = libgis.G_read_vector_timestamp(name, layer, mapset, byref(ts))
|
|
|
+
|
|
|
+ if check:
|
|
|
+ dates = _convert_timestamp_from_grass(ts)
|
|
|
+ info["start_time"] = dates[0]
|
|
|
+ info["end_time"] = dates[1]
|
|
|
+ if len(dates) > 2:
|
|
|
+ info["time_unit"] = dates[2]
|
|
|
+
|
|
|
return(info)
|
|
|
|
|
|
def _fatal_error(lock, conn, data):
|
|
|
"""Calls G_fatal_error()"""
|
|
|
libgis.G_fatal_error("Fatal Error in C library server")
|
|
|
|
|
|
+###############################################################################
|
|
|
+
|
|
|
|
|
|
def _get_mapset(lock, conn, data):
|
|
|
"""Return the current mapset
|
|
@@ -163,6 +192,8 @@ def _get_mapset(lock, conn, data):
|
|
|
mapset = libgis.G_mapset()
|
|
|
conn.send(mapset)
|
|
|
|
|
|
+###############################################################################
|
|
|
+
|
|
|
|
|
|
def _get_location(lock, conn, data):
|
|
|
"""Return the current location
|
|
@@ -176,6 +207,8 @@ def _get_location(lock, conn, data):
|
|
|
location = libgis.G_location()
|
|
|
conn.send(location)
|
|
|
|
|
|
+###############################################################################
|
|
|
+
|
|
|
|
|
|
def _get_gisdbase(lock, conn, data):
|
|
|
"""Return the current gisdatabase
|
|
@@ -189,6 +222,8 @@ def _get_gisdbase(lock, conn, data):
|
|
|
gisdbase = libgis.G_gisdbase()
|
|
|
conn.send(gisdbase)
|
|
|
|
|
|
+###############################################################################
|
|
|
+
|
|
|
|
|
|
def _get_driver_name(lock, conn, data):
|
|
|
"""Return the temporal database driver of a specific mapset
|
|
@@ -280,6 +315,8 @@ def _available_mapsets(lock, conn, data):
|
|
|
finally:
|
|
|
conn.send(mapset_list)
|
|
|
|
|
|
+###############################################################################
|
|
|
+
|
|
|
|
|
|
def _has_timestamp(lock, conn, data):
|
|
|
"""Check if the file based GRASS timestamp is present and send
|
|
@@ -963,9 +1000,15 @@ class CLibrariesInterface(RPCServerBase):
|
|
|
>>> ciface.read_raster_info("test", tgis.get_current_mapset())
|
|
|
{'rows': 12, 'north': 80.0, 'min': 1, 'datatype': 'CELL', 'max': 1, 'ewres': 10.0, 'cols': 8, 'west': 0.0, 'east': 120.0, 'nsres': 10.0, 'south': 0.0}
|
|
|
|
|
|
- >>> ciface.read_raster_full_info("test", tgis.get_current_mapset()) # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
|
|
|
- {u'tbres': 1.0, ... 'title': 'test', u'south': 0.0}
|
|
|
-
|
|
|
+ >>> info = ciface.read_raster_full_info("test", tgis.get_current_mapset())
|
|
|
+ >>> info # doctest: +ELLIPSIS +NORMALIZE_WHITESPACE
|
|
|
+ {u'tbres': 1.0, ... 'keyword': 'generated by r.mapcalc',
|
|
|
+ u'bottom': 0.0, 'end_time': None, 'title': 'test', u'south': 0.0}
|
|
|
+
|
|
|
+ >>> info["start_time"]
|
|
|
+ datetime.datetime(1995, 3, 12, 10, 34, 40)
|
|
|
+ >>> info["end_time"]
|
|
|
+
|
|
|
>>> check = ciface.has_raster_timestamp("test", tgis.get_current_mapset())
|
|
|
>>> print check
|
|
|
True
|
|
@@ -1029,6 +1072,9 @@ class CLibrariesInterface(RPCServerBase):
|
|
|
0
|
|
|
>>> 'columns' in kvp
|
|
|
False
|
|
|
+ >>> kvp["start_time"]
|
|
|
+ datetime.datetime(1995, 3, 12, 10, 34, 40)
|
|
|
+ >>> kvp["end_time"]
|
|
|
|
|
|
>>> check = ciface.has_vector_timestamp("test", tgis.get_current_mapset(), None)
|
|
|
>>> print check
|