Пример #1
0
def test_prepared_predicates():
    # check prepared predicates give the same result as regular predicates
    polygon1 = Polygon([(0, 0), (0, 1), (1, 1), (1, 0), (0, 0)])
    polygon2 = Polygon([(0.5, 0.5), (1.5, 0.5), (1.0, 1.0), (0.5, 0.5)])
    point2 = Point(0.5, 0.5)
    polygon_empty = Polygon()
    prepared_polygon1 = PreparedGeometry(polygon1)
    for geom2 in (polygon2, point2, polygon_empty):
        assert polygon1.disjoint(geom2) == prepared_polygon1.disjoint(geom2)
        assert polygon1.touches(geom2) == prepared_polygon1.touches(geom2)
        assert polygon1.intersects(geom2) == prepared_polygon1.intersects(
            geom2)
        assert polygon1.crosses(geom2) == prepared_polygon1.crosses(geom2)
        assert polygon1.within(geom2) == prepared_polygon1.within(geom2)
        assert polygon1.contains(geom2) == prepared_polygon1.contains(geom2)
        assert polygon1.overlaps(geom2) == prepared_polygon1.overlaps(geom2)
Пример #2
0
def test_prepared_predicates():
    # check prepared predicates give the same result as regular predicates
    polygon1 = Polygon([
        (0, 0), (0, 1), (1, 1), (1, 0), (0, 0)
    ])
    polygon2 = Polygon([
        (0.5, 0.5), (1.5, 0.5), (1.0, 1.0), (0.5, 0.5)
    ])
    point2 = Point(0.5, 0.5)
    polygon_empty = Polygon()
    prepared_polygon1 = PreparedGeometry(polygon1)
    for geom2 in (polygon2, point2, polygon_empty):
        assert polygon1.disjoint(geom2) == prepared_polygon1.disjoint(geom2)
        assert polygon1.touches(geom2) == prepared_polygon1.touches(geom2)
        assert polygon1.intersects(geom2) == prepared_polygon1.intersects(geom2)
        assert polygon1.crosses(geom2) == prepared_polygon1.crosses(geom2)
        assert polygon1.within(geom2) == prepared_polygon1.within(geom2)
        assert polygon1.contains(geom2) == prepared_polygon1.contains(geom2)
        assert polygon1.overlaps(geom2) == prepared_polygon1.overlaps(geom2)
Пример #3
0
def test_prepared_geometry():
    polygon = Polygon([(0, 0), (1, 0), (1, 1), (0, 1)])
    p = PreparedGeometry(polygon)
    assert p.contains(Point(0.5, 0.5))
    assert not p.contains(Point(0.5, 1.5))
Пример #4
0
def test_prepared_geometry():
    polygon = Polygon([(0, 0), (1, 0), (1, 1), (0, 1)])
    p = PreparedGeometry(polygon)
    assert p.contains(Point(0.5, 0.5))
    assert not p.contains(Point(0.5, 1.5))