Exemplo n.º 1
0
    def test_jaccard_indexes_of_crossing_quadrangles(self):
        first_quadrangle = self.first_quadrangle
        second_quadrangle = self.second_quadrangle
        third_quadrangle = self.third_quadrangle
        fourth_quadrangle = self.fourth_quadrangle
        fifth_quadrangle = self.fifth_quadrangle

        index = RTreeConvexQuadrangleIndex((
            first_quadrangle,
            second_quadrangle,
            third_quadrangle,
            fourth_quadrangle,
            fifth_quadrangle,
        ))
        self.assertEqual(
            {
                first_quadrangle:
                ((first_quadrangle.area / 2) /
                 (first_quadrangle.area / 2 + fifth_quadrangle.area)),
                third_quadrangle:
                third_quadrangle.area / fifth_quadrangle.area,
                fourth_quadrangle:
                fifth_quadrangle.area / fourth_quadrangle.area,
                fifth_quadrangle:
                1.0,
            }, index.jaccard_indexes(fifth_quadrangle))
Exemplo n.º 2
0
    def test_clear(self):
        first_quadrangle = self.first_quadrangle
        second_quadrangle = self.second_quadrangle
        fourth_quadrangle = self.fourth_quadrangle

        index = RTreeConvexQuadrangleIndex(
            (first_quadrangle, second_quadrangle))
        index.clear()

        self.assertEqual(0, len(index))
        self.assertEqual({}, index.jaccard_indexes(fourth_quadrangle))
Exemplo n.º 3
0
    def test_discard(self):
        first_quadrangle = self.first_quadrangle
        fourth_quadrangle = self.fourth_quadrangle

        index = RTreeConvexQuadrangleIndex(
            (first_quadrangle, self.second_quadrangle))
        index.discard(self.second_quadrangle)

        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),
        )
Exemplo n.º 4
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),
        )
Exemplo n.º 5
0
    def test_jaccard_indexes_of_touching_quadrangles(self):
        first_quadrangle = self.first_quadrangle
        third_quadrangle = self.third_quadrangle

        index = RTreeConvexQuadrangleIndex((first_quadrangle, ))
        self.assertEqual({}, index.jaccard_indexes(third_quadrangle))
Exemplo n.º 6
0
    def test_jaccard_indexes_of_disjoint_quadrangles(self):
        first_quadrangle = self.first_quadrangle
        second_quadrangle = self.second_quadrangle

        index = RTreeConvexQuadrangleIndex((first_quadrangle, ))
        self.assertEqual({}, index.jaccard_indexes(second_quadrangle))