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')
Esempio n. 2
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')
Esempio n. 3
0
    def setUp(self):
        """Create a random square."""
        geojson = {
                "geometry": {
                    "type": "Polygon",
                    "coordinates": rand_polygon()
                }
            }
        # simulate a single view/area
        self.polygon_avg = spatial.from_list_to_ewkt(geojson['geometry']['coordinates'])
        # simulate a view with 3 areas
        p = (-14, -68)  # rand_coordinates()
        self.polygon_big, _ = spatial.shape_aoi(p, size=8)  # spatial.from_list_to_ewkt(rand_polygon(size=12))
        # simulate a random point

        self.point = spatial.shape_geometry(p[0], p[1])
Esempio n. 4
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
Esempio n. 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