def test_line_inside_collection_of_points_does_not_intersect(self):
     geom1 = LineString([(0.5, 0), (0.5, 1)])
     geom2 = GeometryCollection(
         [Point(0, 0), Point(0, 1),
          Point(1, 0), Point(1, 1)])
     intersects = common.intersects(geom1, geom2)
     self.assertEqual(intersects, False)
Exemple #2
0
def intersects_with_index(rid, index, geom, geoms):
    """ Determines if a given geometry intersects any other supplied geometries
    by first using a spatial index to narrow down the search space

    Arguments:
        rid {int} -- index ID to exclude from search
        index {Index} -- spatial Index from rtrere
        geom {Shapely geometry} -- Query geometry
        geoms {list} -- List of Shapely geometries to check for intersection
            with

    Returns:
        boolean -- true if geom intersects one of geoms, false if not
    """
    buff = geom.buffer(1)
    ints = [geoms[int(i)] for i in index.intersection(buff.bounds) if i != rid]
    if any([intersects(ig, geom) for ig in ints]):
        return True
    return False
 def test_line_inside_mixed_collection_does_intersect(self):
     geom1 = LineString([(0.5, 0), (0.5, 1)])
     geom2 = GeometryCollection(
         [Point(0, 0), LinearRing([(0, 1), (1, 0), (1, 1)])])
     intersects = common.intersects(geom1, geom2)
     self.assertEqual(intersects, True)
 def test_line_on_polygon_edge_intersects(self):
     geom1 = LineString([(0, 0), (0, 2)])
     geom2 = Polygon([(4, 2), (0, 2), (0, 0), (4, 0)])
     intersects = common.intersects(geom1, geom2)
     self.assertEqual(intersects, True)
 def test_line_intersecting_linear_ring(self):
     geom1 = LineString([(1, 1), (3, 1)])
     geom2 = LinearRing([(2, 2), (0, 2), (0, 0), (2, 0)])
     intersects = common.intersects(geom1, geom2)
     self.assertEqual(intersects, True)
 def test_line_inside_linear_ring_does_not_intersect(self):
     geom1 = LineString([(1, 1), (3, 1)])
     geom2 = LinearRing([(4, 2), (0, 2), (0, 0), (4, 0)])
     intersects = common.intersects(geom1, geom2)
     self.assertEqual(intersects, False)
 def test_point_on_end_of_line_intersects(self):
     geom1 = Point(0, 0)
     geom2 = LineString([(0, 0), (2, 2)])
     intersects = common.intersects(geom1, geom2)
     self.assertEqual(intersects, True)
 def test_same_points_do_intersect(self):
     geom1 = Point(0, 0)
     geom2 = Point(0, 0)
     intersects = common.intersects(geom1, geom2)
     self.assertEqual(intersects, True)
 def test_different_points_do_not_intersect(self):
     geom1 = Point(0, 0)
     geom2 = Point(1, 1)
     intersects = common.intersects(geom1, geom2)
     self.assertEqual(intersects, False)