Esempio n. 1
0
    def test_medium_zoo(self):
        import shapely.geometry
        from vectordatasource.util import calculate_way_area, \
            calculate_1px_zoom
        import math

        target_zoom = 11.0
        # want a zoom 11 feature, so make one with a triangle.
        target_area = math.exp((17.256 - target_zoom) * math.log(4))
        # make area with a half-square triangle.
        s = math.sqrt(target_area * 2.0)
        shape = shapely.geometry.Polygon([(0, 0), (s, s), (s, 0)])
        props = {
            'zoo': 'enclosure',
        }

        # test the utility functions we're relying on
        util_way_area = calculate_way_area(shape)
        self.assertAlmostEqual(target_area, util_way_area)
        util_min_zoom = calculate_1px_zoom(shape.area)
        self.assertAlmostEqual(target_zoom, util_min_zoom)

        meta = make_test_metadata()
        out_min_zoom = self.landuse.fn(shape, props, None, meta)
        self.assertAlmostEqual(target_zoom, out_min_zoom)
Esempio n. 2
0
    def test_medium_zoo(self):
        import shapely.geometry
        from vectordatasource.util import calculate_way_area, \
            calculate_1px_zoom
        import math

        target_zoom = 14.0
        # want a zoom 14 feature, so make one with a triangle.
        target_area = math.exp((17.256 - target_zoom) * math.log(4))
        # make area with a half-square triangle.
        s = math.sqrt(target_area * 2.0)
        shape = shapely.geometry.Polygon([(0, 0), (s, s), (s, 0)])
        props = {
            'zoo': 'enclosure',
        }

        # test the utility functions we're relying on
        util_way_area = calculate_way_area(shape)
        self.assertAlmostEqual(target_area, util_way_area)
        util_min_zoom = calculate_1px_zoom(shape.area)
        self.assertAlmostEqual(target_zoom, util_min_zoom)

        meta = make_test_metadata()
        out_min_zoom = self.landuse.fn(shape, props, None, meta)
        self.assertAlmostEqual(target_zoom, out_min_zoom)