Changeset 3566


Ignore:
Timestamp:
07/03/08 14:59:21 (12 years ago)
Author:
mkochan
Message:

Added bounding boxes into WMSCapabilities (if child layers don\'t have a bbox, upper layer's bounding box is used).

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

Legend:

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

    r3562 r3566  
    66wmsXmlNamespace = 'http://www.opengis.net/wms' 
    77 
    8 def wmsLayerFactory(layerElement): 
     8class BBox: 
     9    def __init__(self, west, south, east, north): 
     10        self.west = west; self.east = east 
     11        self.south = south; self.north = north 
     12    def __repr__(self): 
     13        return str(self.west) + ',' + str(self.south) + ',' + str(self.east) + ',' + str(self.north) 
     14 
     15def wmsLayerFactory(layerElement, parentBBox = None): 
    916    ''' 
    1017    [DOC] 
     
    1320    title = layerElement.find('{%s}Title' % wmsXmlNamespace).text 
    1421    abstract = layerElement.find('{%s}Abstract' % wmsXmlNamespace).text 
     22 
     23    bboxElement = layerElement.find('{%s}BoundingBox' % wmsXmlNamespace) 
     24    if not bboxElement == None: 
     25        bboxWest  = float(bboxElement.get('minx')) 
     26        bboxEast  = float(bboxElement.get('maxx')) 
     27        bboxSouth = float(bboxElement.get('miny')) 
     28        bboxNorth = float(bboxElement.get('maxy')) 
     29        bbox = BBox(bboxWest, bboxSouth, bboxEast, bboxNorth) 
     30    elif parentBBox: 
     31        bbox = parentBBox 
     32    else: 
     33        raise AttributeError('Layer has no own nor parental bounding box') 
     34         
    1535    childElements = layerElement.findall('{%s}Layer' % wmsXmlNamespace) 
    1636    childWmsLayers = [] 
    1737    for childElement in childElements: 
    18         childWmsLayer = wmsLayerFactory(childElement) 
     38        childWmsLayer = wmsLayerFactory(childElement, parentBBox = bbox) 
    1939        childWmsLayers.append(childWmsLayer) 
    2040    if childElements != []: 
    21         return WMSLayer(name, title, abstract, childWmsLayers)         
     41        return WMSLayer(name, title, abstract, bbox, childWmsLayers)         
    2242    else: 
    2343        dimensionElements = layerElement.findall('{%s}Dimension' % wmsXmlNamespace) 
     
    2545            if dimensionElement.get('name') == 'time': 
    2646                timesteps = map( dates.dateutil.parser.parse, dimensionElement.text.split(',') ) 
    27         return BottomWMSLayer(name, title, abstract, timesteps) 
     47        return BottomWMSLayer(name, title, abstract, bbox, timesteps) 
    2848 
    2949class WMSLayer: 
     
    3252    ''' 
    3353 
    34     def __init__(self, name, title, abstract, children): 
     54    def __init__(self, name, title, abstract, bbox, children): 
    3555        self.name = name 
    3656        self.title = title 
    3757        self.abstract = abstract 
     58        self.bbox = bbox 
    3859        self.children = children 
    3960 
     
    7192    '''[DOC]''' 
    7293     
    73     def __init__(self, name, title, abstract, timesteps): 
     94    def __init__(self, name, title, abstract, bbox, timesteps): 
    7495 
    7596        self.name = name 
    7697        self.title = title 
    7798        self.abstract = abstract 
     99        self.bbox = bbox 
    78100        # but no self.children 
    79101        self.timesteps = timesteps 
     
    200222            crs = c.find('CRS').text 
    201223 
    202             bBox = '-180,-90,180,90' 
    203  
    204224            # If the timezone is UTC (which in ISO form would look like 'yyyy-mm-ddThh:mm:ss+00:00'), 
    205225            # then replace it with 'Z'. 
     
    207227            timestepString = timestepString.replace('+00:00', 'Z') 
    208228 
    209             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, bBox, imageWidth, imageHeight, crs, timestepString) 
     229            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) 
    210230 
    211231            return wmsRequest 
     
    217237                buildWMSRequest(timestep), 
    218238                timespanStart, timespanEnd, 
    219                 -180, -90, 180, 90, 
     239                self.layer.bbox.west, self.layer.bbox.south, self.layer.bbox.east, self.layer.bbox.north, 
    220240                visible = False 
    221241                ) 
  • DPPP/kml/csml2kml/python/pylonsstack/pylonsstack/controllers/csmlGrapher.py

    r3558 r3566  
    152152            except NameError: 
    153153                pass  # tempFile undefined -- no need to close 
     154 
     155    def list(self): 
     156        '''Handler for generating a list of CSML features per station, with dynamic links to the plot service.''' 
     157        pass 
Note: See TracChangeset for help on using the changeset viewer.