Exemplo n.º 1
0
        def __init__(self):
            BaseWMSFactory.__init__(self)

            layer = mapnik.Layer('TOP', modis_srs)
            layer.datasource = mapnik.Gdal(file=str(data),band=1) 
            layer.title = "Modis VI Layer"
            layer.queryable = True
            layer.wms_srs = None
            style = mapnik.Style()
            rule = mapnik.Rule()
            sym = mapnik.RasterSymbolizer()
            sym.colorizer = mapnik.RasterColorizer(mapnik.COLORIZER_DISCRETE, mapnik.Color("transparent"))
            scale = getModisScale(product)
            for color in scale:
                sym.colorizer.add_stop(color['stop'], mapnik.Color(*color['color']))
            rule.symbols.append(sym)
            style.rules.append(rule)
            self.register_style('modis_style', style)
            self.register_layer(layer, "modis_style",("modis_style",))

            layer = mapnik.Layer('ocean_mask')
            layer.datasource = mapnik.Shapefile(file=str("/data/health/data1/web/data/shapes/50m_ocean.shp"))
            layer.queryable = True
            layer.wms_srs = None
            style = mapnik.Style()
            rule = mapnik.Rule()
            poly_sym = mapnik.PolygonSymbolizer(mapnik.Color('#50649B'))
            rule.symbols.append(poly_sym)
            style.rules.append(rule)
            self.register_style('mask_style', style)
            self.register_layer(layer, "mask_style",("mask_style",))
Exemplo n.º 2
0
def test_encoding():
    import os
    from ogcserver.configparser import SafeConfigParser
    from ogcserver.WMS import BaseWMSFactory
    from ogcserver.wms111 import ServiceHandler as ServiceHandler111
    from ogcserver.wms130 import ServiceHandler as ServiceHandler130

    base_path, tail = os.path.split(__file__)
    file_path = os.path.join(base_path, 'mapfile_encoding.xml')
    wms = BaseWMSFactory() 
    wms.loadXML(file_path)
    wms.finalize()

    conf = SafeConfigParser()
    conf.readfp(open(os.path.join(base_path, 'ogcserver.conf')))

    wms111 = ServiceHandler111(conf, wms, "localhost")
    response = wms111.GetCapabilities({})
    # Check the response is encoded in UTF-8
    # Search for the title in the response
    if conf.get('service', 'title') not in response.content:
        raise Exception('GetCapabilities is not correctly encoded')
    
    wms130 = ServiceHandler130(conf, wms, "localhost")
    wms130.GetCapabilities({})

    return True
Exemplo n.º 3
0
        def __init__(self):
            BaseWMSFactory.__init__(self)
            for data in datas:
                name = data['name']
                title = data['long_name']      
                data = base_path+"/ecohealth/"+name+'.asc'
                
                layer = mapnik.Layer(name,"+init=epsg:4326")
                layer.datasource = mapnik.Gdal(file=str(data),band=1) 
                layer.title = title
                layer.queryable = True
                layer.wms_srs = None
                style = mapnik.Style()
                rule = mapnik.Rule()
                sym = mapnik.RasterSymbolizer()
                sym.colorizer = mapnik.RasterColorizer(mapnik.COLORIZER_LINEAR, mapnik.Color("transparent"))
                scale = getEcohealthScale(name)
                for color in scale:
                    sym.colorizer.add_stop(color['stop'], mapnik.Color(*color['color']))
                rule.symbols.append(sym)
                style.rules.append(rule)

                self.register_style(name,style)
                self.register_layer(layer, name, (name,))
            self.finalize()
Exemplo n.º 4
0
 def __init__(self):
     import sys
     base_path, tail = os.path.split(__file__)
     configpath = os.path.join(base_path, 'ogcserver.conf')
     file_path = os.path.join(base_path, 'mapfile.xml')
     BaseWMSFactory.__init__(self, configpath=configpath)
     self.loadXML(file_path)
     self.finalize()
Exemplo n.º 5
0
 def __init__(self):
     import sys
     base_path, tail = os.path.split(__file__)
     configpath = os.path.join(base_path, 'ogcserver.conf')
     file_path = os.path.join(base_path, 'mapfile.xml') 
     BaseWMSFactory.__init__(self, configpath=configpath)
     self.loadXML(file_path)
     self.finalize()
Exemplo n.º 6
0
 def __init__(self):
     print('Init WMSFactory')
     BaseWMSFactory.__init__(self)
     fp = '/'.join([ROOT_DIR, 'style.xml'])
     #fp = '/home/pierre/Documents/osm.mapnik/nadine_a_velo.xml'
     try:
         print('About to load XML file: %s'%(fp,))
         self.myloadXML(fp)
     except Exception as e:
         print('ERROR loading XML[%s]: %s'%(fp,e))
         return
Exemplo n.º 7
0
 def __init__(self):
     print('Init WMSFactory')
     BaseWMSFactory.__init__(self)
     fp = '/'.join([ROOT_DIR, 'style.xml'])
     #fp = '/home/pierre/Documents/osm.mapnik/nadine_a_velo.xml'
     try:
         print('About to load XML file: %s' % (fp, ))
         self.myloadXML(fp)
     except Exception as e:
         print('ERROR loading XML[%s]: %s' % (fp, e))
         return
Exemplo n.º 8
0
 def __init__(self):
     BaseWMSFactory.__init__(self)
     sty,rl = Style(),Rule()
     poly = PolygonSymbolizer(Color('#f2eff9'))
     line = LineSymbolizer(Color('steelblue'),.1)
     rl.symbols.extend([poly,line])
     sty.rules.append(rl)
     self.register_style('world_style',sty)
     lyr = Layer('world',PROJ4_STRING)
     lyr.datasource = Shapefile(file=SHAPEFILE)
     lyr.title = 'World Borders'
     lyr.abstract = 'Country Borders of the World'
     self.register_layer(lyr,'world_style',('world_style',))
     self.finalize()
Exemplo n.º 9
0
def test_wms_capabilities():
    base_path, tail = os.path.split(__file__)
    file_path = os.path.join(base_path, 'mapfile_encoding.xml')
    wms = BaseWMSFactory()
    with open(file_path) as f:
        settings = f.read()
    wms.loadXML(xmlstring=settings, basepath=base_path)
    wms.finalize()
    
    if len(wms.layers) != 1:
        raise Exception('Incorrect number of layers')
    if len(wms.styles) != 1:
        raise Exception('Incorrect number of styles')
    
    return True
Exemplo n.º 10
0
def test_url_background_color():
    conf, services = _wms_services('mapfile_background-color.xml')

    reqparams = {
        'srs': 'EPSG:4326',
        'bbox': '-180.0000,-90.0000,180.0000,90.0000',
        'width': 800,
        'height': 600,
        'layers': '__all__',
        'styles': '',
        'format': 'image/png',
        'bgcolor': '0x00FF00',
    }

    from ogcserver.WMS import ServiceHandlerFactory
    mapfactory = BaseWMSFactory() 
    servicehandler = ServiceHandlerFactory(conf, mapfactory, '', '1.1.1')
    ogcparams = servicehandler.processParameters('GetMap', reqparams)
    ogcparams['crs'] = ogcparams['srs']
    ogcparams['HTTP_USER_AGENT'] = 'unit_tests'

    m = services['1.1.1']._buildMap(ogcparams)
    print 'wms 1.1.1 backgound color: %s' % m.background
    assert m.background == ColorFactory('rgb(0,255,0)')

    m = services['1.3.0']._buildMap(ogcparams)
    print 'wms 1.3.0 backgound color: %s' % m.background
    assert m.background == ColorFactory('rgb(0,255,0)')
Exemplo n.º 11
0
def _wms_capabilities():
    base_path, tail = os.path.split(__file__)
    file_path = os.path.join(base_path, 'mapfile_encoding.xml')
    wms = BaseWMSFactory() 
    wms.loadXML(file_path)
    wms.finalize()

    conf = SafeConfigParser()
    conf.readfp(open(os.path.join(base_path, 'ogcserver.conf')))

    wms111 = ServiceHandler111(conf, wms, "localhost")
    wms130 = ServiceHandler130(conf, wms, "localhost")

    return (conf, {
        '1.1.1': wms111.GetCapabilities({}),
        '1.3.0': wms130.GetCapabilities({})
    })
Exemplo n.º 12
0
        def __init__(self):
            BaseWMSFactory.__init__(self)
            name = "photos"
            title = "Geo-tagged photos"      
            
            select = "photos"
            select = '''(SELECT kmeans, count(*), ST_Centroid(ST_Collect(point)) AS point 
                        FROM (
                          SELECT kmeans(ARRAY[ST_X(point), ST_Y(point)], 100) OVER (), point
                          FROM photos WHERE point is not NULL
                        ) AS ksub
                        GROUP BY kmeans
                        ORDER BY kmeans) as result '''

            select = '''(SELECT kmeans, count(*), ST_ConvexHull(ST_Collect(point)) AS point 
                        FROM (
                          SELECT kmeans(ARRAY[ST_X(point), ST_Y(point)], 100) OVER (), point
                          FROM photos WHERE point is not NULL
                        ) AS ksub
                        GROUP BY kmeans
                        ORDER BY kmeans) as result '''
                        
            layer = mapnik.Layer(name,"+init=epsg:4326")
            layer.datasource = mapnik.PostGIS(host='localhost',
                                              user='******',
                                              password='******',
                                              dbname='remotesensing',
                                              table=select)
            layer.title = title
            layer.queryable = True
            layer.wms_srs = None
            style = mapnik.Style()
            rule = mapnik.Rule()
            #icon = "/web/eomf/dev/eomf/photos/circle.svg"
            sym = mapnik.PointSymbolizer()
            sym2 = mapnik.PolygonSymbolizer()
            #sym.filename = "/web/eomf/dev/eomf/photos/circle.svg"
            sym.allow_overlap = True
            sym.opacity = .5
            rule.symbols.append(sym)
            rule.symbols.append(sym2)
            style.rules.append(rule)

            self.register_style(name,style)
            self.register_layer(layer, name, (name,))
            self.finalize()
Exemplo n.º 13
0
def test_encoding():
    import os
    from ogcserver.configparser import SafeConfigParser
    from ogcserver.WMS import BaseWMSFactory
    from ogcserver.wms111 import ServiceHandler as ServiceHandler111
    from ogcserver.wms130 import ServiceHandler as ServiceHandler130

    base_path, tail = os.path.split(__file__)
    file_path = os.path.join(base_path, 'mapfile_encoding.xml')
    wms = BaseWMSFactory()
    wms.loadXML(file_path)
    wms.finalize()

    conf = SafeConfigParser()
    conf.readfp(open(os.path.join(base_path, 'ogcserver.conf')))

    wms111 = ServiceHandler111(conf, wms, "localhost")
    response = wms111.GetCapabilities({})
    # Check the response is encoded in UTF-8
    # Search for the title in the response
    if conf.get('service', 'title') not in response.content:
        raise Exception('GetCapabilities is not correctly encoded')

    wms130 = ServiceHandler130(conf, wms, "localhost")
    wms130.GetCapabilities({})

    return True
Exemplo n.º 14
0
def test_encoding():
    import os
    from ogcserver.configparser import SafeConfigParser
    from ogcserver.WMS import BaseWMSFactory
    from ogcserver.wms111 import ServiceHandler as ServiceHandler111
    from ogcserver.wms130 import ServiceHandler as ServiceHandler130

    base_path, tail = os.path.split(__file__)
    file_path = os.path.join(base_path, 'shape_encoding.xml')
    wms = BaseWMSFactory() 
    wms.loadXML(file_path)
    wms.finalize()

    conf = SafeConfigParser()
    conf.readfp(open(os.path.join(base_path, 'ogcserver.conf')))

# srs = EPSG:4326
# 3.00 , 42,35 - 3.15 , 42.51
# x = 5 , y = 6
    params = {}
    params['srs'] = 'epsg:4326'
    params['x'] = 5
    params['y'] = 5
    params['bbox'] = [3.00,42.35,3.15,42.51]
    params['height'] = 10
    params['width'] = 10
    params['layers'] = ['row']
    params['styles'] = ''
    params['query_layers'] = ['row']

    for format in ['text/plain', 'text/xml']:
        params['info_format'] = format
        wms111 = ServiceHandler111(conf, wms, "localhost")
        result = wms111.GetFeatureInfo(params)
        
        wms130 = ServiceHandler130(conf, wms, "localhost")
        wms130.GetCapabilities({})


    return True
Exemplo n.º 15
0
 def __init__(self, configpath, mapfile=None,fonts=None,home_html=None):
     conf = SafeConfigParser()
     conf.readfp(open(configpath))
     # TODO - be able to supply in config as well
     self.home_html = home_html
     self.conf = conf
     if fonts:
         mapnik.register_fonts(fonts)
     if mapfile:
         wms_factory = BaseWMSFactory(configpath)
         # TODO - add support for Cascadenik MML
         wms_factory.loadXML(mapfile)
         wms_factory.finalize()
         self.mapfactory = wms_factory
     else:
         if not conf.has_option_with_value('server', 'module'):
             raise ServerConfigurationError('The factory module is not defined in the configuration file.')
         try:
             mapfactorymodule = do_import(conf.get('server', 'module'))
         except ImportError:
             raise ServerConfigurationError('The factory module could not be loaded.')
         if hasattr(mapfactorymodule, 'WMSFactory'):
             self.mapfactory = getattr(mapfactorymodule, 'WMSFactory')()
         else:
             raise ServerConfigurationError('The factory module does not have a WMSFactory class.')
     if conf.has_option('server', 'debug'):
         self.debug = int(conf.get('server', 'debug'))
     else:
         self.debug = 0
     if self.conf.has_option_with_value('server', 'maxage'):
         self.max_age = 'max-age=%d' % self.conf.get('server', 'maxage')
     else:
         self.max_age = None
Exemplo n.º 16
0
 def ogcserver_constructor(self, content):
     try:
         wms_factory = BaseWMSFactory(self.ogc_configfile)
         if os.path.isfile(content):
             wms_factory.loadXML(xmlfile=content)
         else:
             wms_factory.loadXML(xmlstring=content)  #for testing
         wms_factory.finalize()
     except:
         self.logging(
             0, 
             "ERROR: Content {} not init as Mapnik FILE".format(content)
         )
     else:
         return wms_factory
Exemplo n.º 17
0
 def ogcserver_constructor(self, content):
     try:
         wms_factory = BaseWMSFactory(self.ogc_configfile)
         if os.path.isfile(content):
             if isinstance(content, unicode):
                 mapnik_file = content.encode("utf-8")
             else:
                 mapnik_file = content
             wms_factory.loadXML(xmlfile=mapnik_file)
         else:
             wms_factory.loadXML(xmlstring=content)  #for testing
         wms_factory.finalize()
     except Exception as err:
         self.logging(
             0, u"ERROR: Content {0} not init as Mapnik FILE\n{1}".format(
                 content,
                 err.__str__().decode("utf-8")))
     else:
         return wms_factory
Exemplo n.º 18
0
 def __init__(self,
              configpath,
              mapfile,
              fonts=None,
              home_html=None,
              **kwargs
             ):
     BasePasteWSGIApp.__init__(self, 
                               configpath, 
                               font=fonts, home_html=home_html, **kwargs)
     wms_factory = BaseWMSFactory(configpath)
     wms_factory.loadXML(mapfile)
     wms_factory.finalize()
     self.mapfactory = wms_factory
Exemplo n.º 19
0
 def __init__(self, configpath, mapfile=None, fonts=None, home_html=None):
     # 实例化 ConfigParser 并加载配置文件
     conf = SafeConfigParser()
     # 从配置文件读取并分析(分列)配置信息
     conf.readfp(open(configpath))
     # TODO - be able to supply in config as well
     self.home_html = home_html
     self.conf = conf
     if fonts:
         # 注册指定字体
         mapnik.register_fonts(fonts)
     if mapfile:
         # 生成BaseWMSFactory实例
         wms_factory = BaseWMSFactory(configpath)
         # TODO - add support for Cascadenik MML
         wms_factory.loadXML(mapfile)
         wms_factory.finalize()
         self.mapfactory = wms_factory
     else:
         # 阅读default.conf,有疑惑???
         #
         # 原default.conf文件中module未定义,需要使用要在default.conf中自行定义
         if not conf.has_option_with_value('server', 'module'):
             raise ServerConfigurationError(
                 'The factory module is not defined in the configuration file.'
             )
         # 导入指定module
         try:
             # get(section,option),Get an option value for the named
             # section.
             mapfactorymodule = do_import(conf.get('server', 'module'))
         except ImportError:
             raise ServerConfigurationError(
                 'The factory module could not be loaded.')
         if hasattr(mapfactorymodule, 'WMSFactory'):
             # Get a named attribute from an object; getattr(x, 'y') is
             # equivalent to x.y.
             self.mapfactory = getattr(mapfactorymodule, 'WMSFactory')()
         else:
             raise ServerConfigurationError(
                 'The factory module does not have a WMSFactory class.')
     if conf.has_option('server', 'debug'):
         self.debug = int(conf.get('server', 'debug'))
     else:
         self.debug = 0
     if self.conf.has_option_with_value('server', 'maxage'):
         self.max_age = 'max-age=%d' % self.conf.get('server', 'maxage')
     else:
         self.max_age = None
Exemplo n.º 20
0
def test_wms_capabilities():
    base_path, tail = os.path.split(__file__)
    file_path = os.path.join(base_path, 'mapfile_encoding.xml')
    wms = BaseWMSFactory()
    with open(file_path) as f:
        settings = f.read()
    wms.loadXML(xmlstring=settings, basepath=base_path)
    wms.finalize()

    if len(wms.layers) != 1:
        raise Exception('Incorrect number of layers')
    if len(wms.styles) != 1:
        raise Exception('Incorrect number of styles')

    return True
Exemplo n.º 21
0
def _wms_services(mapfile):
    base_path, tail = os.path.split(__file__)
    file_path = os.path.join(base_path, mapfile)
    wms = BaseWMSFactory()

    # Layer 'awkward-layer' contains a regular style named 'default', which will
    # be hidden by OGCServer's auto-generated 'default' style. A warning message
    # is written to sys.stderr in loadXML.
    # Since we don't want to see this several times while unit testing (nose only
    # redirects sys.stdout), we redirect sys.stderr here into a StringIO buffer
    # temporarily.
    # As a side effect, we can as well search for the warning message and fail the
    # test, if it occurs zero or more than one times per loadXML invocation. However,
    # this test highly depends on the warning message text.
    stderr = sys.stderr
    errbuf = StringIO.StringIO()
    sys.stderr = errbuf

    wms.loadXML(file_path)

    sys.stderr = stderr
    errbuf.seek(0)
    warnings = 0
    for line in errbuf:
        if line.strip('\r\n') == multi_style_err_text:
            warnings += 1
        else:
            sys.stderr.write(line)
    errbuf.close()

    if warnings == 0:
        raise Exception(
            'Expected warning message for layer \'awkward-layer\' not found in stderr stream.'
        )
    elif warnings > 1:
        raise Exception(
            'Expected warning message for layer \'awkward-layer\' occurred several times (%d) in stderr stream.'
            % warnings)

    wms.finalize()

    conf = SafeConfigParser()
    conf.readfp(open(os.path.join(base_path, 'ogcserver.conf')))

    wms111 = ServiceHandler111(conf, wms, "localhost")
    wms130 = ServiceHandler130(conf, wms, "localhost")

    return (conf, {'1.1.1': wms111, '1.3.0': wms130})
Exemplo n.º 22
0
def _wms_capabilities():
    base_path, tail = os.path.split(__file__)
    file_path = os.path.join(base_path, 'mapfile_encoding.xml')
    wms = BaseWMSFactory()
    wms.loadXML(file_path)
    wms.finalize()

    conf = SafeConfigParser()
    conf.readfp(open(os.path.join(base_path, 'ogcserver.conf')))

    wms111 = ServiceHandler111(conf, wms, "localhost")
    wms130 = ServiceHandler130(conf, wms, "localhost")

    return (conf, {
        '1.1.1': wms111.GetCapabilities({}),
        '1.3.0': wms130.GetCapabilities({})
    })
Exemplo n.º 23
0
def _wms_services(mapfile):
    base_path, tail = os.path.split(__file__)
    file_path = os.path.join(base_path, mapfile)
    wms = BaseWMSFactory() 
    wms.loadXML(file_path)
    wms.finalize()

    conf = SafeConfigParser()
    conf.readfp(open(os.path.join(base_path, 'ogcserver.conf')))

    wms111 = ServiceHandler111(conf, wms, "localhost")
    wms130 = ServiceHandler130(conf, wms, "localhost")

    return (conf, {
        '1.1.1': wms111,
        '1.3.0': wms130
    })
Exemplo n.º 24
0
def test_encoding():
    import os
    from ogcserver.configparser import SafeConfigParser
    from ogcserver.WMS import BaseWMSFactory
    from ogcserver.wms111 import ServiceHandler as ServiceHandler111
    from ogcserver.wms130 import ServiceHandler as ServiceHandler130

    base_path, tail = os.path.split(__file__)
    file_path = os.path.join(base_path, 'shape_encoding.xml')
    wms = BaseWMSFactory()
    wms.loadXML(file_path)
    wms.finalize()

    conf = SafeConfigParser()
    conf.readfp(open(os.path.join(base_path, 'ogcserver.conf')))

    # srs = EPSG:4326
    # 3.00 , 42,35 - 3.15 , 42.51
    # x = 5 , y = 6
    params = {}
    params['srs'] = 'epsg:4326'
    params['x'] = 5
    params['y'] = 5
    params['bbox'] = [3.00, 42.35, 3.15, 42.51]
    params['height'] = 10
    params['width'] = 10
    params['layers'] = ['row']
    params['styles'] = ''
    params['query_layers'] = ['row']

    for format in ['text/plain', 'text/xml']:
        params['info_format'] = format
        wms111 = ServiceHandler111(conf, wms, "localhost")
        result = wms111.GetFeatureInfo(params)

        wms130 = ServiceHandler130(conf, wms, "localhost")
        wms130.GetCapabilities({})

    return True
Exemplo n.º 25
0
 def __init__(self):
     BaseWMSFactory.__init__(self)
     base_path, tail = os.path.split(__file__)
     file_path = os.path.join(base_path, 'mapfile_encoding.xml') 
     self.loadXML(file_path)
     self.finalize()
Exemplo n.º 26
0
def test_wms_capabilities():
    wms = BaseWMSFactory()
    nose.tools.assert_raises(ServerConfigurationError, wms.loadXML)
    
    return True
Exemplo n.º 27
0
 def __init__(self):
   BaseWMSFactory.__init__(self)
   self.loadXML('resources.xml')
   self.finalize()
Exemplo n.º 28
0
 def __init__(self):
     BaseWMSFactory.__init__(self)
     base_path, tail = os.path.split(__file__)
     file_path = os.path.join(base_path, 'mapfile_encoding.xml')
     self.loadXML(file_path)
     self.finalize()
Exemplo n.º 29
0
 def __init__(self):
     BaseWMSFactory.__init__(self)
Exemplo n.º 30
0
def test_map():
    from ogcserver.WMS import ServiceHandlerFactory

    reqparams = {
        'srs': 'EPSG:4326',
        'bbox': '-180.0000,-90.0000,180.0000,90.0000',
        'width': 800,
        'height': 600,
        'layers': '__all__',
        'styles': '',
        'format': 'image/png',
    }

    def check_map_styles(version, no, layer, style_param, styles=None):

        print 'GetMap %s: layer #%d \'%s\': STYLES=%s' % (version, no, layer,
                                                          style_param)

        ogcparams['layers'] = layer.split(',')
        ogcparams['styles'] = style_param.split(',')

        # Parameter 'styles' contains the list of expected styles. If styles
        # evaluates to False (e.g. None, Null), an invalid STYLE was provided
        # and so, an OGCException 'StyleNotDefined' is expected.
        try:
            m = services[version]._buildMap(ogcparams)
        except OGCException:
            if not styles:
                print '              style #0 \'invalid style\': OK (caught OGCException)'
                print
                return
            raise Exception(
                'GetMap %s: Expected OGCExecption for invalid style \'%s\' for layer #%d \'%s\' was not thrown.'
                % (version, style_param, no, layer))

        _check_style_lists('GetMap', version, no, layer, m.layers[0].styles,
                           styles)
        print

    conf, services = _wms_services('mapfile_styles.xml')

    mapfactory = BaseWMSFactory()
    servicehandler = ServiceHandlerFactory(conf, mapfactory, '', '1.1.1')
    ogcparams = servicehandler.processParameters('GetMap', reqparams)
    ogcparams['crs'] = ogcparams['srs']
    ogcparams['HTTP_USER_AGENT'] = 'unit_tests'

    for version in ['1.1.1', '1.3.0']:
        check_map_styles(version, 1, 'single-style-layer', '',
                         ['simple-style'])
        check_map_styles(version, 1, 'single-style-layer', 'simple-style',
                         ['simple-style'])
        check_map_styles(version, 1, 'single-style-layer', 'default')
        check_map_styles(version, 1, 'single-style-layer', 'invalid-style')

        check_map_styles(version, 2, 'multi-style-layer', '',
                         ['simple-style', 'another-style'])
        check_map_styles(version, 2, 'multi-style-layer', 'default',
                         ['simple-style', 'another-style'])
        check_map_styles(version, 2, 'multi-style-layer', 'simple-style',
                         ['simple-style'])
        check_map_styles(version, 2, 'multi-style-layer', 'another-style',
                         ['another-style'])
        check_map_styles(version, 2, 'multi-style-layer', 'invalid-style')

        check_map_styles(version, 3, 'awkward-layer', '',
                         ['default', 'another-style'])
        check_map_styles(version, 3, 'awkward-layer', 'default',
                         ['default', 'another-style'])
        check_map_styles(version, 3, 'awkward-layer', 'another-style',
                         ['another-style'])
        check_map_styles(version, 3, 'awkward-layer', 'invalid-style')

        check_map_styles(version, 4, 'single-default-layer', '', ['default'])
        check_map_styles(version, 4, 'single-default-layer', 'default',
                         ['default'])
        check_map_styles(version, 4, 'single-default-layer', 'invalid-style')

        # Some 'manually' created error cases for testing error reporting
        #check_map_styles(version, 2, 'multi-style-layer', 'default', ['simple-style', 'another-style', 'foo', 'bar'])
        #check_map_styles(version, 2, 'multi-style-layer', 'default', ['simple-style'])

    return True