Skip to content

Commit

Permalink
added %d.%m.%Y format and increased version to 1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
anitagraser committed Nov 29, 2014
1 parent 26c1c68 commit 133a2c2
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 16 deletions.
14 changes: 13 additions & 1 deletion README.md
Expand Up @@ -24,6 +24,18 @@ Time Manager filters your datasets and displays only features with timestamps in
* YYYY/MM/DD HH:MM:SS
* YYYY/MM/DD HH:MM
* YYYY/MM/DD
* DD.MM.YYYY HH:MM:SS.ssssss
* DD.MM.YYYY HH:MM:SS
* DD.MM.YYYY HH:MM
* DD.MM.YYYY
* DD-MM-YYYY HH:MM:SS.ssssss
* DD-MM-YYYY HH:MM:SS
* DD-MM-YYYY HH:MM
* DD-MM-YYYY
* DD/MM/YYYY HH:MM:SS.ssssss
* DD/MM/YYYY HH:MM:SS
* DD/MM/YYYY HH:MM
* DD/MM/YYYY

Other formats can be added by appending to the `supportedFormats` list in `timevectorlayer.py`.

Expand Down Expand Up @@ -52,7 +64,7 @@ If you are running an **older version of QGIS**, Time Manager versions <= 0.7 re

The plug-in uses Python's datetime module for calculations. It is therefore limited to the module's functionality. This enfolds (not exhaustive):

* Dates must be according to the format mentioned above
* Dates must be according to the formats mentioned above
* Dates must accord to the Gregorian calendar
* **The range of years is limited**. The exact range of manageable years is dependent on your platform. This is due to limitations in time.mktime. (Problems have been reported with dates before 1970.)
* Limits to the size/resolution of the time frame size
Expand Down
17 changes: 16 additions & 1 deletion help.htm
Expand Up @@ -21,7 +21,22 @@ <h1>Time Manager</h1>
<li>YYYY-MM-DD HH:MM:SS </li>
<li>YYYY-MM-DD HH:MM </li>
<li>YYYY-MM-DD </li>
<li>YYYY/MM/DD HH:MM:SS</li></ul>
<li>YYYY/MM/DD HH:MM:SS.ssssss</li>
<li>YYYY/MM/DD HH:MM:SS</li>
<li>YYYY/MM/DD HH:MM</li>
<li>YYYY/MM/DD</li>
<li>DD.MM.YYYY HH:MM:SS.ssssss</li>
<li>DD.MM.YYYY HH:MM:SS</li>
<li>DD.MM.YYYY HH:MM</li>
<li>DD.MM.YYYY</li>
<li>DD-MM-YYYY HH:MM:SS.ssssss</li>
<li>DD-MM-YYYY HH:MM:SS</li>
<li>DD-MM-YYYY HH:MM</li>
<li>DD-MM-YYYY</li>
<li>DD/MM/YYYY HH:MM:SS.ssssss</li>
<li>DD/MM/YYYY HH:MM:SS</li>
<li>DD/MM/YYYY HH:MM</li>
<li>DD/MM/YYYY</li></ul>

<p>Time Manager plugin requires at least QGIS 1.7.</p>

Expand Down
7 changes: 4 additions & 3 deletions metadata.txt
@@ -1,12 +1,13 @@
[general]
name=TimeManager
description=TimeManager adds time controls to QGIS. Using these time controls, you can animate vector features based on a time attribute. There is also an experimental raster layer support. You can create animations directly in the map window and export image series.
version=1.1.3
version=1.2
qgisMinimumVersion=2.3
author=Anita Graser
email=anitagraser@gmx.at
changelog=1.1.3
- fix Add support for data type QDate #65
changelog=1.2
- added support for DD.MM.YYYY, DD/MM/YYYY, and DD-MM-YYYY formats, thanks to https://github.com/vmora
- added French translation, thanks to https://github.com/bbouteilles
tags=spatio-temporal,time,animation
icon=icon.png
experimental=True
Expand Down
28 changes: 17 additions & 11 deletions timevectorlayer.py
Expand Up @@ -29,6 +29,10 @@ def __init__(self,layer,fromTimeAttribute,toTimeAttribute,enabled=True,timeForma
"%Y/%m/%d %H:%M:%S",
"%Y/%m/%d %H:%M",
"%Y/%m/%d",
"%d.%m.%Y %H:%M:%S.%f",
"%d.%m.%Y %H:%M:%S",
"%d.%m.%Y %H:%M",
"%d.%m.%Y",
"%d-%m-%Y %H:%M:%S.%f",
"%d-%m-%Y %H:%M:%S",
"%d-%m-%Y %H:%M",
Expand Down Expand Up @@ -106,28 +110,30 @@ def setTimeRestriction(self,timePosition,timeFrame):
return
startTime = datetime.strftime(timePosition + timedelta(seconds=self.offset),self.timeFormat)
if self.toTimeAttribute != self.fromTimeAttribute:
# if an end time attribute is set for the layer, then only show features where the current time position
# falls between the feature's time from and time to attributes
endTime = startTime
"""If an end time attribute is set for the layer, then only show features where the current time position
falls between the feature's time from and time to attributes """
endTime = startTime
else:
# if no end time attribute has been set for this layer, then show features with a time attribute
# which falls somewhere between the current time position and the start position of the next frame
endTime = datetime.strftime((timePosition + timeFrame + timedelta(seconds=self.offset)),self.timeFormat)
#subsetString = "\"%s\" < '%s' AND \"%s\" >= '%s' " % ( self.fromTimeAttribute,endTime,self.toTimeAttribute,startTime)
if self.layer.dataProvider().storageType() == 'PostgreSQL database with PostGIS extension':
"""If no end time attribute has been set for this layer, then show features with a time attribute
which falls somewhere between the current time position and the start position of the next frame"""
endTime = datetime.strftime((timePosition + timeFrame + timedelta(seconds=self.offset)),self.timeFormat)
"""PostGIS has to be handled differently than OGR sources since it's not possible to get the same query
syntax to work"""
if self.layer.dataProvider().storageType() == 'PostgreSQL database with PostGIS extension':
if self.originalSubsetString == "":
subsetString = "\"%s\" < '%s' AND \"%s\" >= '%s' " % ( self.fromTimeAttribute,endTime,self.toTimeAttribute,startTime)
else:
subsetString = "%s AND \"%s\" < '%s' AND \"%s\" >= '%s' " % ( self.originalSubsetString,self.fromTimeAttribute,endTime,self.toTimeAttribute,startTime)
else:
if self.originalSubsetString == "":
subsetString = self.sqlSubsetString(startTime, endTime)
subsetString = self.constructOGRSubsetString(startTime, endTime)
else:
subsetString = "%s AND %s"%(self.originalSubsetString,self.sqlSubsetString(startTime, endTime))
subsetString = "%s AND %s"%(self.originalSubsetString,self.constructOGRSubsetString(startTime, endTime))
self.layer.setSubsetString( subsetString )
#QMessageBox.information(self.iface.mainWindow(),"Test Output",subsetString)

def sqlSubsetString(self, startTime, endTime):
def constructOGRSubsetString(self, startTime, endTime):
"""Constructs the subset query depending on which time format was detected"""
if self.timeFormat[0:2] == '%Y' and self.timeFormat[3:5] == '%m' and self.timeFormat[6:8] == '%d':
return "cast(\"%s\" as character) < '%s' AND cast(\"%s\" as character) >= '%s' " % ( self.fromTimeAttribute,endTime,self.toTimeAttribute,startTime)
elif self.timeFormat[0:2] == '%d' and self.timeFormat[3:5] == '%m' and self.timeFormat[6:8] == '%Y':
Expand Down

0 comments on commit 133a2c2

Please sign in to comment.