def run_qc_tools_v3(grid_path, flier_finder, holiday_finder, holiday_finder_mode, grid_qa, survey_name, output_shp=False, output_kml=False): from hyo2.qc.survey.project import SurveyProject from hyo2.qc import __version__ print("\n-->> running QC Tools (v.%s)" % __version__) grid_folder, grid_name = os.path.split(grid_path) prj = SurveyProject(output_folder=grid_folder) # disable output formats except .000 prj.output_svp = False prj.output_shp = False prj.output_kml = False prj.add_to_grid_list(grid_path) if survey_name is None: prj.clear_survey_label() else: prj.survey_label = survey_name if flier_finder: print('running flier finder on: %s' % grid_path) prj.set_cur_grid(path=grid_path) prj.open_to_read_cur_grid() prj.find_fliers_v8(height=None) saved = prj.save_fliers() if saved: print('- found fliers: %d' % prj.number_of_fliers()) else: print('- no fliers found') if holiday_finder: print('running holiday finder on: %s' % grid_path) prj.find_holes_v4(path=grid_path, mode=holiday_finder_mode) prj.output_shp = output_shp prj.output_kml = output_kml saved = prj.save_holes() if saved: print('- found holidays: certain %d, possible %d' % (prj.number_of_certain_holes(), prj.number_of_possible_holes())) else: print('- no holidays') if grid_qa: print('running grid qa on: %s' % grid_path) prj.set_cur_grid(path=grid_path) prj.open_to_read_cur_grid() tvu_qc_layers = prj.cur_grid_tvu_qc_layers() if len(tvu_qc_layers) > 0: prj.set_cur_grid_tvu_qc_name(tvu_qc_layers[0]) ret = prj.grid_qa_v5() print("- passed? %r" % ret) if grid_qa: prj.open_gridqa_output_folder() return if holiday_finder: prj.open_holes_output_folder() return if flier_finder: prj.open_fliers_output_folder() return
def run_find_fliers(self, args): if not os.path.exists(args.output_folder): raise RuntimeError('Unable to locate output folder: %s' % args.output_folder) out_folder = args.output_folder logger.debug('output folder: %s' % out_folder) # create the project prj = SurveyProject(output_folder=out_folder) if not os.path.exists(args.input_dtm): raise RuntimeError('Unable to locate input DTM: %s' % args.input_dtm) dtm_file = args.input_dtm logger.debug('input DTM: %s' % dtm_file) prj.add_to_grid_list(dtm_file) if args.s57_path is not None: if not os.path.exists(args.s57_path): raise RuntimeError('Unable to locate input S57: %s' % args.s57_path) s57_file = args.s57_path logger.debug('input S57: %s' % s57_file) prj.add_to_s57_list(s57_file) if args.enforce_height is not None: if args.enforce_height <= 0.0: raise RuntimeError('Invalid height: %s' % args.enforce_height) height_value = args.enforce_height # logger.debug('height: %s' % height_value) check_laplacian = args.check_laplacian check_curv = args.check_curv check_adjacent = args.check_adjacent check_slivers = args.check_slivers check_isolated = args.check_isolated check_edges = args.check_edges filter_designated = args.filter_designated filter_fff = args.filter_fff self._check_web_page( token='FFv8_%d%d%d%d%d%d_%d%d' % (check_laplacian, check_curv, check_adjacent, check_slivers, check_isolated, check_edges, filter_designated, filter_fff)) # actual execution for i, grid_path in enumerate(prj.grid_list): logger.debug(">>> #%d (%s)" % (i, grid_path)) prj.clear_survey_label() prj.set_cur_grid(path=grid_path) prj.open_to_read_cur_grid(chunk_size=4294967296) prj.find_fliers_v8(height=height_value, check_laplacian=check_laplacian, check_curv=check_curv, check_adjacent=check_adjacent, check_slivers=check_slivers, check_isolated=check_isolated, check_edges=check_edges, filter_fff=filter_fff, filter_designated=filter_designated) prj.close_cur_grid() prj.set_cur_grid(path=grid_path) prj.open_to_read_cur_grid(chunk_size=4294967296) prj.find_fliers_v8_apply_filters() saved = prj.save_fliers() if saved: logger.debug('Fliers saved')
try: # Trapping Exceptions like OSError (File permissions) logger.debug(">>>>>> #%03d (%s): processing ..." % (i, bag_path)) if calc_min_depth_tvu: height_value = prj.retrieve_min_depth_tvu(bag_path) prj.clear_survey_label() prj.open_grid(path=bag_path) prj.find_fliers_v8(height=height_value, check_laplacian=check_laplacian, check_curv=check_curv, check_adjacent=check_adjacent, check_slivers=check_slivers, check_isolated=check_isolated, check_edges=check_edges, filter_designated=filter_designated, filter_fff=filter_fff) prj.close_cur_grid() prj.open_grid(path=bag_path) prj.find_fliers_v8_apply_filters() saved = prj.save_fliers() if saved: bag_with_fliers_list.append(bag_path) nr_fliers_per_bag_dict[bag_path] = prj.number_of_fliers() tvu_height_per_bag_dict[bag_path] = height_value
prj.add_to_grid_list(r"C:\code\hyo2\processing\hyo2_qc\data\download\H13384_50cm_MLLW_testing_subset.csar") logger.debug(prj) for grid_path in prj.grid_list: logger.debug("grid: %s" % grid_path) prj.clear_survey_label() prj.open_grid(path=grid_path) prj.find_fliers_v8(height=height_value, check_laplacian=check_laplacian, check_curv=check_curv, check_adjacent=check_adjacent, check_slivers=check_slivers, check_isolated=check_isolated, check_edges=check_edges, edges_distance=edges_distance, edges_pct_tvu=edges_pct_tvu, filter_fff=filter_fff, filter_designated=filter_designated, export_proxies=False) prj.close_cur_grid() prj.set_cur_grid(path=grid_path) prj.open_to_read_cur_grid() prj.find_fliers_v8_apply_filters() saved = prj.save_fliers() if saved: prj.open_fliers_output_folder()