Пример #1
0
 def nearest_address(self):
     data = self._retrieve_json()
     geojson_input = self.validate_geojson(data)
     if check_in_flanders(geojson_input):
         crab_gateway = self.request.crab_gateway() if hasattr(self.request, 'crab_gateway') else None
         address = nearest_location(geojson_input, crab_gateway)
         if address is None:
             return {"found": False}
         return {"found": True, "address": address}
     else:
         raise ValidationFailure(
                 "De geojson geometrie is niet geldig.",
                 {"": "Geometrie ligt niet binnen Vlaanderen"}
         )
Пример #2
0
 def check_in_flanders(self):
     data = self._retrieve_json()
     geojson_input = self.validate_geojson(data)
     return {'IntersectFlanders': check_in_flanders(geojson_input)}
Пример #3
0
 def test_check_in_flanders(self):
     self.assertTrue(check_in_flanders(testdata.test_geojson_valid))
     self.assertTrue(check_in_flanders(testdata.test_json_intersects_flanders))
     self.assertFalse(check_in_flanders(testdata.test_json_outside_flanders))