def test_static_map_generator2(self):
        width = 500
        height = 500
        simple_config = {
            'params': {
                'epsg': 31370,
                'filetype': 'png',
                'width': width,
                'height': height,
                'bbox': [145000, 195000, 165000, 215000]
            },
            'layers':
                [{
                    'type': 'text',
                    'text': 'This is a test',
                    'color': '#FF3366',
                    'borderwidth': 0,
                    'font_size': 24,
                    'text_color': '#FF3366',
                    'gravity': 'center'

                  }
                 ]
        }
        Generator.generate(simple_config)
Beispiel #2
0
 def test_static_map_generator(self):
     file_path = os.path.join(self.tempdir.name, 'test.png')
     width = 500
     height = 500
     simple_config = {
         'params': {
             'filename': file_path,
             'epsg': 31370,
             'filetype': 'png',
             'width': width,
             'height': height,
             'bbox': [145000, 195000, 165000, 215000]
         },
         'layers': [{
             'type': 'text',
             'text': 'This is a test',
             'color': '#FF3366',
             'borderwidth': 0,
             'font_size': 24,
             'text_color': '#FF3366',
             'gravity': 'center'
         }]
     }
     Generator.generate(simple_config)
     self.assertTrue(os.path.isfile(file_path))
     image = Image(filename=file_path)
     self.assertEqual(image.width, width)
     self.assertEqual(image.height, height)
    def test_static_map_generator(self):
        file_path = os.path.join(self.tempdir.name, 'test.png')
        width = 500
        height = 500
        simple_config = {
            'params': {
                 'filename': file_path,
                'epsg': 31370,
                'filetype': 'png',
                'width': width,
                'height': height,
                'bbox': [145000, 195000, 165000, 215000]
            },
            'layers':
                [{
                    'type': 'text',
                    'text': 'This is a test',
                    'color': '#FF3366',
                    'borderwidth': 0,
                    'font_size': 24,
                    'text_color': '#FF3366',
                    'gravity': 'center'

                  }
                 ]
        }
        Generator.generate(simple_config)
        self.assertTrue(os.path.isfile(file_path))
        image = Image(filename=file_path)
        self.assertEqual(image.width, width)
        self.assertEqual(image.height, height)
 def test_stream_wms_error(self):
     responses.add(responses.GET,
                   'http://geoservices.informatievlaanderen.be/raadpleegdiensten/GRB-basiskaart-grijs/wms',
                   status=500)
     with patch('static_map_generator.generator.log') as log_mock:
         with self.assertRaises(Exception):
             Generator.generate_stream(config)
     self.assertEqual(log_mock.error.call_count, 2)
     self.assertIn(call('Background wms could not be rendered'), log_mock.error.mock_calls)
 def test_stream_text_error(self):
     _init_responses()
     config_text_error = deepcopy(config)
     del config_text_error['layers'][1]['text']
     with patch('static_map_generator.generator.log') as log_mock:
         with self.assertRaises(Exception):
             Generator.generate_stream(config_text_error)
     self.assertEqual(log_mock.error.call_count, 2)
     self.assertIn(call('Text could not be rendered'), log_mock.error.mock_calls)
    def test_all_types(self):
        file_path = os.path.join(self.tempdir.name, 'test.png')
        width = 500
        height = 500
        config_31370 = {
    'params': {
        'filename': file_path,
        'epsg': 31370,
        'filetype': 'png',
        'width': width,
        'height': height,
        'bbox': [145000, 195000, 165000, 215000]
    },
    'layers':
        [{
            'type': 'text',
            'text': 'This is a test',
            'color': '#FF3366',
            'borderwidth': 1,
            'font_size': 24,
            'text_color': '#FF3366',
            'gravity': 'center'

          },
            {
            'type': 'legend'
          },

         {
             'type': 'logo',
             'url': 'https://www.onroerenderfgoed.be/assets/img/logo-og.png',
             'opacity': 0.5,
             'imagewidth': 100,
             'imageheight': 100,
             'gravity': 'south_west',
             'offset': '0,0'

          },
         {
             'type': 'wkt',
             'wkt': 'POLYGON ((155000 215000, 160000 210000, 160000 215000, 155000 215000))',
             'color': 'steelblue',
             'opacity': 0.5

          },

         {
             'type': 'wms',
             'url': 'http://geo.api.agiv.be/geodiensten/raadpleegdiensten/GRB-basiskaart/wmsgr?',
             'layers': 'GRB_BSK'

          }
         ]
}
        Generator.generate(config_31370)
 def maps_by_post_base64(self):
     params = self._get_params()
     config = self.validate_config(params)
     self.request.response.status = 201
     return {
         'image':  text_(Generator.generate_base64(config))
     }
Beispiel #8
0
 def maps_by_post(self):
     params = self._get_params()
     config = self.validate_config(params)
     res = Response(content_type='image/png')
     res.status = '200 OK'
     res.body = Generator.generateStream(config)
     return res
Beispiel #9
0
 def maps_by_post(self):
     params = self._get_params()
     config = self.validate_config(params)
     res = Response(content_type='image/png')
     res.status = '200 OK'
     res.body = Generator.generateStream(config)
     return res
Beispiel #10
0
 def test_all_types(self):
     file_path = os.path.join(self.tempdir.name, 'test.png')
     width = 500
     height = 500
     config_31370 = {
         'params': {
             'filename': file_path,
             'epsg': 31370,
             'filetype': 'png',
             'width': width,
             'height': height,
             'bbox': [145000, 195000, 165000, 215000]
         },
         'layers': [{
             'type': 'text',
             'text': 'This is a test',
             'color': '#FF3366',
             'borderwidth': 1,
             'font_size': 24,
             'text_color': '#FF3366',
             'gravity': 'center'
         }, {
             'type': 'legend'
         }, {
             'type': 'logo',
             'url':
             'https://www.onroerenderfgoed.be/assets/img/logo-og.png',
             'opacity': 0.5,
             'imagewidth': 100,
             'imageheight': 100,
             'gravity': 'south_west',
             'offset': '0,0'
         }, {
             'type': 'wkt',
             'wkt':
             'POLYGON ((155000 215000, 160000 210000, 160000 215000, 155000 215000))',
             'color': 'steelblue',
             'opacity': 0.5
         }, {
             'type': 'wms',
             'url':
             'http://geo.api.agiv.be/geodiensten/raadpleegdiensten/GRB-basiskaart/wmsgr?',
             'layers': 'GRB_BSK'
         }]
     }
     Generator.generate(config_31370)
Beispiel #11
0
 def test_static_map_generator2(self):
     width = 500
     height = 500
     simple_config = {
         'params': {
             'epsg': 31370,
             'filetype': 'png',
             'width': width,
             'height': height,
             'bbox': [145000, 195000, 165000, 215000]
         },
         'layers': [{
             'type': 'text',
             'text': 'This is a test',
             'color': '#FF3366',
             'borderwidth': 0,
             'font_size': 24,
             'text_color': '#FF3366',
             'gravity': 'center'
         }]
     }
     Generator.generate(simple_config)
from static_map_generator.generator import Generator

config_simple = {
    'params': {
        'filename': 'simple.png',
        'epsg': 4326,
        'filetype': 'png',
        'width': 500,
        'height': 500,
        'bbox': [4.95, 50.95, 5, 51]
    },
    'layers': [{
        'type': 'text',
        'text': 'This is a test',
        'font_size': 40,
        'text_color': '#FF3366'
    }, {
        'type': 'wkt',
        'wkt': 'POLYGON ((4.99 50.99, 4.995 50.99, 4.995 50, 4.99 50.99))',
        'color': 'steelblue',
        'opacity': 0.5
    }, {
        'type': 'wms',
        'url':
        'http://geo.api.agiv.be/geodiensten/raadpleegdiensten/GRB-basiskaart/wmsgr?',
        'layers': 'GRB_BSK'
    }]
}
Generator.generate(config_simple)
        'filetype': 'png',
        'width': 500,
        'height': 500,
        'bbox': [4.95, 50.95, 5, 51]
    },
    'layers':
        [{
            'type': 'text',
            'text': 'This is a test',
            'font_size': 40,
            'text_color': '#FF3366'


        },
            {
                'type': 'wkt',
                'wkt': 'POLYGON ((4.99 50.99, 4.995 50.99, 4.995 50, 4.99 50.99))',
                'color': 'steelblue',
                'opacity': 0.5

            },
            {
                'type': 'wms',
                'url': 'http://geo.api.agiv.be/geodiensten/raadpleegdiensten/GRB-basiskaart/wmsgr?',
                'layers': 'GRB_BSK'

            }
        ]
}
Generator.generate(config_simple)
    config_simple = {
      "params": {
        "width": 325,
        "height": 500
      },
      "layers": [
        {
          "geojson": {
            "coordinates": example["coordinates"],
            "type": "Polygon"
          },
          "type": "geojson"
        },
        {
          "type": "text",
          "text": "© GRB basiskaart, informatie Vlaanderen",
          "gravity": "south_east",
          "font_size": 3
        },
        {

          "type": "wms",
          "url": "http://geoservices.informatievlaanderen.be/raadpleegdiensten/GRB-basiskaart-grijs/wms?",
          "layers": "GRB_BSK_GRIJS"
        }
      ]
    }

    with open(os.path.join(os.path.dirname(__file__), example["name"]), 'wb') as f:
        f.write(Generator.generate_stream(config_simple))
             'type': 'logo',
             'url': 'https://www.onroerenderfgoed.be/assets/img/logo-og.png',
             'opacity': 0.5,
             'imagewidth': 100,
            'imageheight': 100

          },
         {
             'type': 'wkt',
             'wkt': 'POLYGON ((4.5 50.2, 5 50.2, 5 50, 4.5 50.2))',
             'color': 'steelblue',
             'opacity': 0.5

          },
         {
             'type': 'wms',
             'url': 'https://geo.onroerenderfgoed.be/geoserver/wms?',
             'layers': 'vioe_geoportaal:landschapsbeheersplannen',
             'featureid': 'landschapsbeheersplannen.3816'

          },
         {
             'type': 'wms',
             'url': 'http://geo.api.agiv.be/geodiensten/raadpleegdiensten/GRB-basiskaart/wmsgr?',
             'layers': 'GRB_BSK'

          }
         ]
}
Generator.generate(config_4326)
Beispiel #16
0
             'url': 'https://www.onroerenderfgoed.be/assets/img/logo-og.png',
             'opacity': 0.5,
            'imagewidth': 100,
            'imageheight': 100

          },
         {
             'type': 'wkt',
             'wkt': 'POLYGON ((155000 215000, 160000 210000, 160000 215000, 155000 215000))',
             'color': 'steelblue',
             'opacity': 0.5

          },
         {
             'type': 'wms',
             'url': 'https://geo.onroerenderfgoed.be/geoserver/wms?',
             'layers': 'vioe_geoportaal:landschapsbeheersplannen',
             'featureid': 'landschapsbeheersplannen.3816'

          },
         {
             'type': 'wms',
             'url': 'http://geo.api.agiv.be/geodiensten/raadpleegdiensten/GRB-basiskaart/wmsgr?',
             'layers': 'GRB_BSK'

          }
         ]
}

Generator.generate(config_31370)
 def test_stream(self):
     _init_responses()
     Generator.generate_stream(config)
Beispiel #18
0
    },
    'layers': [{
        'type': 'text',
        'text': 'This is a test',
        'font_size': 24,
        'text_color': '#FF3366'
    }, {
        'type': 'logo',
        'url': 'https://www.onroerenderfgoed.be/assets/img/logo-og.png',
        'opacity': 0.5,
        'imagewidth': 100,
        'imageheight': 100
    }, {
        'type': 'wkt',
        'wkt': 'POLYGON ((4.5 50.2, 5 50.2, 5 50, 4.5 50.2))',
        'color': 'steelblue',
        'opacity': 0.5
    }, {
        'type': 'wms',
        'url': 'https://geo.onroerenderfgoed.be/geoserver/wms?',
        'layers': 'vioe_geoportaal:landschapsbeheersplannen',
        'featureid': 'landschapsbeheersplannen.3816'
    }, {
        'type': 'wms',
        'url':
        'http://geo.api.agiv.be/geodiensten/raadpleegdiensten/GRB-basiskaart/wmsgr?',
        'layers': 'GRB_BSK'
    }]
}
Generator.generate(config_4326)