Changeset 3188


Ignore:
Timestamp:
09/01/08 10:08:32 (12 years ago)
Author:
mkochan
Message:

Prototype: Added support for customized logical year determination

File:
1 edited

Legend:

Unmodified
Added
Removed
  • DPPP/kml/csml2kml/python/kmlfeatures.py

    r3187 r3188  
    2323        self.timebounds=timebounds 
    2424         
    25     def _getLogicalTimeSpan(self, timestep): 
     25    def _getDecadeSince1900(self, year): 
     26        return (year - 1900) / 10  # get decade as a "logical" year 
     27 
     28    #--------------------------------------------------------------------------------     
     29    # _getLogicalTimeSpan() 
     30    # [UNCLEAR] Am not sure about difference between asking WMS for data at some date 
     31    #           and at midnight of that day -- which is correct? 
     32    #-------------------------------------------------------------------------------- 
     33    def _getLogicalTimeSpan(self, timestep, getLogicalYear): 
    2634        ''' Translate timestep to a timespan that cover a full month in a year corresponding to the decade (e.g. 1900s -> 0, 1980s -> 8''' 
    2735        matchObject = re.match("(\d+)\-(\d+)\-(\d+)T", timestep) 
    2836        (sYear, sMonth, sDay) = matchObject.groups() 
    29         year = (int(sYear) - 1900) / 10  # get decade ("logical" year) 
     37        year = int(sYear) 
     38        year = getLogicalYear(year) 
    3039        month = int(sMonth) 
    31         #daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] 
    32         #isLeapYear = (year % 4) == 0  # even logical years can be leap years :) 
    33         #if isLeapYear: 
    34         #    daysInMonth[1] = 29 
    3540        startDate = "%04d-%02d-%02d" % (year, month, 1) 
    3641        if month+1 <= 12: 
     
    7075            SubElement(go, 'visibility').text='0' 
    7176            timespan=SubElement(go, 'TimeSpan') 
    72             #TODO - need a method for retrieving time bounds 
    73             (startTime, endTime) = self._getLogicalTimeSpan(timestep) 
     77            #(startTime, endTime) = self._getLogicalTimeSpan(timestep, lambda x: x) 
     78            (startTime, endTime) = self._getLogicalTimeSpan(timestep, self._getDecadeSince1900) 
    7479            SubElement(timespan, 'begin').text=startTime 
    7580            SubElement(timespan, 'end').text=endTime 
Note: See TracChangeset for help on using the changeset viewer.