Changeset 3603 for DPPP


Ignore:
Timestamp:
13/03/08 17:33:01 (11 years ago)
Author:
mkochan
Message:

Finished commenting WMSLayer.py

File:
1 edited

Legend:

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

    r3600 r3603  
    8686        return str(vars(self)) 
    8787 
    88     #def parseXML(self, layerElement): 
    89     #    ''' 
    90     #    Deprecated. 
    91     #    ''' 
    92     #    raise NotImplementedError('Use the wmsLayerFactory() function instead.') 
    93  
    9488    def toKML(self, wmsRequestConfigElement, viewTypes, parentDir, parentDirUrl): 
    9589        ''' 
     
    149143 
    150144    ''' 
    151     Represents a bottom-level WMS layer (i.e. with no embedded sub-layers and a I{<wms:Dimension>} element. 
     145    Represents a bottom-level WMS layer (i.e. with no embedded sub-layers, and a I{<wms:Dimension>} element). 
    152146    @ivar name: Name of the layer 
    153147    @ivar title: Title of the layer (more human readable than name) 
     
    167161 
    168162    def _parseName(self): 
     163        ''' 
     164        Parse name of the layer I{name} element, and extract various layer parameters from it. 
     165        ''' 
    169166        mo = re.match('(.+)\:(.+)\:(.+)', self.name) 
    170167        if mo: 
     
    183180 
    184181    def getType(self): 
     182        '''@return: Layer type ("climatology" or "changes")''' 
    185183        return self._parseName()[0] 
    186184 
    187185    def getPeriod(self): 
    188         '''@return The period length (integer)''' 
     186        '''@return: The period length (int)''' 
    189187        return self._parseName()[1] 
    190188     
     
    251249    def getLogicalTimespan(self, timestep): 
    252250        ''' 
    253         Abstract method, defined in derived classes. 
    254         Translates a single time step into a time span. 
    255         @param timestep: The date step (a datetime object) 
     251        Translate a single time-step into a time-span. 
     252        @param timestep: The date/time step 
     253        @type timestep: C{pylab.dates.datetime.datetime} 
    256254        @return: The (timespanStart, timespanEnd) tuple (both are datetime objects) 
    257255        ''' 
     
    260258    def getCategory(self, timestep): 
    261259        ''' 
    262         Abstract method, implemented in derived classes. Get a category in which the timestep belongs to. 
    263         @param timestep: A timestep. 
     260        Get a category in which a timestep belongs to. 
     261        @param timestep: The timestep. 
    264262        @type timestep: C{pylab.dates.datetime.datetime} 
    265263        @return: The category in which C{timestep} belongs to 
     
    269267    def getCategoryDescription(self, category): 
    270268        ''' 
    271         Abstract method, defined in derived classes. Get a human-readable description of the category. 
     269        Get a human-readable description of a category. 
    272270        @param category: The category 
    273         @type categoty: Undefined (depends on category) 
    274         @return: A string describing the category (used for naming the category KML folder). 
     271        @type category: of undefined type, which depends on category 
     272        @return: A string describing the category (used for naming the category's KML folder, if any). 
    275273        ''' 
    276274        pass 
     
    278276    def _getSameDate(self, timestep): 
    279277        ''' 
    280         A time-step transform. 
     278        A time-step transform, used by derived classes. 
    281279        @type timestep: C{pylab.dates.datetime.datetime} 
    282280        ''' 
     
    285283    def _getFirstDayOfMonth(self, timestep): 
    286284        ''' 
    287         A time-step transform. 
     285        A time-step transform, used by derived classes. 
    288286        @type timestep: C{pylab.dates.datetime.datetime} 
    289287        ''' 
     
    292290    def _getMonthHence(self, timestep): 
    293291        ''' 
    294         A time-step transform. 
     292        A time-step transform, used by derived classes. 
    295293        @type timestep: C{pylab.dates.datetime.datetime} 
    296294        ''' 
     
    302300    def _getYearHence(self, timestep): 
    303301        ''' 
    304         A time-step transform. 
     302        A time-step transform, used by derived classes. 
    305303        @type timestep: C{pylab.dates.datetime.datetime} 
    306304        ''' 
     
    309307    def _getHalfPeriodEarlier(self, timestep): 
    310308        ''' 
    311         A time-step transform. 
     309        A time-step transform, used by derived classes. 
    312310        @type timestep: C{pylab.dates.datetime.datetime} 
    313311        @return: A timestep that is half of the viewed layer's period before C{timestep}. 
     
    317315    def _getHalfPeriodLater(self, timestep): 
    318316        ''' 
    319         A time-step transform. 
     317        A time-step transform, used by derived classes. 
    320318        @type timestep: C{pylab.dates.datetime.datetime} 
    321319        @return: A timestep that is half of the viewed layer's period after C{timestep}. 
     
    325323    def toKML(self): 
    326324        ''' 
     325        Get a KML representation of the layer C{self.layer} in this view. 
    327326        ''' 
    328327 
    329328        def buildWMSRequest(timestep): 
    330             ''' Build a WMS request ''' 
     329            ''' Build a WMS request for retrieving this timestep, using self.wmsRequestConfigElement.''' 
    331330 
    332331            # We will be using configuration for WMS request 
     
    351350 
    352351        def buildKmlGroundOverlay(timestep): 
     352            '''@return: A C{KML.KMLGroundOverlay} object representing a ground overlay for this timestep.''' 
     353 
     354            # Find the time-span which corresponds to this time-step in this view. 
    353355            (timespanStart, timespanEnd) = self.getLogicalTimespan(timestep) 
     356 
     357            # Return a ground overlay element which is valid for the given time-span and contains a dynamic hyperlink 
     358            # to the WMS service. 
    354359            return KMLGroundOverlay( 
    355360                timestep.isoformat(), 
     
    374379        categories.sort() 
    375380 
     381        # Iterate through categories, creating a special folder for each, and putting the ground overlays 
     382        # corresponding to that category into that folder. However, if creating special directories for 
     383        # individual categories is not permitted in this view (self.areCategoriesListedExplicitly() == False), 
     384        # then place the ground overlays directly into the layer view folder. 
    376385        for category in categories: 
    377386            categoryDescription = self.getCategoryDescription(category) 
     
    390399 
    391400class ViewWholeTimecourse(View): 
     401    ''' 
     402    View all periods in one contiguous animation. Layer periods are substituted with logical years 
     403    (the first period is substituted with year 1, etc.) 
     404    ''' 
    392405 
    393406    def __init__(self, layer, wmsRequestConfigElement): 
     
    401414 
    402415    def areCategoriesListedExplicitly(self): 
     416        '''@return: C{False}''' 
    403417        return False 
    404418 
    405419    def getLogicalTimespan(self, timestep): 
     420        '''@return: The date's whole month, placed into the date's logical year.''' 
    406421        category = self.getCategory(timestep) 
    407422        timespanStart = self._getFirstDayOfMonth( timestep.replace(year = category) ) 
     
    410425 
    411426    def getCategory(self, timestep): 
     427        '''@return: The logical year (the year's order in the sequence of the layer's years).''' 
    412428        try: 
    413429            return self.sortedYears.index(timestep.year) + 1 
     
    416432 
    417433    def getCategoryDescription(self, category): 
    418         '''Get a human-readable description of the category (here, return category verbatim).''' 
     434        '''@return: Return the category verbatim.''' 
    419435        return str(category) 
    420436 
    421437class ViewSplittedByMonth(View): 
     438    ''' 
     439    In each period, the selected month spreads to cover the whole period. 
     440    Note that if duration of each period is shorter than the spacing between the periods  
     441    (e.g. for some 20 year climatologies), there will be "blind spots" in the animation. 
     442    ''' 
    422443 
    423444    def __init__(self, layer, wmsRequestConfigElement): 
     
    427448 
    428449    def areCategoriesListedExplicitly(self): 
     450        '''@return: C{True}''' 
    429451        return True 
    430452 
    431453    def getLogicalTimespan(self, timestep): 
     454        '''@return: The period which C{timestep} is the center of.''' 
    432455        timespanStart = self._getHalfPeriodEarlier(timestep) 
    433456        timespanEnd = self._getHalfPeriodLater(timestep) 
     
    435458 
    436459    def getCategory(self, timestep): 
     460        '''@return: The date's month.''' 
    437461        return timestep.month 
    438462 
    439463    def getCategoryDescription(self, category): 
    440464        ''' 
    441         Get a human-readable description of the category. 
    442         For instance, for category being 2, the result is 'February'. 
     465        @type category: int 
     466        @return: The written form name of the month (for C{category} being 2, the result is 'February'). 
    443467        ''' 
    444468        if not ( isinstance(category, int) and category >= 1 and category <= 12 ): 
     
    450474 
    451475class ViewSplittedByPeriod(View): 
     476    ''' 
     477    Animate the selected period only. 
     478    The animation runs only during the period\'s central year, but actually covers the whole period. 
     479    ''' 
    452480 
    453481    def __init__(self, layer, wmsRequestConfigElement): 
     
    457485 
    458486    def areCategoriesListedExplicitly(self): 
     487        '''@return: C{True}''' 
    459488        return True 
    460489 
    461490    def getLogicalTimespan(self, timestep): 
     491        '''@return: The date's whole month.''' 
    462492        timespanStart = self._getFirstDayOfMonth(timestep) 
    463493        timespanEnd = self._getMonthHence(timespanStart) 
     
    465495 
    466496    def getCategory(self, timestep): 
     497        '''@return: The date's year.''' 
    467498        return timestep.year 
    468499 
    469500    def getCategoryDescription(self, category): 
    470501        ''' 
    471         Get a human-readable description of the category that timestep belongs to. 
    472         For instance, for 1990, the result would be 'Period of 1990'. 
     502        @type category: int 
     503        @returns: For instance, for 1990, the result would be 'Period of 1990'. 
    473504        ''' 
    474505        if not isinstance(category, int): 
     
    479510class WMSCapabilities: 
    480511 
    481     '''[DOC]''' 
     512    ''' 
     513    A representation of the I{<wms:Capabilities>} element (which gets returned from WMS GetCapability() calls). 
     514    @ivar topWmsLayer: The top layer of the WMS layer hierarchy. 
     515    @type topWmsLayer: C{WMSLayer} 
     516    ''' 
    482517 
    483518    def __init__(self): 
     519        '''Create an empty object.''' 
    484520        self.topWmsLayer = None 
    485521 
    486522    def parseXML(self, wmsCapabilitiesElement): 
     523        ''' 
     524        Parse in the I{<wms:Capabilities>} element. 
     525        @param wmsCapabilitiesElement: The element. 
     526        @type wmsCapabilitiesElement: C{cElementTree.Element} 
     527        ''' 
    487528        topLayerElement = wmsCapabilitiesElement.find('{%s}Capability/{%s}Layer' % (wmsXmlNamespace, wmsXmlNamespace)) 
    488529        self.topWmsLayer = wmsLayerFactory(topLayerElement) 
Note: See TracChangeset for help on using the changeset viewer.