Example #1
0
    def test_add(self):
        first_quadrangle = self.first_quadrangle
        second_quadrangle = self.second_quadrangle
        fourth_quadrangle = self.fourth_quadrangle

        index = RTreeConvexQuadrangleIndex()
        index.add(first_quadrangle)
        index.add(second_quadrangle)

        self.assertEqual(2, len(index))
        self.assertEqual({first_quadrangle, second_quadrangle},
                         set(index.quadrangles))
        self.assertEqual(
            {
                first_quadrangle:
                first_quadrangle.area / fourth_quadrangle.area,
                second_quadrangle:
                second_quadrangle.area / fourth_quadrangle.area,
            },
            index.jaccard_indexes(fourth_quadrangle),
        )
Example #2
0
    def test_add_duplicates(self):
        first_quadrangle = self.first_quadrangle
        fourth_quadrangle = self.fourth_quadrangle

        index = RTreeConvexQuadrangleIndex()
        index.add(first_quadrangle)
        index.add(first_quadrangle)
        index.add(
            GEOSConvexQuadrangle(
                top_left=first_quadrangle.top_left,
                top_right=first_quadrangle.top_right,
                bottom_left=first_quadrangle.bottom_left,
                bottom_right=first_quadrangle.bottom_right,
            ))

        self.assertEqual(1, len(index))
        self.assertEqual({first_quadrangle}, set(index.quadrangles))
        self.assertEqual(
            {
                first_quadrangle:
                first_quadrangle.area / fourth_quadrangle.area,
            },
            index.jaccard_indexes(fourth_quadrangle),
        )