コード例 #1
0
ファイル: test_atlas.py プロジェクト: 5l1v3r1/atlas-2
    def test_relation_spatial_index(self):
        atlas = Atlas("resources/test.atlas")

        lower_left = geometry.location_with_degrees(37.999, -118.001)
        upper_right = geometry.location_with_degrees(38.001, -117.999)

        test_results = atlas.relations_with_entities_intersecting(
            Rectangle(lower_left, upper_right))
        self.assertEqual({atlas.relation(2)}, test_results)
コード例 #2
0
ファイル: test_atlas.py プロジェクト: 5l1v3r1/atlas-2
    def test_edge_spatial_index(self):
        atlas = Atlas("resources/test.atlas")

        test_location = geometry.location_with_degrees(39, -119.05)
        test_results = atlas.edges_containing(test_location)
        self.assertEqual({atlas.edge(1), atlas.edge(3)}, test_results)

        poly = Rectangle(
            geometry.location_with_degrees(38, -120), geometry.location_with_degrees(40, -117))
        test_results = atlas.edges_intersecting(poly)
        self.assertEqual({atlas.edge(1), atlas.edge(2), atlas.edge(3)}, test_results)
コード例 #3
0
ファイル: test_atlas.py プロジェクト: 5l1v3r1/atlas-2
    def test_line_spatial_index(self):
        atlas = Atlas("resources/test.atlas")

        test_location = geometry.location_with_degrees(38.02, -118.02)
        test_results = atlas.lines_containing(test_location)
        self.assertEqual({atlas.line(1)}, test_results)

        poly = Rectangle(
            geometry.location_with_degrees(38, -118), geometry.location_with_degrees(39, -119))
        test_results = atlas.lines_intersecting(poly)
        self.assertEqual({atlas.line(1), atlas.line(2)}, test_results)
コード例 #4
0
ファイル: test_spatial_index.py プロジェクト: 5l1v3r1/atlas-2
    def test_rtree(self):
        # The bounding box defined in this test should only encompass
        # test Points 1, 2, and 3 from the test atlas

        atlas = Atlas("resources/test.atlas")
        tree = _RTree(atlas.points())

        lower_left = geometry.location_with_degrees(37, -118.02)
        upper_right = geometry.location_with_degrees(39, -118)

        test_results = []
        for element in tree.get(Rectangle(lower_left, upper_right)):
            test_results.append(element)

        self.assertEqual({1, 2, 3}, set(test_results))
コード例 #5
0
ファイル: test_atlas.py プロジェクト: 5l1v3r1/atlas-2
    def test_node_spatial_index(self):
        atlas = Atlas("resources/test.atlas")

        lower_left = geometry.location_with_degrees(39, -119.04)
        upper_right = geometry.location_with_degrees(39.05, -119)

        # NOTE node 4 does not show up in results because it lies on the the polygon border
        test_results = atlas.nodes_within(Rectangle(lower_left, upper_right))
        self.assertEqual({atlas.node(2)}, test_results)

        test_results = atlas.nodes_within(
            Rectangle(lower_left, upper_right), lambda n: n.get_identifier() == 3)
        self.assertEqual(frozenset(), test_results)

        test_results = atlas.nodes_at(geometry.location_with_degrees(39, -119.05))
        self.assertEqual({atlas.node(3)}, test_results)
コード例 #6
0
ファイル: test_atlas.py プロジェクト: 5l1v3r1/atlas-2
    def test_point_spatial_index(self):
        atlas = Atlas("resources/test.atlas")

        lower_left = geometry.location_with_degrees(37, -118.02)
        upper_right = geometry.location_with_degrees(39, -118)

        # NOTE point 1 does not show up in the results because it lies on the polygon border
        test_results = atlas.points_within(Rectangle(lower_left, upper_right))
        self.assertEqual({atlas.point(2), atlas.point(3)}, test_results)

        test_results = atlas.points_within(
            Rectangle(lower_left, upper_right), lambda p: p.get_identifier() % 2 != 0)
        self.assertEqual({atlas.point(3)}, test_results)

        test_results = atlas.points_at(geometry.location_with_degrees(38, -118))
        self.assertEqual({atlas.point(1)}, test_results)
コード例 #7
0
ファイル: test_spatial_index.py プロジェクト: 5l1v3r1/atlas-2
    def test_basic_spatial_index_operations(self):
        atlas = Atlas("resources/test.atlas")

        index = SpatialIndex(atlas, EntityType.POINT, atlas.points())
        index.initialize_rtree()

        lower_left = geometry.location_with_degrees(37, -118.02)
        upper_right = geometry.location_with_degrees(39, -118)

        test_results = index.get(Rectangle(lower_left, upper_right))
        self.assertEqual(
            {atlas.point(2), atlas.point(3),
             atlas.point(1)}, test_results)

        test_results = index.get(Rectangle(lower_left, upper_right),
                                 lambda p: p.get_identifier() == 2)
        self.assertEqual({atlas.point(2)}, test_results)
コード例 #8
0
ファイル: test_atlas.py プロジェクト: 5l1v3r1/atlas-2
    def test_area_spatial_index(self):
        atlas = Atlas("resources/test.atlas")

        test_location = geometry.location_with_degrees(38.15, -118.03)
        test_results = atlas.areas_covering(test_location)
        self.assertEqual({atlas.area(2)}, test_results)

        test_results = atlas.areas_intersecting(atlas.area(2).as_polygon())
        self.assertEqual({atlas.area(1), atlas.area(2)}, test_results)