示例#1
0
    def test_should_return_all_the_xco2_in_a_geometry(self):
        # create a controller
        controller = Controller(self.polygon_big)
        #print(self.polygon_big)
        # find the areas contained by controller's view
        controller.which_areas_contains_this_polygon()
        # return the JSON points contained by the areas
        #print(areas)
        json = controller.serialize_features_from_database()

        print(json)
示例#2
0
 def test_should_initialize_controller(self):
     print('TEST1')
     controller = Controller(self.polygon_avg)
     try:
         print(str(controller))
         #print(repr(controller))
         print('TEST PASSED')
     except:
         print('TEST FAILED')
示例#3
0
 def test_should_print_coordinates(self):
     print('TEST2')
     controller = Controller(self.polygon_avg)
     try:
         #print(repr(controller))
         print(controller.geo_object.__geo_interface__)
         #print(controller.geo_object.bounds)
         print('TEST PASSED')
     except:
         print('TEST FAILED')
示例#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
示例#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
示例#6
0
 def test_should_find_all_the_areas_from_a_view(self):
     """Should find all the rows in t_areas that are contained in the polygon"""
     print('TEST3')
     controller = Controller(self.polygon_big)
     # find all the areas contained in the view
     count = dbProxy.alchemy.execute(
         'SELECT count(*) FROM t_areas WHERE ST_Contains(%s, aoi)',
         ((controller.geometry, ), )
     ).first()
     print('FOUND: ', count[0])
     results = dbProxy.alchemy.execute(
         'SELECT id, aoi, center, data FROM t_areas WHERE ST_Contains(%s, aoi)',
         ((controller.geometry, ), )
     ).fetchall()
     for r in results:
         print(r)
示例#7
0
 def test_should_find_closest_centers(self):
     print('TEST4')
     controller = Controller(self.point)
     closest = controller.what_are_the_closest_centers_to_(controller.geometry)
     print(closest)
示例#8
0
 def test_should_return_controller_primary_keys(self):
     controller = Controller(self.polygon_big)
     print(controller.pks)
示例#9
0
 def test_should_return_controller_center(self):
     controller = Controller(self.polygon_big)
     print(controller.geo_object.__geo_interface__['coordinates'])
     print(controller.center)