Esempio n. 1
0
def test_path_selfintersection_subpath():
    p1 = "M0 0L1 1M0 1L1 0"
    mock_elem = {"id": "theid", "d": p1}

    checker = IntersectionChecker()
    res = list(checker(mock_elem))
    eq_(res, [])

    collect_res = list(checker.collect())
    eq_(len(collect_res), 1)
    collect_res = collect_res[0]
    eq_(collect_res.elem, mock_elem)
    eq_(unicode(collect_res), "intersection found: theid (intersection: POINT (0.5 0.5))")
Esempio n. 2
0
def test_selfintersect_L_and_Z():
    """
    a Z-shape with a closepath at the end intersects itself
    """
    p1 = "M1 0 0 0 1 1 0 1 Z"
    mock_elem = {"id": "theid", "d": p1}

    checker = IntersectionChecker()
    res = list(checker(mock_elem))
    eq_(res, [])

    collect_res = list(checker.collect())
    eq_(len(collect_res), 1)
    collect_res = collect_res[0]
    eq_(collect_res.elem, mock_elem)
    eq_(unicode(collect_res), "self-intersection found: theid")
Esempio n. 3
0
def test_selfintersect_M_only_subpath():
    """
    M with more than one point as argument is the same as M + L
    """
    p1 = "M0 0 1 1M0 1 1 0"
    mock_elem = {"id": "theid", "d": p1}

    checker = IntersectionChecker()
    res = list(checker(mock_elem))
    eq_(res, [])

    collect_res = list(checker.collect())
    eq_(len(collect_res), 1)
    collect_res = collect_res[0]
    eq_(collect_res.elem, mock_elem)
    eq_(unicode(collect_res), "intersection found: theid (intersection: POINT (0.5 0.5))")
Esempio n. 4
0
def test_straight_intersect():
    """
    two lines with an intersection
    """
    p1 = "M0 0 1 1"
    p2 = "M1 0 0 1"
    e1 = {"id": "elem1", "d": p1}
    e2 = {"id": "elem2", "d": p2}

    checker = IntersectionChecker()
    res = list(checker(e1))
    eq_(res, [])
    res = list(checker(e2))
    eq_(res, [])

    collect_res = list(checker.collect())
    eq_(len(collect_res), 1)
    collect_res = collect_res[0]
    eq_(collect_res.elem, e2)
    eq_(unicode(collect_res), "intersection found: elem2 (intersection: POINT (0.5 0.5))")