Ejemplo n.º 1
0
def test_relate_pattern():
    g = shapely.linestrings([(0, 0), (1, 0), (1, 1)])
    polygon = shapely.box(0, 0, 2, 2)
    assert shapely.relate(g, polygon) == "11F00F212"
    assert shapely.relate_pattern(g, polygon, "11F00F212")
    assert shapely.relate_pattern(g, polygon, "*********")
    assert not shapely.relate_pattern(g, polygon, "F********")
Ejemplo n.º 2
0
def test_relate_pattern_non_scalar():
    with pytest.raises(ValueError, match="only supports scalar"):
        shapely.relate_pattern([point] * 2, polygon, ["*********"] * 2)
Ejemplo n.º 3
0
def test_relate_pattern_non_string(pattern):
    with pytest.raises(TypeError, match="expected string"):
        shapely.relate_pattern(point, polygon, pattern)
Ejemplo n.º 4
0
def test_relate_pattern_incorrect_length():
    with pytest.raises(shapely.GEOSException, match="Should be length 9"):
        shapely.relate_pattern(point, polygon, "**")

    with pytest.raises(shapely.GEOSException, match="Should be length 9"):
        shapely.relate_pattern(point, polygon, "**********")
Ejemplo n.º 5
0
def test_relate_pattern_none(g1, g2):
    assert shapely.relate_pattern(g1, g2, "*" * 9).item() is False
Ejemplo n.º 6
0
def test_relate_pattern_empty():
    with ignore_invalid():
        # Empty geometries give 'invalid value encountered' in all predicates
        # (see https://github.com/libgeos/geos/issues/515)
        assert shapely.relate_pattern(empty, empty, "*" * 9).item() is True
Ejemplo n.º 7
0
 def relate_pattern(self, other, pattern):
     """Returns True if the DE-9IM string code for the relationship between
     the geometries satisfies the pattern, else False"""
     return bool(shapely.relate_pattern(self, other, pattern))