Beispiel #1
0
    def layer_parsing_test(self):
        """Check layer parsing works correctly."""
        mapnik_config = config["layers"]["mapnik"]
        layer = MapLayer(layerId="mapnik", config=mapnik_config)
        self.assertEqual(layer.id, "mapnik")
        self.assertEqual(layer.label, "Mapnik (default)")
        self.assertEqual(layer.url, "http://c.tile.openstreetmap.org/")
        self.assertEqual(layer.type, "png")
        self.assertEqual(layer.max_zoom, 18)
        self.assertEqual(layer.min_zoom, 0)
        self.assertEqual(layer.folder_name, "OpenStreetMap I")
        self.assertEqual(layer.group_id, "osm")
        self.assertEqual(layer.icon, "mapnik")
        self.assertEqual(layer.timeout, 240.5)

        expected_dict = {
            "id": "mapnik",
            "label": "Mapnik (default)",
            "url": "http://c.tile.openstreetmap.org/",
            "type": "png",
            "max_zoom": 18,
            "min_zoom": 0,
            "folder_name": "OpenStreetMap I",
            "coordinates": "osm",
            "group_id": "osm",
            "icon": "mapnik",
            "timeout": 240.5
        }
        self.assertDictEqual(layer.dict, expected_dict)
Beispiel #2
0
 def _getFallbackLayer(self):
     """In case that loading the map configuration
     file fails, this Mapnik layer can be used as a fallback.
     """
     return MapLayer(layerId="mapnik",
                     config={
                         'label': "OSM Mapnik",
                         'url': "http://c.tile.openstreetmap.org",
                         'max_zoom': 18,
                         'min_zoom': 0,
                         'folder_prefix': "OpenStreetMap I",
                         'coordinates': "osm"
                     })
Beispiel #3
0
    def _parseLayers(self):
        """Parse all map layer definitions"""
        # check if there is at least one valid layer

        layerDefinitions = self.modrana.configs.map_config.get('layers', {})
        for layerId, layerDefinition in six.iteritems(layerDefinitions):
            if self._hasRequiredKeys(layerDefinition, MAP_LAYER_REQUIRED_KEYS):
                self._layers[layerId] = MapLayer(layerId, layerDefinition)
            else:
                self.log.error('layer %s definition is missing required keys',
                               layerId)
        if self._layers == {}:
            self.log.error('map layer config has no valid layers,'
                           ' using Mapnik fallback layer')
            self._layers['mapnik'] = self._getFallbackLayer()