def test_should_get_coordinates_from_geojson(self):
     print('TEST1')
     coords = spatial.coordinates_from_geojson(self.data)
     print(coords)
     try:
         self.assertEqual(coords[0], coords[-1])
         print('PASSED')
     except AssertionError:
         print('FAILED')
Example #2
0
 def test_should_get_coordinates_from_geojson(self):
     print('TEST1')
     coords = spatial.coordinates_from_geojson(self.data)
     print(coords)
     try:
         self.assertEqual(coords[0], coords[-1])
         print('PASSED')
     except AssertionError:
         print('FAILED')
 def test_should_print_ewkt_from_coords(self):
     print('TEST2')
     coords = spatial.coordinates_from_geojson(self.data)
     polygon = spatial.from_list_to_ewkt(coords)
     print(polygon)
     try:
         self.assertEqual(
             polygon,
             'SRID=3857;POLYGON((62.5 169.0, 62.5 169.3, 62.9 169.3, 62.9 169.0, 62.5 169.0))'
         )
         print('PASSED')
     except AssertionError:
         print('FAILED')
Example #4
0
 def test_should_print_ewkt_from_coords(self):
     print('TEST2')
     coords = spatial.coordinates_from_geojson(self.data)
     polygon = spatial.from_list_to_ewkt(coords)
     print(polygon)
     try:
         self.assertEqual(
             polygon,
             'SRID=3857;POLYGON((62.5 169.0, 62.5 169.3, 62.9 169.3, 62.9 169.0, 62.5 169.0))'
         )
         print('PASSED')
     except AssertionError:
         print('FAILED')
Example #5
0
    def on_post(self, req, resp):
        """Handles POST requests"""
        resp.status = falcon.HTTP_200
        # grab 'geojson' from req.context
        data = req.context['geojson']
        # get coordinates from geojson
        coords = spatial.from_list_to_ewkt(
            spatial.coordinates_from_geojson(data))
        print(coords)
        # create the controller view
        controller = Controller(coords)
        # find the areas contained by controller's view and connected points' data
        controller.which_areas_contains_this_polygon()
        # dump the retrieved data
        json = controller.serialize_features_from_database()

        print(str(controller))
        print(json)

        req.context['result'] = json
Example #6
0
    def on_post(self, req, resp):
        """Handles POST requests"""
        resp.status = falcon.HTTP_200
        # grab 'geojson' from req.context
        data = req.context['geojson']
        # get coordinates from geojson
        coords = spatial.from_list_to_ewkt(
            spatial.coordinates_from_geojson(data)
        )
        print(coords)
        # create the controller view
        controller = Controller(coords)
        # find the areas contained by controller's view and connected points' data
        controller.which_areas_contains_this_polygon()
        # dump the retrieved data
        json = controller.serialize_features_from_database()

        print(str(controller))
        print(json)

        req.context['result'] = json