def test_Extent_from_3857(): x, y = mapping._to_3857(0.2, 0.3) ex = mapping.Extent.from_centre(0.2, 0.3, xsize=0.1).to_project_3857() ex1 = mapping.Extent.from_centre_3857(x, y, xsize=0.1) assert ex1.xrange == pytest.approx(ex.xrange) assert ex1.yrange == pytest.approx(ex.yrange) xx, yy = mapping._to_3857(0.25, 0.4) ex = mapping.Extent.from_3857(x, xx, y, yy) ex1 = mapping.Extent(0.2, 0.25, 0.3, 0.4).to_project_3857() assert ex1.xrange == pytest.approx(ex.xrange) assert ex1.yrange == pytest.approx(ex.yrange)
def test_Extent_projection(): ex = mapping.Extent(0.2, 0.5, 0.3, 0.4) ex1 = ex.to_project_3857() ex2 = ex.to_project_web_mercator() assert_standard_properties(ex) assert_standard_properties(ex2) x, y = mapping._to_3857(0.2, 0.3) xx, yy = mapping._to_3857(0.5, 0.4) assert ex1.xmin == pytest.approx(x) assert ex1.xmax == pytest.approx(xx) assert ex1.width == pytest.approx(xx - x) assert ex1.xrange == pytest.approx((x, xx)) assert ex1.ymin == pytest.approx(y) assert ex1.ymax == pytest.approx(yy) assert ex1.height == pytest.approx(yy - y) assert ex1.yrange == pytest.approx((yy, y)) assert str(ex1).endswith(" projected as epsg:3857)")
def test_Plotter_plot_epsg(ex, tile_provider, new_image): ex = ex.to_project_3857() plot = mapping.Plotter(ex, tile_provider, width=100) ax = mock.Mock() plot.plot(ax) image = new_image.return_value imshow = imshow_calls_to_list(ax) assert len(imshow) == 1 tile, extent = imshow[0] assert tile == image x, y = mapping._to_3857(0, 0) xx, yy = mapping._to_3857(1, 0.5) assert extent == pytest.approx((x, xx, yy, y)) kwargs = ax.set.call_args_list[0][1] x, y = mapping._to_3857(0.2, 0.3) xx, yy = mapping._to_3857(0.5, 0.4) kwargs["xlim"] == pytest.approx((x, xx)) kwargs["ylim"] == pytest.approx((yy, y))