Beispiel #1
0
    def write_tin(cls,
                  feature_list_a,
                  feature_list_b,
                  path,
                  list_of_list=True):
        if not os.path.exists(os.path.dirname(path)):
            raise RuntimeError("the passed path does not exist: %s" % path)

        path = Helper.truncate_too_long(path)

        if not isinstance(feature_list_a, list):
            raise RuntimeError(
                "the passed parameter as feature_list_a is not a list: %s" %
                type(feature_list_a))

        if not isinstance(feature_list_b, list):
            raise RuntimeError(
                "the passed parameter as feature_list_b is not a list: %s" %
                type(feature_list_b))

        s57 = S57()
        s57.create_tin_file(filename=path,
                            geo2edges_a=feature_list_a,
                            geo2edges_b=feature_list_b,
                            list_of_list=list_of_list)
Beispiel #2
0
    def _prepare_fff_list(cls, s57_path: str, s57_idx: int):
        selected_features = list()

        # open the file
        s57 = S57()
        s57.set_input_filename(s57_path)
        s57.read()
        cur_s57 = s57.input_s57file

        # retrieve all features
        all_features = cur_s57.rec10s
        logger.debug("  [%d] all features: %d" % (s57_idx, len(all_features)))

        for ft in all_features:
            # skip if the feature has not position
            if (len(ft.geo2s) == 0) and (len(ft.geo3s) == 0):
                continue

            # skip if the feature has more than 1 node
            if (len(ft.geo2s) != 1) and (len(ft.geo3s) == 0):
                continue

            # logger.debug("%s" % ft.acronym)

            selected_features.append(ft)

        nr_selected_features = len(selected_features)
        logger.debug("  [%d] selected features: %d" %
                     (s57_idx, nr_selected_features))

        return selected_features
Beispiel #3
0
    def truncate(self, input_file, output_file, decimal_places):

        try:
            s57 = S57()
            s57.set_input_filename(input_file)
            s57.read()
            s57.depth_truncate(output_file, decimal_places)

            return True

        except Exception as e:
            traceback.print_exc()
            logger.warning("Issue in truncating, %s" % e)
            return False
Beispiel #4
0
    def write_bluenotes(cls, feature_list, path, list_of_list=True):
        if not os.path.exists(os.path.dirname(path)):
            raise RuntimeError("the passed path does not exist: %s" % path)

        path = Helper.truncate_too_long(path)

        if not isinstance(feature_list, list):
            raise RuntimeError(
                "the passed parameter as feature_list is not a list: %s" %
                type(feature_list))

        s57 = S57()
        s57.create_blue_notes_file(filename=path,
                                   geo2notes=feature_list,
                                   list_of_list=list_of_list)
Beispiel #5
0
    def _read_ss_file(self, ss_path):
        """Read the SS file"""
        try:
            ss = S57()
            ss.set_input_filename(ss_path)
            ss.read()
            self._cur_ss = ss.input_s57file
            self._cur_ss_path = ss_path
            self._cur_ss_basename = os.path.basename(self._cur_ss_path)

        except Exception as e:
            self._cur_ss = None
            self._cur_ss_path = None
            self._cur_ss_basename = None
            raise e
Beispiel #6
0
    def _read_s57_file(self, s57_path):
        """Read the S57 file"""
        try:
            s57 = S57()
            s57.set_input_filename(s57_path)
            s57.read()
            self._cur_s57 = s57.input_s57file
            self._cur_s57_path = s57_path
            self._cur_s57_basename = os.path.basename(self._cur_s57_path)
            # logger.debug("Read S57 file: %s %s" % (s57_path, self._cur_s57))

        except Exception as e:
            self._cur_s57 = None
            self._cur_s57_path = None
            self._cur_s57_basename = None
            raise e
Beispiel #7
0
    def write_soundings(cls, feature_list, path, list_of_list=False):
        """Feature list as list of long, lat, depth"""

        if not os.path.exists(os.path.dirname(path)):
            raise RuntimeError("the passed path does not exist: %s" % path)

        path = Helper.truncate_too_long(path)

        if not isinstance(feature_list, list):
            raise RuntimeError(
                "the passed parameter as feature_list is not a list: %s" %
                type(feature_list))

        s57 = S57()
        s57.create_soundings_file(filename=path,
                                  geo3s=feature_list,
                                  list_of_list=list_of_list)