Exemple #1
0
def test_is_point_inside_virtual_closed_polygon(p, expected):
    poly = [
        LatLong(0, 0),
        LatLong(10, 0),
        LatLong(10, 10),
        LatLong(0, 10),
        LatLong(0, 0)
    ]
    assert is_point_inside(p, poly) == expected
Exemple #2
0
def test_is_point_inside_real_polygon(p, expected):
    poly = [
        LatLong(55.4903, 65.2110),
        LatLong(55.4066, 65.2275),
        LatLong(55.4329, 65.3573),
        LatLong(55.4969, 65.3878),
        LatLong(55.5169, 65.3113),
        LatLong(55.4903, 65.2110)
    ]
    assert is_point_inside(p, poly) == expected
Exemple #3
0
    def __contains__(self, item):
        """Returns True if LatLong item inside polygon.
        """

        # too few points for polygon
        if len(self) < 3:
            return False

        # if polygon is not closed, add last point to the start
        if self._points[0] != self._points[-1]:
            self._points.insert(0, self._points[-1])

        return raycasting.is_point_inside(item, self._points)
Exemple #4
0
def test_is_point_inside_few_points():
    p = LatLong(0, 0)
    poly = [LatLong(0, 0)]
    assert not is_point_inside(p, poly)