def get_layers(self, field_type):
        """Return layers in this WMS."""
        # Mock OWSLib
        openURL = wms_utils.owslib.wms.openURL
        wms_utils.owslib.wms.openURL = openURL_mock(self.path_info,
                                                    self.handler)
        # Get layers
        layers = wms_utils.get_layers(self.url)
        # Remove coordinate layers (assumed to contain 'EPSG')
        layers = [layer for layer in layers if layer.find('EPSG') == -1]
        # Identify vector fields (currently hardcoded names)
        # and reconstruct layer list based on these
        if field_type == 'vector':
            vlayers = []
            vectors = {
                'u': 'v',
                'u10': 'v10',
                'u_velocity': 'v_velocity',
                'uu': 'vv',
                'U10M': 'V10M'
            }
            for layer in layers:
                if layer in vectors:
                    vlayers.append('%s:%s' % (layer, vectors[layer]))
            layers = vlayers

        # Restore mocked object
        wms_utils.owslib.wms.openURL = openURL
        return layers
Beispiel #2
0
 def get_layers(self):
     """Return layers in WMS."""
     # Mock OWSLib
     openURL = wms_utils.owslib.wms.openURL
     wms_utils.owslib.wms.openURL = openURL_mock(self.path_info, self.handler)
     # Get layers
     layers = wms_utils.get_layers(self.url)
     # Restore mocked object
     wms_utils.owslib.wms.openURL = openURL
     return layers