def test_rtree(self):
        from ocgis.spatial.index import SpatialIndex

        geom_mapping = {1: Point(1, 2)}
        si = SpatialIndex()
        si.add(1, Point(1, 2))
        ret = list(si.iter_intersects(Point(1, 2), geom_mapping))
        self.assertEqual(ret, [1])
Beispiel #2
0
    def test_rtree(self):
        from ocgis.spatial.index import SpatialIndex

        geom_mapping = {1: Point(1, 2)}
        si = SpatialIndex()
        si.add(1, Point(1, 2))
        ret = list(si.iter_intersects(Point(1, 2), geom_mapping))
        self.assertEqual(ret, [1])
Beispiel #3
0
 def test_iter_intersects_with_polygon(self):
     polygon = self.geom_michigan[1]
     si = SpatialIndex()
     points = self.geom_michigan_point_grid
     ids = list(points.keys())
     geoms = [points[i] for i in ids]
     si.add(ids, geoms)
     intersects_ids = list(si.iter_intersects(polygon, points))
     self.assertEqual(intersects_ids, [67])
Beispiel #4
0
 def test_iter_intersects(self):
     points = self.geom_michigan_point_grid
     si = SpatialIndex()
     ids = list(points.keys())
     geoms = [points[i] for i in ids]
     si.add(ids, geoms)
     intersects_ids = list(si.iter_intersects(self.geom_michigan, points))
     self.assertEqual(
         set(intersects_ids),
         set([
             22, 23, 24, 32, 33, 34, 35, 36, 42, 43, 44, 46, 56, 66, 67, 76
         ]))
Beispiel #5
0
 def test_keep_touches(self):
     points = self.geom_michigan_point_grid
     si = SpatialIndex()
     ids = list(points.keys())
     geoms = [points[i] for i in ids]
     si.add(ids, geoms)
     touch_geom = Point(
         *mapping(self.geom_michigan)['coordinates'][0][0][3])
     si.add(1000, touch_geom)
     points[1000] = touch_geom
     for keep_touches in [True, False]:
         intersects_ids = list(
             si.iter_intersects(self.geom_michigan,
                                points,
                                keep_touches=keep_touches))
         if keep_touches:
             self.assertIn(1000, intersects_ids)
         else:
             self.assertNotIn(1000, intersects_ids)