Пример #1
0
    def test_delete_id(self):
        ix = GeoIndex('./test_indices', 'test_delete_id', int, int)

        ix.insert(1L, poly1)
        ix.insert(2L, poly2)
        ix.insert(3L, poly3)

        ix.delete(1)


        x = ix.within(cover)
        x = list(x)
        self.assertEqual(len(x), 2, "didn't drop one like we should have")
        self.assertEqual(sorted(x), [2,3], "Didn't pull back all ids")

        ix.bulk_delete([2,3])
        x = ix.within(cover)
        x = list(x)
        self.assertEqual(len(x) ,0)

        ix.drop()
Пример #2
0
    def test_insert_one(self):
        ix = GeoIndex('./test_indices', 'test_insert_one', int, int)
        ix.insert(1L, poly1)

        x = ix.within(cover)
        x = list(x)
        self.assertEqual(len(x), 1)
        self.assertEqual(x[0], 1L, "Geom in index doesn't overlap")

        x = ix.equals(poly1)
        x = list(x)
        self.assertEqual(len(x), 1)
        self.assertEqual(x[0], 1L, "Geom in index isn't exact")

        ix.drop()
Пример #3
0
    def test_insert_multiple(self):
        ix = GeoIndex('./test_indices', 'test_insert_multiple', int, int)
        ix.bulk_insert([(1, poly1), (2, poly2), (3, poly3)])

        x = ix.equals(poly1)
        x = list(x)
        self.assertEqual(len(x), 1)
        self.assertEqual(x[0], 1, "Geom in index for poly 1 isn't exact")
        x = ix.equals(poly2)
        x = list(x)
        self.assertEqual(len(x), 1)
        self.assertEqual(x[0], 2, "Geom in index for poly 2 isn't exact")
        x = ix.equals(poly3)
        x = list(x)
        self.assertEqual(len(x), 1)
        self.assertEqual(x[0], 3, "Geom in index for poly 3 isn't exact")

        x = ix.within(cover)
        x = list(x)
        self.assertEqual(len(x), 3)
        self.assertEqual(sorted(x), [1,2,3], "Didn't pull back all ids")

        ix.drop()