Ignore:
Timestamp:
22/02/08 17:33:04 (12 years ago)
Author:
mkochan
Message:

In the middle of debugging of classes in WMSCapabilities.py.

File:
1 edited

Legend:

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

    r3505 r3506  
    11from pylab import dates     # a very good date/time module from matplotviz -- allows years < 1970 
     2from KML import * 
    23 
    34wmsXmlNamespace = 'http://www.opengis.net/wms' 
     
    4344    def toKML(self, wmsRequestConfigElement, views): 
    4445        # ignore wmsRequestConfigElement, views 
    45         kmlLayerFolder = KMLFolder(wmsLayer.name, [], opened = False, visible = False) 
    46         for childWmsLayer in wmsLayer.children: 
    47             kmlFolder.children.append( childWmsLayer.toKML() ) 
     46        kmlLayerFolder = KMLFolder(self.name, [], opened = False, visible = False) 
     47        for childWmsLayer in self.children: 
     48            kmlLayerFolder.children.append( childWmsLayer.toKML(wmsRequestConfigElement, views) ) 
    4849        return kmlLayerFolder 
    4950 
     
    148149        # ------------ 
    149150 
    150         if self.description: 
    151             layerName = self.description 
    152         else: 
    153             layerName = self.name 
    154         kmlLayerFolder = KMLFolder(layerName, [], visible = False, opened = False) 
     151        kmlLayerFolder = KMLFolder(self.name, [], visible = False, opened = False) 
    155152        for view in views: 
    156             kmlLayerFolder.append( buildLayerViewFolder(view) ) 
     153            kmlLayerFolder.children.append( buildLayerViewFolder(view) ) 
    157154        return kmlLayerFolder 
    158155     
     
    162159    in Google Earth. In particular, it defines logical transforms of time-points into time-spans. 
    163160    ''' 
     161 
     162    def __init__(self): 
     163        pass 
     164 
    164165    def getLogicalTimespan(timestep): 
    165166        ''' 
     
    205206        return timestep.replace(year=timestep.year+10) 
    206207 
     208class ViewWholeCentury(View): 
     209 
     210    def __init__(self): 
     211        self.name = 'Whole century' 
     212 
     213    def getLogicalTimespan(self, timestep): 
     214        timespanStart = _get20thCenturyDecade(timestep) 
     215        timespanEnd = _getMonthHence(timespanStart) 
     216        return (timespanStart, timespanEnd) 
     217 
     218    def getCategory(self, timestep): 
     219        return dt.isoformat() 
     220 
     221    def getCategoryName(self, timestep): 
     222        return dt.isoformat() 
     223 
    207224class ViewSplittedByMonth(View): 
     225 
     226    def __init__(self): 
     227        self.name = 'Compare months' 
     228 
    208229    def getLogicalTimespan(self, timestep): 
    209230        timespanStart = _getFirstDayOfMonth(timestep) 
     
    220241 
    221242class ViewSplittedByDecade(View): 
     243 
     244    def __init__(self): 
     245        self.name = 'Compare decades' 
     246 
    222247    def getLogicalTimespan(self, timestep): 
    223248        timespanStart = _getFirstDayOfMonth(timestep) 
     
    230255    def getCategoryName(self, category): 
    231256        return 'Decade of ' + str(self.getCategory(timestep)) 
    232  
    233 class ViewAllDecades(View): 
    234     def getLogicalTimespan(timestep): 
    235         timespanStart = _getDecadeSince(timestep, 1900) 
    236         timespanEnd = _getMonthHence(timespanStart) 
    237         return (timespanStart, timespanEnd) 
    238  
    239     def getCategory(timestep): 
    240         return dt.isoformat() 
    241  
    242     def getCategoryName(timestep): 
    243         return dt.isoformat() 
    244257 
    245258class WMSCapabilities: 
     
    267280        self.wmsRequestConfigElement = wmsRequestConfigElement 
    268281        self.baseKmlOutputDirectory = baseKmlOutputDirectory 
    269         self.maxDirDepth = 10 
     282        self.maxDirDepth = 1 
    270283        # [a:D,r:DEBUG] self.maxDirDepth = self.config(...)  
    271284         
     
    273286 
    274287        def _convertToKML(wmsLayer): 
    275             views = [ViewAllDecades, ViewSplittedByMonth, ViewSplittedByDecade] 
    276             return wmsLayer.toKML(wmsRequestConfigElement, views) 
     288            views = [ViewWholeCentury(), ViewSplittedByMonth(), ViewSplittedByDecade()] 
     289            return wmsLayer.toKML(self.wmsRequestConfigElement, views) 
    277290         
    278291        def _convertToDirectory(wmsLayer, parentDir, currentLevel): 
     
    287300            elif currentLevel == self.maxDirDepth: 
    288301                # Create a KML document with no styles 
    289                 ###kmlDocument = KMLDocument(wmsLayer.name, [])   # [?] dir name?? 
    290                 ###kmlDocument.elements.append(_convertToKML(wmsLayer)) 
     302                kmlDocument = KMLDocument(wmsLayer.name, [])  
     303                kmlDocument.elements.append( _convertToKML(wmsLayer) ) 
    291304                filename = parentDir + '/' + wmsLayer.name + '.kml' 
    292                 ###kmlDocument.save(filename) 
     305                kmlDocument.save(filename) 
    293306                print 'Saved file "%s"' % filename 
    294307            else: 
Note: See TracChangeset for help on using the changeset viewer.