コード例 #1
0
def test_native_geometry_str(shapes):
    expected = 'POLYGON ((1 0, 1 1, 0 1, 0 0, 1 0))'
    assert str(NaiveGeoMetry(shapes['base'])) == expected
コード例 #2
0
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
コード例 #3
0
def test_naive_geometry_eq(shapes):
    assert NaiveGeoMetry(shapes['base']) == NaiveGeoMetry(shapes['reordered'])
コード例 #4
0
def test_intersects(shapes):
    geom = NaiveGeoMetry(shapes['base'])
    other = NaiveGeoMetry(shapes['contains'])
    assert geom.intersection(other) == other
コード例 #5
0
def test_similar_to(shapes):
    bbox = box(0.0001, 0.0001, 0.9999, 0.9999)
    assert NaiveGeoMetry(shapes['base']).similar_to(bbox)
コード例 #6
0
def test_overlaps(shapes):
    assert NaiveGeoMetry(shapes['base']).overlaps(shapes['overlaps'])
コード例 #7
0
def test_disjoint(shapes):
    assert NaiveGeoMetry(shapes['base']).disjoint(shapes['disjoint'])
コード例 #8
0
def test_native_geometry_width_km(shapes):
    width_km = NaiveGeoMetry(shapes['base']).width_km
    assert width_km == approx(DEG_AT_EQUATOR, rel=1e-2)
コード例 #9
0
def test_native_geometry_xy(shapes):
    expected = [(1, 1, 0, 0, 1), (0, 1, 1, 0, 0)]
    assert NaiveGeoMetry(shapes['base']).xy == expected
コード例 #10
0
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
コード例 #11
0
def test_native_geometry_longitudes(shapes):
    expected = [1, 1, 0, 0, 1]
    assert NaiveGeoMetry(shapes['base']).longitudes == expected
コード例 #12
0
def test_native_geometry_height_km(shapes):
    height_km = NaiveGeoMetry(shapes['base']).height_km
    assert height_km == approx(DEG_AT_EQUATOR, rel=1e-2)
コード例 #13
0
def test_native_geometry_change_crs(shapes):
    with pytest.raises(AttributeError):
        NaiveGeoMetry(shapes['base']).crs = 'FAKE CRS'
コード例 #14
0
def test_native_geometry_centroid(shapes):
    lng, lat = NaiveGeoMetry(shapes['base']).centroid.coords[0]
    assert lng == 0.5
    assert lat == 0.5
コード例 #15
0
def test_contains(shapes):
    assert NaiveGeoMetry(shapes['base']).contains(shapes['contains'])
コード例 #16
0
def test_native_geometry_x(shapes):
    expected = [1, 1, 0, 0, 1]
    assert NaiveGeoMetry(shapes['base']).x == expected
コード例 #17
0
def test_within(shapes):
    assert NaiveGeoMetry(shapes['base']).within(shapes['within'])
コード例 #18
0
def test_native_geometry_y(shapes):
    expected = [0, 1, 1, 0, 0]
    assert NaiveGeoMetry(shapes['base']).y == expected
コード例 #19
0
def test_touches(shapes):
    assert NaiveGeoMetry(shapes['base']).touches(shapes['touches'])
コード例 #20
0
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)
コード例 #21
0
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])
コード例 #22
0
def test_native_geometry_invalid_radius_km(shapes):
    with pytest.raises(ValueError):
        NaiveGeoMetry(shapes['base']).radius_km = 'str'
コード例 #23
0
def test_clone(shapes):
    geom = NaiveGeoMetry(shapes['base'])
    assert geom.clone() == geom
コード例 #24
0
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)
コード例 #25
0
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)
コード例 #26
0
def test_center(shapes):
    assert NaiveGeoMetry(shapes['base']).center == Point(0.5, 0.5)
コード例 #27
0
def test_naive_geometry_bool(shapes):
    assert NaiveGeoMetry(shapes['base'])
コード例 #28
0
def test_centroid(shapes):
    centroid = NaiveGeoMetry(shapes['base']).centroid
    assert centroid == NaiveGeoMetry(Point(0.5, 0.5))
コード例 #29
0
def test_native_geometry_iter(shapes):
    expected = [(0, 1), (1, 1), (1, 0), (0, 0), (0, 1)]
    assert list(NaiveGeoMetry(shapes['base'])) == expected
コード例 #30
0
def test_native_geometry_len(shapes):
    assert len(NaiveGeoMetry(shapes['base'])) == 5