Beispiel #1
0
 def getTimeExtents(self):
     """Get layer's temporal extent using the fields and the format defined somewhere else!"""
     startStr = self.fromTimeAttribute
     endStr = self.toTimeAttribute
     startTime = time_util.str_to_datetime(startStr, self.getTimeFormat())
     endTime = time_util.str_to_datetime(endStr, self.getTimeFormat())
     # apply offset
     startTime += timedelta(seconds=self.offset)
     endTime += timedelta(seconds=self.offset)
     return (startTime, endTime)
 def getTimeExtents(self):
     """Get layer's temporal extent using the fields and the format defined somewhere else!"""
     startStr = self.fromTimeAttribute
     endStr = self.toTimeAttribute
     startTime = time_util.str_to_datetime(startStr, self.getTimeFormat())
     endTime = time_util.str_to_datetime(endStr, self.getTimeFormat())
     # apply offset
     startTime += timedelta(seconds=self.offset)
     endTime += timedelta(seconds=self.offset)
     return (startTime, endTime)
    def setTimeRestriction(self, timePosition, timeFrame):
        """Constructs the query, including the original subset"""
        if not self.timeEnabled:
            self.deleteTimeRestriction()
            return

        startTime = timePosition + timedelta(seconds=self.offset)
        endTime = timePosition + timeFrame + timedelta(seconds=self.offset)
        layerStartTime = time_util.str_to_datetime(self.fromTimeAttribute, self.getTimeFormat())
        layerEndTime = time_util.str_to_datetime(self.toTimeAttribute, self.getTimeFormat())
        self.hideOrShowLayer(startTime, endTime, layerStartTime, layerEndTime)
 def getTimeExtents(self):
     """
     Return temporal extent in datetime format
     using the fields and the format defined in the layer
     """
     start_str, end_str = self.getMinMaxValues()
     startTime = time_util.str_to_datetime(start_str, self.getTimeFormat())
     endTime = time_util.str_to_datetime(end_str, self.getTimeFormat())
     # apply offset
     startTime += timedelta(seconds=self.offset)
     endTime += timedelta(seconds=self.offset)
     return startTime, endTime
 def getTimeExtents(self):
     """
     Return temporal extent in datetime format
     using the fields and the format defined in the layer
     """
     start_str, end_str = self.getMinMaxValues()
     startTime = time_util.str_to_datetime(start_str, self.getTimeFormat())
     endTime = time_util.str_to_datetime(end_str, self.getTimeFormat())
     # apply offset
     startTime += timedelta(seconds=self.offset)
     endTime += timedelta(seconds=self.offset)
     return startTime, endTime
Beispiel #6
0
    def setTimeRestriction(self, timePosition, timeFrame):
        """Constructs the query, including the original subset"""
        if not self.timeEnabled:
            self.deleteTimeRestriction()
            return

        startTime = timePosition + timedelta(seconds=self.offset)
        endTime = timePosition + timeFrame + timedelta(seconds=self.offset)
        layerStartTime = time_util.str_to_datetime(self.fromTimeAttribute,
                                                   self.getTimeFormat())
        layerEndTime = time_util.str_to_datetime(self.toTimeAttribute,
                                                 self.getTimeFormat())
        self.hideOrShowLayer(startTime, endTime, layerStartTime, layerEndTime)
 def findValidValues(self, fieldName, fmt):
     uniques = self.getUniques(fieldName)
     at_least_one_valid = False
     last_exc = None
     for v in uniques:
         try:
             time_util.str_to_datetime(v, fmt)
             at_least_one_valid = True
             break
         except Exception as e:
             error(traceback.format_exc(e))
             last_exc = e
             continue
     if not at_least_one_valid:
         raise Exception(last_exc)
 def findValidValues(self, fieldName, fmt):
     uniques = self.getUniques(fieldName)
     at_least_one_valid = False
     last_exc = None
     for v in uniques:
         try:
             time_util.str_to_datetime(v, fmt)
             at_least_one_valid = True
             break
         except Exception as e:
             error(traceback.format_exc(e))
             last_exc = e
             continue
     if not at_least_one_valid:
         raise Exception(last_exc)
 def findValidValues(self, fieldName, fmt):
     uniques = self.getUniques(fieldName)
     at_least_one_valid = False
     last_exception = None
     for v in uniques:
         try:
             time_util.str_to_datetime(v, fmt)
             at_least_one_valid = True
             break
         except time_util.UnsupportedFormatException as e:
             error(e)
             last_exception = e
             continue
     if not at_least_one_valid:
         raise NoValidTimestampValuesException(last_exception)
Beispiel #10
0
 def restoreTimePositionFromSettings(self, value):
     """Restore the time position from settings"""
     if value:
         dt = time_util.str_to_datetime(
             value,
             time_util.DEFAULT_FORMAT)  # this also works for integer values
         self.getTimeLayerManager().setCurrentTimePosition(dt)
 def restoreFromSaveString(self, saveString):
     """restore settings from loaded project file"""
     tdfmt = time_util.SAVE_STRING_FORMAT
     if saveString:
         saveString = str(saveString).split(conf.SAVE_DELIMITER)
         try:
             timeExtents = (time_util.str_to_datetime(saveString[0], tdfmt),
                            time_util.str_to_datetime(saveString[1], tdfmt))
         except Exception:
             try:
                 # Try converting without the fractional seconds for
                 # backward compatibility.
                 tdfmt = time_util.DEFAULT_FORMAT
                 timeExtents = (time_util.str_to_datetime(saveString[0], tdfmt),
                                time_util.str_to_datetime(saveString[1], tdfmt))
             except Exception:
                 # avoid error message for projects without
                 # time-managed layers
                 return
         self.setProjectTimeExtents(timeExtents)
         pos = time_util.str_to_datetime(saveString[2], tdfmt)
         self.setCurrentTimePosition(pos)
 def restoreFromSaveString(self, saveString):
     """restore settings from loaded project file"""
     tdfmt = time_util.SAVE_STRING_FORMAT
     if saveString:
         saveString = str(saveString).split(conf.SAVE_DELIMITER)
         try:
             timeExtents = (time_util.str_to_datetime(saveString[0], tdfmt),
                            time_util.str_to_datetime(saveString[1], tdfmt))
         except Exception:
             try:
                 # Try converting without the fractional seconds for
                 # backward compatibility.
                 tdfmt = time_util.DEFAULT_FORMAT
                 timeExtents = (time_util.str_to_datetime(
                     saveString[0],
                     tdfmt), time_util.str_to_datetime(
                         saveString[1], tdfmt))
             except Exception:
                 # avoid error message for projects without
                 # time-managed layers
                 return
         self.setProjectTimeExtents(timeExtents)
         pos = time_util.str_to_datetime(saveString[2], tdfmt)
         self.setCurrentTimePosition(pos)
 def restoreTimePositionFromSettings(self, value):
     """Restore the time position from settings"""
     if value:
         dt = time_util.str_to_datetime(value, time_util.DEFAULT_FORMAT)  # this also works for integer values
         self.getTimeLayerManager().setCurrentTimePosition(dt)
Beispiel #14
0
 def getTimeExtents(self):
     startTime, endTime = time_util.str_to_datetime(self.fromTimeAttribute, self.timeFormat), \
                          time_util.str_to_datetime(self.toTimeAttribute, self.timeFormat)
     startTime += timedelta(seconds=self.offset)
     endTime += timedelta(seconds=self.offset)
     return (startTime, endTime)
Beispiel #15
0
 def getTimeExtents(self):
     startTime, endTime = time_util.str_to_datetime(self.fromTimeAttribute, self.timeFormat), \
                          time_util.str_to_datetime(self.toTimeAttribute, self.timeFormat)
     startTime += timedelta(seconds=self.offset)
     endTime += timedelta(seconds=self.offset)
     return (startTime, endTime)