def test_native_geometry_str(shapes): expected = 'POLYGON ((1 0, 1 1, 0 1, 0 0, 1 0))' assert str(NaiveGeoMetry(shapes['base'])) == expected
def test_subsection(shapes, test_input, expected): geom = NaiveGeoMetry(shapes['base']) subsection = geom.subsection(test_input) assert geom.subsection(test_input).bounds == expected assert subsection.supersection() == geom
def test_naive_geometry_eq(shapes): assert NaiveGeoMetry(shapes['base']) == NaiveGeoMetry(shapes['reordered'])
def test_intersects(shapes): geom = NaiveGeoMetry(shapes['base']) other = NaiveGeoMetry(shapes['contains']) assert geom.intersection(other) == other
def test_similar_to(shapes): bbox = box(0.0001, 0.0001, 0.9999, 0.9999) assert NaiveGeoMetry(shapes['base']).similar_to(bbox)
def test_overlaps(shapes): assert NaiveGeoMetry(shapes['base']).overlaps(shapes['overlaps'])
def test_disjoint(shapes): assert NaiveGeoMetry(shapes['base']).disjoint(shapes['disjoint'])
def test_native_geometry_width_km(shapes): width_km = NaiveGeoMetry(shapes['base']).width_km assert width_km == approx(DEG_AT_EQUATOR, rel=1e-2)
def test_native_geometry_xy(shapes): expected = [(1, 1, 0, 0, 1), (0, 1, 1, 0, 0)] assert NaiveGeoMetry(shapes['base']).xy == expected
def test_native_geometry_lat_lngs(shapes): expected = [(0, 1), (1, 1), (1, 0), (0, 0), (0, 1)] assert NaiveGeoMetry(shapes['base']).lat_lngs == expected
def test_native_geometry_longitudes(shapes): expected = [1, 1, 0, 0, 1] assert NaiveGeoMetry(shapes['base']).longitudes == expected
def test_native_geometry_height_km(shapes): height_km = NaiveGeoMetry(shapes['base']).height_km assert height_km == approx(DEG_AT_EQUATOR, rel=1e-2)
def test_native_geometry_change_crs(shapes): with pytest.raises(AttributeError): NaiveGeoMetry(shapes['base']).crs = 'FAKE CRS'
def test_native_geometry_centroid(shapes): lng, lat = NaiveGeoMetry(shapes['base']).centroid.coords[0] assert lng == 0.5 assert lat == 0.5
def test_contains(shapes): assert NaiveGeoMetry(shapes['base']).contains(shapes['contains'])
def test_native_geometry_x(shapes): expected = [1, 1, 0, 0, 1] assert NaiveGeoMetry(shapes['base']).x == expected
def test_within(shapes): assert NaiveGeoMetry(shapes['base']).within(shapes['within'])
def test_native_geometry_y(shapes): expected = [0, 1, 1, 0, 0] assert NaiveGeoMetry(shapes['base']).y == expected
def test_touches(shapes): assert NaiveGeoMetry(shapes['base']).touches(shapes['touches'])
def test_native_geometry_radius_km(shapes): geom = NaiveGeoMetry(shapes['base']) geom._radius_km = None assert geom.radius_km == approx(78.4, rel=1e-2)
def test_intersects(shapes, test_input, expected): if expected: assert NaiveGeoMetry(shapes['base']).intersects(shapes[test_input]) else: assert not NaiveGeoMetry(shapes['base']).intersects(shapes[test_input])
def test_native_geometry_invalid_radius_km(shapes): with pytest.raises(ValueError): NaiveGeoMetry(shapes['base']).radius_km = 'str'
def test_clone(shapes): geom = NaiveGeoMetry(shapes['base']) assert geom.clone() == geom
def test_native_geometry_shape(shapes): geom = NaiveGeoMetry(Point(0, 0), radius_km=DEG_AT_EQUATOR / 2) assert geom.area == approx(1, rel=1e-2)
def test_similar_to_with_args(shapes): bbox = box(0.1, 0.1, 0.9, 0.9) assert NaiveGeoMetry(shapes['base']).similar_to(bbox, 0.9, 0.5)
def test_center(shapes): assert NaiveGeoMetry(shapes['base']).center == Point(0.5, 0.5)
def test_naive_geometry_bool(shapes): assert NaiveGeoMetry(shapes['base'])
def test_centroid(shapes): centroid = NaiveGeoMetry(shapes['base']).centroid assert centroid == NaiveGeoMetry(Point(0.5, 0.5))
def test_native_geometry_iter(shapes): expected = [(0, 1), (1, 1), (1, 0), (0, 0), (0, 1)] assert list(NaiveGeoMetry(shapes['base'])) == expected
def test_native_geometry_len(shapes): assert len(NaiveGeoMetry(shapes['base'])) == 5