Changeset 3506 for DPPP


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

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

Location:
DPPP/kml/csml2kml
Files:
3 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: 
  • DPPP/kml/csml2kml/python/csml2kml/csml2kml/tests/testWMSCapabilities.py

    r3505 r3506  
    1010 
    1111wmsCapabilities.parseXML(wmsCapabilitiesElement) 
    12 print wmsCapabilities 
    13 print 
     12###print wmsCapabilities 
     13###print 
    1414 
    1515etree2 = ElementTree() 
     
    1717wmsRequestConfigElement = etree2.getroot() 
    1818 
    19 #wmsLayersConvertor = WMSLayersConvertor(wmsCapabilities.topWmsLayer, None, '../../../../output/wms-ar4') 
    20 #wmsLayersConvertor.convert() 
     19wmsLayersConvertor = WMSLayersConvertor(wmsCapabilities.topWmsLayer, None, '../../../../output/wms-ar4') 
     20wmsLayersConvertor.convert() 
  • DPPP/kml/csml2kml/testdata/ar4.conf.xml

    r3499 r3506  
    88    <CRS>EPSG:4326</CRS> 
    99  </WMSRequest> 
    10   <View name="Whole century"> 
    11     <SplitTimeStepsBy></SplitTimeStepsBy> 
    12     <LogicalDateTimeTransform>20_CENTURY_DECADE</LogicalDateTimeTransform> 
    13     <LogicalDateTimeDelta>MONTH_HENCE</LogicalDateTimeDelta> 
    14   </View> 
    15   <View name="Compare decades"> 
    16     <SplitTimeStepsBy>year</SplitTimeStepsBy> 
    17     <CategoryNamingPattern>Decade of #VERBATIM#</CategoryNamingPattern> 
    18     <LogicalDateTimeTransform>FIRST_DAY_OF_MONTH</LogicalDateTimeTransform> 
    19     <LogicalDateTimeDelta>MONTH_HENCE</LogicalDateTimeDelta> 
    20   </View> 
    21   <View name="Compare months"> 
    22     <SplitTimeStepsBy>month</SplitTimeStepsBy> 
    23     <CategoryNamingPattern>#MONTH#</CategoryNamingPattern> 
    24     <LogicalDateTimeTransform>FIRST_DAY_OF_MONTH</LogicalDateTimeTransform> 
    25     <LogicalDateTimeDelta>DECADE_HENCE</LogicalDateTimeDelta> 
    26   </View> 
    27 </CSML2KMLConfig> 
     10</WMSLayers2KML> 
Note: See TracChangeset for help on using the changeset viewer.