Changeset 3557


Ignore:
Timestamp:
06/03/08 12:17:04 (11 years ago)
Author:
mkochan
Message:

Corrected bug with NetworkLink? refresh. Turned ZIP compression on.

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

Legend:

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

    r3556 r3557  
    22import sys 
    33from cElementTree import ElementTree, Element, SubElement, XML 
    4 from zipfile import ZipFile 
     4import zipfile 
    55from StringIO import StringIO 
    66 
     
    104104            buf = StringIO() 
    105105            _save(buf) 
    106             kmzFile = ZipFile(filename, 'w') 
     106            kmzFile = zipfile.ZipFile(filename, 'w', zipfile.ZIP_DEFLATED) 
    107107            kmzFile.writestr('doc.kml', buf.getvalue()) 
    108108            kmzFile.close() 
     
    336336class KMLNetworkLink(KMLElement): 
    337337 
    338     def __init__(self, name, url, visible = True): 
     338    def __init__(self, name, url, styleID = None, visible = True): 
    339339        self.name = name 
    340340        self.url = url 
    341341        self.visible = visible 
     342        self.styleID = styleID 
    342343 
    343344    def build(self): 
     
    345346 
    346347        SubElement(networkLinkElement, 'name').text = self.name 
     348 
     349        if self.styleID: 
     350            SubElement(networkLinkElement, 'styleUrl').text = '#' + self.styleID 
    347351 
    348352        if self.visible: 
     
    353357        linkElement = SubElement(networkLinkElement, 'Link') 
    354358        SubElement(linkElement, 'href').text = self.url 
     359        SubElement(linkElement, 'refreshMode').text = 'onExpire' 
    355360 
    356361        return networkLinkElement 
  • DPPP/kml/csml2kml/python/csml2kml/csml2kml/WMSCapabilities.py

    r3555 r3557  
    4646    def toKML(self, wmsRequestConfigElement, viewTypes, parentDir, parentDirUrl): 
    4747 
    48         title_ = self.title.replace(' ', '_').replace('/', '_').replace('\\', '_')  # self.title underscored 
     48        title_ = self.title.replace(' ', '_').replace('/', '_').replace('\\', '_')  # self.title "underscored" 
    4949 
    5050        dir = parentDir + '/' + title_ 
     
    5959        kmlDocument = KMLDocument(self.title, []) 
    6060        for childWmsLayer in self.children: 
    61             kmlDocument.elements.append(  
    62                 childWmsLayer.toKML(wmsRequestConfigElement, viewTypes, dir, dirUrl)  
     61            kmlDocument.elements.append( 
     62                childWmsLayer.toKML(wmsRequestConfigElement, viewTypes, dir, dirUrl) 
    6363                ) 
    6464        kmlDocument.save(filename) 
Note: See TracChangeset for help on using the changeset viewer.