Changeset 3762


Ignore:
Timestamp:
04/04/08 15:40:46 (11 years ago)
Author:
mkochan
Message:

Added two new view classes, ViewSimpleMonthly? and ViewSimpleYearly?, in WMSLayer.py. Changed higem.wms2kml.conf.xml to use the view ViewSimpleYearly?.

Location:
DPPP/kml/python/csml2kml/csml2kml
Files:
3 edited

Legend:

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

    r3757 r3762  
    309309        return timestep.replace(day=1) 
    310310 
     311    def _getFirstDayOfYear(self, timestep): 
     312        ''' 
     313        A time-step transform, used by derived classes. 
     314        @type timestep: C{matplotlib.dates.datetime.datetime} 
     315        ''' 
     316        return timestep.replace(day=1, month=1) 
     317 
    311318    def _getMonthHence(self, timestep): 
    312319        ''' 
     
    535542        return 'Period of ' + str(year) 
    536543 
     544class ViewSimpleYearly(View): 
     545    ''' 
     546    Assign each timestep a timespan that spans the whole year it is in. 
     547    Allow a continuous animation with no explicit categories. 
     548    ''' 
     549     
     550    def __init__(self, layer, wmsRequestConfigElement): 
     551        View.__init__(self, layer, wmsRequestConfigElement) 
     552        self.name = 'Year by year' 
     553        self.description = 'This view shows one sample per each year.' 
     554 
     555    def areCategoriesListedExplicitly(self): 
     556        '''@return: C{False}''' 
     557        return False 
     558 
     559    def getLogicalTimespan(self, timestep): 
     560        '''@return: The date's whole year.''' 
     561        timespanStart = self._getFirstDayOfYear(timestep) 
     562        timespanEnd = self._getYearHence(timespanStart) 
     563        return (timespanStart, timespanEnd) 
     564 
     565    def getCategory(self, timestep): 
     566        '''@return: The date's year.''' 
     567        return timestep.year 
     568 
     569    def getCategoryDescription(self, category): 
     570        ''' 
     571        @type category: int 
     572        @returns: For instance, for 1990, the result would be 'The year 1990'. 
     573        ''' 
     574        if not isinstance(category, int): 
     575            raise ValueError('Category not an integer (a year)') 
     576        year = category 
     577        return 'The year ' + str(year) 
     578 
     579class ViewSimpleMonthly(View): 
     580    ''' 
     581    Assign each timestep a timespan that spans the whole month it is in. 
     582    Allow a continuous animation with no explicit categories. 
     583    ''' 
     584     
     585    def __init__(self, layer, wmsRequestConfigElement): 
     586        View.__init__(self, layer, wmsRequestConfigElement) 
     587        self.name = 'Month by month' 
     588        self.description = 'This view shows one sample per each month.' 
     589 
     590    def areCategoriesListedExplicitly(self): 
     591        '''@return: C{False}''' 
     592        return False 
     593 
     594    def getLogicalTimespan(self, timestep): 
     595        '''@return: The date's whole month.''' 
     596        timespanStart = self._getFirstDayOfMonth(timestep) 
     597        timespanEnd = self._getMonthHence(timespanStart) 
     598        return (timespanStart, timespanEnd) 
     599 
     600    def getCategory(self, timestep): 
     601        ''' 
     602        @return: The date's year followed by month (eg July of the year 815 would be "081507"). 
     603        doesn't really matter as categories are not listed in this view. 
     604        @rtype: C{str} 
     605        ''' 
     606        return '%04d%02d' % (timestep.year, timestep.month) 
     607 
     608    def getCategoryDescription(self, category): 
     609        ''' 
     610        @type category: str 
     611        @returns: Returns the category verbatim. 
     612        ''' 
     613        if not isinstance(category, str): 
     614            raise ValueError('Category not a string') 
     615        return category 
     616 
    537617class WMSCapabilities: 
    538618 
  • DPPP/kml/python/csml2kml/csml2kml/config/higem.wms2kml.conf.xml

    r3743 r3762  
    88    <CRS>EPSG:4326</CRS> 
    99  </WMSRequest> 
    10   <OutputRootDirectory>/home/users/mkochan/svn-root/kml/kml-output/</OutputRootDirectory> 
    11   <ServerRootDirectory>http://superglue.badc.rl.ac.uk:8084</ServerRootDirectory> 
     10  <Views> 
     11    <View>ViewSimpleYearly</View> 
     12  </Views> 
     13  <OutputRootDirectory>/home/users/mkochan/svn-root/kml/kml-output/wms-higem</OutputRootDirectory> 
     14  <ServerRootDirectory>http://superglue.badc.rl.ac.uk:8082</ServerRootDirectory> 
    1215</WMSLayers2KML> 
  • DPPP/kml/python/csml2kml/csml2kml/scripts

    • Property svn:ignore set to
      *.pyc
Note: See TracChangeset for help on using the changeset viewer.