Example #1
0
    def test_merge_subsite_report_errors(self):
        overlap_area = MaterialArea(rect(5, 5, 7, 7),
                                    material=self.grass,
                                    parent_site=self.subsite,
                                    id="{Overlap area}")

        cleaner = SiteNodeGeometryCleaner(self.mainsite)

        with self.assertRaises(InconsistentGeometricModel):
            cleaner.merge_subsite(self.subsite)
Example #2
0
    def test_sorting_material_area_reverse_order(self):
        cleaner = SiteNodeGeometryCleaner(self.mainsite)

        self.assert_pos_and_insert(cleaner, self.grass_area, 0)
        self.assertEqual(cleaner.material_areas_inner_first(),
                         ['{Grass area}'])

        self.assert_pos_and_insert(cleaner, self.waterbody, 0)
        self.assertEqual(cleaner.material_areas_inner_first(),
                         ['{Water body}', '{Grass area}'])
Example #3
0
 def test_sorting_material_problems(self):
     # Build a material area which touches another one.
     grass_area_coords = [(0, 9), (12, 9), (12, 10), (0, 10)]
     other_grass = MaterialArea(grass_area_coords,
                                material=self.grass,
                                parent_site=self.mainsite,
                                id="{Other grass area}")
     self.mainsite.add_child(other_grass)
     cleaner = SiteNodeGeometryCleaner(self.mainsite)
     cleaner.process_material_areas()
     problems = cleaner.check_issues_with_material_area_order()
     self.assertEqual(problems, [('{Grass area}', '{Other grass area}')])
Example #4
0
    def test_add_and_clean_level_curves(self):
        cleaner = SiteNodeGeometryCleaner(self.mainsite)

        cleaner.process_level_curves()

        self.assertTrue(cleaner.geom['{Level curve A}'].equals(
            self.cleaned_level_A_shape))
        # Not directly in sitenode
        with self.assertRaises(KeyError):
            cleaner['{Level curve B}']
        # Already clean
        self.assertTrue(cleaner.geom['{Water body}'].equals(
            self.waterbody.shape))
Example #5
0
    def test_export_subsite_feature(self):
        cleaner_mainsite = SiteNodeGeometryCleaner(self.mainsite)
        cleaner_subsite = SiteNodeGeometryCleaner(self.subsite)
        cleaner_subsite.process_level_curves()

        cleaner_mainsite.import_cleaned_geometries_from(cleaner_subsite)

        self.assertTrue(cleaner_mainsite.geom['{Level curve B}'].equals(
            self.cleaned_level_B_shape))
Example #6
0
    def test_add_and_clean_material_area(self):
        overlap_area = MaterialArea(rect(5, 7, 7, 9),
                                    material=self.grass,
                                    parent_site=self.mainsite,
                                    id="{Overlap area}")
        in_hole_scope_area = MaterialArea(rect(6, 6, 7, 7),
                                          material=self.grass,
                                          parent_site=self.mainsite,
                                          id="{In hole area}")
        cleaner = SiteNodeGeometryCleaner(self.mainsite)

        cleaner.process_material_areas()

        self.assertIn("{Overlap area}", cleaner.erroneous_overlap)
        self.assertIn("{In hole area}", cleaner.ignored_features)
        self.assertTrue(cleaner.geom["{Grass area}"].equals(
            self.grass_area.shape))
Example #7
0
    def test_water_body_info(self):
        cleaner = SiteNodeGeometryCleaner(self.mainsite)

        cleaner.process_level_curves()
        cleaner.process_material_areas()

        water_shape, water_info = cleaner['{Water body}']
        self.assertEqual(water_info["altitude"], self.altitude_water)
Example #8
0
    def test_merge_subsite_OK(self):
        cleaner = SiteNodeGeometryCleaner(self.mainsite)
        cleaner.process_all_features()

        cleaner.merge_subsite(self.subsite)

        self.assertTrue(cleaner.geom['{Level curve A}'].equals(
            self.cleaned_level_A_shape))
        self.assertTrue(cleaner.geom['{Level curve B}'].equals(
            self.cleaned_level_B_shape))
Example #9
0
    def test_merge_subsite_material(self):
        self.subgrass = MaterialArea(rect(6, 7, 7, 8),
                                     material=self.grass,
                                     id="{Grass in subsite}",
                                     parent_site=self.subsite)
        cleaner = SiteNodeGeometryCleaner(self.mainsite)
        cleaner.process_all_features()
        cleaner.merge_subsite(self.subsite)

        self.assertIn(self.subgrass.id, cleaner.geom)
        geom, info = cleaner[self.subgrass.id]
        self.assertEqual(info['material'], self.grass.id)
Example #10
0
    def test_sorting_material_area_two_branches(self):
        site = SiteNode(rect(0, 0, 12, 12), id='{Main site}')
        cleaner = SiteNodeGeometryCleaner(self.mainsite)

        cleaner.process_material_areas()
        self.assertEqual(cleaner.check_issues_with_material_area_order(), [])