Changeset 3509 for DPPP


Ignore:
Timestamp:
25/02/08 12:52:08 (11 years ago)
Author:
mkochan
Message:

Corrected problem with wrong Zulu format in WMS and wrong category list order.

File:
1 edited

Legend:

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

    r3508 r3509  
    9393        @return: a KML.KMLFolder object representing a <kml:Folder> element with lots of <kml:GroundOverlay> 
    9494        elements, each standing for a different time segment. 
    95         [NOTE] Should replace timeStep with a timedate object? 
    96         [NOTE] Please! Use dates.datetime all around here -- the self.times are of such type! 
    9795        ''' 
    9896 
     
    112110 
    113111            bBox = '-180,-90,180,90' 
    114              
    115             wmsRequest = '%s?request=GetMap&amp;SERVICE=%s&amp;FORMAT=%s&amp;LAYERS=%s&amp;BBOX=%s&amp;WIDTH=%s&amp;HEIGHT=%s&amp;CRS=%s&TIME=%s' % (url, serviceVersion, imageFormat, layerName, bBox, imageWidth, imageHeight, crs, timestep.isoformat()) 
     112 
     113            # If the timezone is UTC (which in ISO form would look like 'yyyy-mm-ddThh:mm:ss+00:00'), 
     114            # then replace it with 'Z'. 
     115            timestepString = timestep.isoformat() 
     116            timestepString = timestepString.replace('+00:00', 'Z') 
     117 
     118            wmsRequest = '%s?request=GetMap&amp;SERVICE=%s&amp;FORMAT=%s&amp;LAYERS=%s&amp;BBOX=%s&amp;WIDTH=%s&amp;HEIGHT=%s&amp;CRS=%s&TIME=%s' % (url, serviceVersion, imageFormat, layerName, bBox, imageWidth, imageHeight, crs, timestepString) 
    116119 
    117120            return wmsRequest 
     
    143146 
    144147            for category in categories: 
    145                 categoryName = view.getCategoryDescription(timestep) 
    146                 kmlCategoryFolder = KMLFolder(categoryName, [], visible = False, opened = False) 
    147                 for timestep in dict[category]: 
     148                categoryDescription = view.getCategoryDescription(category) 
     149                categoryTimesteps = dict[category] 
     150                kmlCategoryFolder = KMLFolder(categoryDescription, [], visible = False, opened = False) 
     151                for timestep in categoryTimesteps: 
    148152                    kmlGroundOverlay = buildKmlGroundOverlay(view, timestep) 
    149153                    kmlCategoryFolder.children.append(kmlGroundOverlay) 
     
    180184        pass 
    181185 
    182     def getCategoryDescription(self, timestep): 
    183         ''' 
    184         Abstract method, defined in derived classes. 
    185         Get a human-readable description of the category that timestep belongs to. 
    186         ''' 
     186    def getCategoryDescription(self, category): 
     187        '''Abstract method, defined in derived classes. Get a human-readable description of the category.''' 
    187188        pass 
    188189 
     
    222223        return timestep.isoformat() 
    223224 
    224     def getCategoryDescription(self, timestep): 
    225         return self.getCategory(timestep) 
     225    def getCategoryDescription(self, category): 
     226        '''Get a human-readable description of the category (here, return category verbatim).''' 
     227        return category 
    226228 
    227229class ViewSplittedByMonth(View): 
     
    238240        return timestep.month 
    239241 
    240     def getCategoryDescription(self, timestep): 
    241         ''' 
    242         Get a human-readable description of the category that timestep belongs to. 
    243         For instance, for timestep being 2000-02-14T10:11:12Z (which belongs into category 2), the result is 'February'. 
    244         ''' 
     242    def getCategoryDescription(self, category): 
     243        ''' 
     244        Get a human-readable description of the category. 
     245        For instance, for category being 2, the result is 'February'. 
     246        ''' 
     247        if not ( isinstance(category, int) and category >= 1 and category <= 12 ): 
     248            raise ValueError('Category not an integer between 1 and 12.') 
     249        month = category 
    245250        monthNames = ['January', 'February', 'March', 'April', 'May', 'June',  
    246251                      'July', 'August', 'September', 'October', 'November', 'December'] 
    247         return monthNames[self.getCategory(timestep)-1] 
     252        return monthNames[month-1] 
    248253 
    249254class ViewSplittedByDecade(View): 
     
    260265        return timestep.year 
    261266 
    262     def getCategoryDescription(self, timestep): 
     267    def getCategoryDescription(self, category): 
    263268        ''' 
    264269        Get a human-readable description of the category that timestep belongs to. 
    265         For instance, for timestep being 1990-05-17T02:05:17Z, the result would be 'Decade of 1990'. 
    266         ''' 
    267         return 'Decade of ' + str(self.getCategory(timestep)) 
     270        For instance, for 1990, the result would be 'Decade of 1990'. 
     271        ''' 
     272        if not isinstance(category, int): 
     273            raise ValueError('Category not an integer (a year)') 
     274        year = category 
     275        return 'Decade of ' + str(year) 
    268276 
    269277class WMSCapabilities: 
Note: See TracChangeset for help on using the changeset viewer.