Ignore:
Timestamp:
03/04/08 14:49:13 (11 years ago)
Author:
spascoe
Message:

In progress changes to make csml2kml compatible with the HiGEM WMS (i.e. WMSs
based on the latest pylons stack). See the new config file for the WMS to
test on.

There are a couple of work arounds marked as "#!TODO" that need cleaning up.

File:
1 edited

Legend:

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

    r3717 r3743  
    1 ''' 
     1""" 
    22Classes for work with I{<wms:Layer>}'s. 
    3 ''' 
     3""" 
    44 
    55import os 
     
    3737    @type parentBBox: C{BBox} 
    3838    ''' 
    39     name = layerElement.find('{%s}Name' % wmsXmlNamespace).text 
     39    # Some layers don't have a name.  This doesn't matter for non-bottom layers. 
     40    # This is tested for below. 
     41    try: 
     42        name = layerElement.find('{%s}Name' % wmsXmlNamespace).text 
     43    except AttributeError: 
     44        name = None 
     45         
    4046    title = layerElement.find('{%s}Title' % wmsXmlNamespace).text 
    41     abstract = layerElement.find('{%s}Abstract' % wmsXmlNamespace).text 
     47    try: 
     48        abstract = layerElement.find('{%s}Abstract' % wmsXmlNamespace).text 
     49    except AttributeError: 
     50        abstract = '' 
    4251 
    4352    bboxElement = layerElement.find('{%s}BoundingBox' % wmsXmlNamespace) 
     
    5059    elif parentBBox: 
    5160        bbox = parentBBox 
     61    elif name is None: 
     62        # Non-named layers don't need a bounding box 
     63        bbox = None 
    5264    else: 
    5365        raise AttributeError('Layer has no own nor parental bounding box') 
     
    6577            if dimensionElement.get('name') == 'time': 
    6678                timesteps = map( dates.dateutil.parser.parse, dimensionElement.text.split(',') ) 
     79        if name is None: 
     80            raise AttributeError('Bottom layer has no Name element') 
    6781        return BottomWMSLayer(name, title, abstract, bbox, timesteps) 
    6882 
     
    91105 
    92106    def toKML(self, wmsRequestConfigElement, viewTypes, parentDir, parentDirUrl): 
    93         ''' 
     107        """ 
    94108        Export the non-bottom layer to KML. This creates a hierarchy of KMZ files embedded in directories. 
    95109        Each KMZ files encodes a single I{<wms:Layer>} element, as follows: 
     
    113127        @return: An object representing a I{<kml:NetworkLink>} to the uppermost-leve created KMZ file 
    114128        @rtype: C{KML.KMLNetworkLink} 
    115         ''' 
     129        """ 
    116130 
    117131        # Create an "underscored" version of the title, in which all spaces, slashes, and backslashes 
     
    341355            url = c.find('URL').text 
    342356            serviceVersion = c.find('ServiceVersion').text 
     357 
     358            # The SRS/CRS parameter depends on serviceVersion 
     359            if re.match(r'1\.3', serviceVersion): 
     360                crsParam = 'CRS' 
     361            else: 
     362                crsParam = 'SRS' 
     363                 
     364 
    343365            imageFormat = c.find('ImageFormat').text 
    344366            imageWidth = c.find('ImageWidth').text 
     
    349371            # then replace it with 'Z'. 
    350372            timestepString = timestep.isoformat() 
     373            #!TODO: This shouldn't be necessary but is needed to work with CSML WMSs at the moment 
     374            timestepString += '.0' 
    351375            timestepString = timestepString.replace('+00:00', 'Z') 
    352376 
    353             wmsRequest = '%s?request=GetMap&SERVICE=%s&FORMAT=%s&LAYERS=%s&BBOX=%s&WIDTH=%s&HEIGHT=%s&CRS=%s&TIME=%s' % (url, serviceVersion, imageFormat, self.layer.name, str(self.layer.bbox), imageWidth, imageHeight, crs, timestepString) 
     377            wmsRequest = '%s?request=GetMap&VERSION=%s&FORMAT=%s&LAYERS=%s&BBOX=%s&WIDTH=%s&HEIGHT=%s&%s=%s&TIME=%s' % (url, serviceVersion, imageFormat, self.layer.name, str(self.layer.bbox), imageWidth, imageHeight, crsParam, crs, timestepString) 
    354378 
    355379            return wmsRequest 
Note: See TracChangeset for help on using the changeset viewer.