Пример #1
0
 def test_outputs(self):
     prj = BaseProject(projects_folder=testing.output_data_folder())
     prj.output_shp = True
     self.assertTrue(prj.output_shp)
     prj.output_kml = True
     self.assertTrue(prj.output_kml)
     prj.output_svp = True
     self.assertTrue(prj.output_svp)
Пример #2
0
 def test_clear_project_data(self):
     prj = BaseProject(projects_folder=testing.output_data_folder())
     prj.survey_label = "test"
     self.assertTrue(len(prj.survey_label) != 0)
     prj.clear_data()
     self.assertEqual(len(prj.s57_list), 0)
     self.assertEqual(len(prj.ss_list), 0)
     self.assertEqual(len(prj.survey_label), 0)
Пример #3
0
 def test_select_layers_in_cur_grid(self):
     prj = BaseProject(projects_folder=testing.output_data_folder())
     prj.add_to_grid_list(testing.input_test_files(".bag")[0])
     prj.set_cur_grid(testing.input_test_files(".bag")[0])
     prj.open_to_read_cur_grid()
     self.assertEqual(len(prj.selected_layers_in_cur_grid), 0)
     prj.selected_layers_in_cur_grid = [layer_types['depth'], ]
     self.assertEqual(len(prj.selected_layers_in_cur_grid), 1)
Пример #4
0
 def test_grid_read(self):
     prj = BaseProject(projects_folder=testing.output_data_folder())
     self.assertTrue(prj.cur_grid is None)
     self.assertFalse(prj.has_grid())
     with self.assertRaises(RuntimeError):
         _ = prj.cur_grid_basename
     prj.add_to_grid_list(testing.input_test_files(".bag")[0])
     prj.set_cur_grid(testing.input_test_files(".bag")[0])
     prj.open_to_read_cur_grid()
     self.assertTrue(prj.cur_grid is not None)
     self.assertTrue(prj.has_grid())
     self.assertGreater(len(prj.cur_grid_basename), 0)
Пример #5
0
 def test_cur_grid_shape(self):
     prj = BaseProject(projects_folder=testing.output_data_folder())
     prj.add_to_grid_list(testing.input_test_files(".bag")[0])
     prj.set_cur_grid(testing.input_test_files(".bag")[0])
     prj.open_to_read_cur_grid()
     self.assertEquals(prj.cur_grid_shape[0], 0)
     self.assertEquals(prj.cur_grid_shape[1], 0)
Пример #6
0
 def test_s57_list_add_real(self):
     prj = BaseProject(projects_folder=testing.output_data_folder())
     prj.add_to_s57_list(testing.input_test_files(".000")[0])
     self.assertEqual(len(prj.s57_list), 1)
     prj.add_to_s57_list(testing.input_test_files(".000")[0])
     self.assertEqual(len(prj.s57_list), 1)
     prj.remove_from_s57_list(testing.input_test_files(".000")[0])
     self.assertEqual(len(prj.s57_list), 0)
Пример #7
0
 def test_make_project_survey_label(self):
     prj = BaseProject(projects_folder=None)
     prj.add_to_s57_list(testing.input_test_files(".000")[0])
     prj.read_feature_file(testing.input_test_files(".000")[0])
     self.assertTrue(len(prj.survey_label) != 0)
     self.assertTrue(len(prj.survey_label) == 6)
     self.assertEqual(prj.survey_label, "tiny__")
Пример #8
0
 def test_s57_read(self):
     prj = BaseProject(projects_folder=testing.output_data_folder())
     self.assertTrue(prj.cur_s57 is None)
     self.assertFalse(prj.has_s57())
     self.assertEqual(len(prj.cur_s57_basename), 0)
     prj.read_feature_file(testing.input_test_files(".000")[0])
     self.assertTrue(prj.cur_s57 is not None)
     self.assertTrue(prj.has_s57())
     self.assertGreater(len(prj.cur_s57_basename), 0)
Пример #9
0
 def test_raise_window(self):
     BaseProject.raise_window()
Пример #10
0
 def test_s57_list(self):
     prj = BaseProject(projects_folder=testing.output_data_folder())
     self.assertEqual(len(prj.s57_list), 0)
Пример #11
0
 def test_s57_list_add_fake(self):
     prj = BaseProject(projects_folder=testing.output_data_folder())
     with self.assertRaises(RuntimeError):
         prj.add_to_s57_list("fake/fake.000")
Пример #12
0
 def test_make_project_survey_label_from_path(self):
     prj = BaseProject(projects_folder=None)
     survey_label = prj.make_survey_label_from_path("fake/H012345")
     self.assertTrue(len(survey_label) != 0)
     self.assertTrue(len(survey_label) == 6)
     self.assertEqual(survey_label, "H01234")
Пример #13
0
 def test_init_project_with_folder(self):
     prj = BaseProject(projects_folder=testing.output_data_folder())
     self.assertTrue(os.path.exists(prj.output_folder))
Пример #14
0
 def test_init_project_survey_label(self):
     prj = BaseProject(projects_folder=None)
     self.assertTrue(len(prj.survey_label) == 0)
Пример #15
0
    def test_cur_grid_has_layers(self):
        prj = BaseProject(projects_folder=testing.output_data_folder())
        with self.assertRaises(RuntimeError):
            prj.cur_grid_has_depth_layer()
        with self.assertRaises(RuntimeError):
            prj.cur_grid_has_product_uncertainty_layer()
        with self.assertRaises(RuntimeError):
            prj.cur_grid_has_density_layer()
        with self.assertRaises(RuntimeError):
            prj.cur_grid_has_tvu_qc_layer()
        with self.assertRaises(RuntimeError):
            prj.cur_grid_tvu_qc_layers()
        with self.assertRaises(RuntimeError):
            prj.set_cur_grid_tvu_qc_name("fake")

        prj.add_to_grid_list(testing.input_test_files(".bag")[0])
        prj.set_cur_grid(testing.input_test_files(".bag")[0])
        prj.open_to_read_cur_grid()
        self.assertTrue(prj.cur_grid_has_depth_layer())
        self.assertTrue(prj.cur_grid_has_product_uncertainty_layer())
        self.assertFalse(prj.cur_grid_has_density_layer())
        self.assertFalse(prj.cur_grid_has_tvu_qc_layer())
        self.assertEqual(len(prj.cur_grid_tvu_qc_layers()), 0)
        self.assertTrue(prj.has_bag_grid())
        self.assertFalse(prj.has_csar_grid())
Пример #16
0
 def test_init_project_field_profile(self):
     prj = BaseProject(projects_folder=testing.output_data_folder(), profile=BaseProject.project_profiles['field'])
     self.assertEqual(prj.active_profile, BaseProject.project_profiles['field'])
Пример #17
0
 def test_init_project_none_folder(self):
     prj = BaseProject(projects_folder=None)
     self.assertTrue(os.path.exists(prj.output_folder))
Пример #18
0
 def test_s57_list_clear(self):
     prj = BaseProject(projects_folder=testing.output_data_folder())
     prj.add_to_s57_list(testing.input_test_files(".000")[0])
     prj.clear_s57_list()
     self.assertEqual(len(prj.s57_list), 0)
Пример #19
0
 def test_default_output_folder(self):
     out = BaseProject.default_output_folder()
     self.assertTrue("Base" in out)
Пример #20
0
 def test_output_folder(self):
     prj = BaseProject(projects_folder=testing.output_data_folder())
     with self.assertRaises(RuntimeError):
         prj.output_folder = "C:/invalid/path/to/folder"
Пример #21
0
 def test_init_project_valid_profile(self):
     prj = BaseProject(projects_folder=testing.output_data_folder())
     self.assertTrue(prj.active_profile in BaseProject.project_profiles.values())
Пример #22
0
    def _bag_checks_v1(self, grid_file: str, idx: int, total: int) -> bool:

        quantum = 100.0 / total
        cur_quantum = quantum * idx

        self.progress.update(value=cur_quantum + quantum * 0.05,
                             text="[%d/%d] File opening" % (idx + 1, total))

        # we want to be sure that the label is based on the name of the new file input
        self._survey = BaseProject.make_survey_label_from_path(grid_file)
        self._grid_basename = os.path.basename(grid_file)

        # skip CSAR
        if not bag.BAGFile.is_bag(bag_path=grid_file):  # skip CSAR
            logger.debug('not a BAG file: %s' % grid_file)
            return False

        self._is_vr = bag.BAGFile.is_vr(bag_path=grid_file)
        if self._is_vr:
            logger.debug('detected VR BAG')

        self._bc_report = Report(lib_name=lib_name, lib_version=lib_version)

        self.progress.update(value=cur_quantum + quantum * 0.15,
                             text="[%d/%d] Structure checking" %
                             (idx + 1, total))

        self._bag_checks_v1_structure(grid_file=grid_file)

        self.progress.update(value=cur_quantum + quantum * 0.3,
                             text="[%d/%d] Metadata checking" %
                             (idx + 1, total))

        self._bag_checks_v1_metadata(grid_file=grid_file)

        self.progress.update(value=cur_quantum + quantum * 0.5,
                             text="[%d/%d] Elevation checking" %
                             (idx + 1, total))

        self._bag_checks_v1_elevation(grid_file=grid_file)

        self.progress.update(value=cur_quantum + quantum * 0.7,
                             text="[%d/%d] Uncertainty checking" %
                             (idx + 1, total))

        self._bag_checks_v1_uncertainty(grid_file=grid_file)

        self.progress.update(value=cur_quantum + quantum * 0.85,
                             text="[%d/%d] Tracking list checking" %
                             (idx + 1, total))

        self._bag_checks_v1_tracking_list(grid_file=grid_file)

        self.progress.update(value=cur_quantum + quantum * 0.95,
                             text="[%d/%d] Summary" % (idx + 1, total))

        self._bag_checks_v1_summary()

        output_pdf = os.path.join(
            self.bagchecks_output_folder, "%s.BCv1.%s.pdf" %
            (self._grid_basename, datetime.now().strftime("%Y%m%d.%H%M%S")))
        if self._noaa_nbs_profile:
            title_pdf = "BAG Checks v1 - Tests against NOAA OCS Profile"
        else:
            title_pdf = "BAG Checks v1 - Tests against General Profile"
        if self._bc_report.generate_pdf(output_pdf, title_pdf,
                                        use_colors=True):
            self._bc_pdf = output_pdf

        return True