Пример #1
0
    def test_normalise_grid_size(self):
        grid_size_1 = GriddedMappablePoint.normalise_grid_size(10)
        self.assertEqual(grid_size_1, 8)

        grid_size_2 = GriddedMappablePoint.normalise_grid_size(0.00001)
        self.assertEqual(grid_size_2, 0)

        grid_size_3 = GriddedMappablePoint.normalise_grid_size(0.9)
        self.assertEqual(grid_size_3, 0.5)

        grid_size_4 = GriddedMappablePoint.normalise_grid_size(1.1)
        self.assertEqual(grid_size_4, 1)
Пример #2
0
    def test_get_cluster_centroids_as_geo_json(self):
        test_layer_1 = DBSession.query(Layer).filter_by(name='TestLayer1').one()
        test_layer_2 = DBSession.query(Layer).filter_by(name='TestLayer2').one()

        q = GriddedMappablePoint.get_points_as_geojson(test_layer_1, grid_size=1)
        result = q.all()
        self.assertEqual(result[0].centroid, '{"type":"Point","coordinates":[20,10]}')
        self.assertEqual(result[1].centroid, '{"type":"Point","coordinates":[30,10]}')

        q2 = GriddedMappablePoint.get_points_as_geojson(test_layer_1, grid_size=100)
        result2 = q2.one()
        self.assertEqual(result2.centroid, '{"type":"Point","coordinates":[25,10]}')

        q3 = GriddedMappablePoint.get_points_as_geojson(test_layer_2, grid_size=100)
        result3 = q3.one()
        self.assertEqual(result3.centroid, '{"type":"Point","coordinates":[16.6666666666667,15]}')
Пример #3
0
    def test_get_layer_points_as_geo_json(self):
        test_layer_1 = DBSession.query(Layer).filter_by(name='TestLayer1').one()
        test_layer_2 = DBSession.query(Layer).filter_by(name='TestLayer2').one()

        q = GriddedMappablePoint.get_points_as_geojson(test_layer_1, grid_size=1)
        result = q.all()
#        self.assertEqual(result[0].locations, '{"type":"MultiPoint","coordinates":[[20,10]]}')
#        self.assertEqual(result[1].locations, '{"type":"MultiPoint","coordinates":[[30,10]]}')
        self.assertEqual(result[0].cluster_size, 1)
        self.assertEqual(result[1].cluster_size, 1)

        q2 = GriddedMappablePoint.get_points_as_geojson(test_layer_1, grid_size=100)
        result2 = q2.all()
#        self.assertEqual(result2[0].locations, '{"type":"MultiPoint","coordinates":[[30,10],[20,10]]}')
        self.assertEqual(result2[0].cluster_size, 2)

        q3 = GriddedMappablePoint.get_points_as_geojson(test_layer_2, grid_size=1)
        result3 = q3.all()
#        self.assertEqual(result3[0].locations, '{"type":"MultiPoint","coordinates":[[10,15],[10,15]]}')
#        self.assertEqual(result3[1].locations, '{"type":"MultiPoint","coordinates":[[30,15]]}')
        self.assertEqual(result3[0].cluster_size, 2)
        self.assertEqual(result3[1].cluster_size, 1)
Пример #4
0
    def test_get_layer_points_as_wkt(self):
        test_layer_1 = DBSession.query(Layer).filter_by(name='TestLayer1').one()

        q = GriddedMappablePoint.get_points_as_wkt(test_layer_1, grid_size=1)
        result = q.all()