For the time being, only DMSH compacted format is 'supported' by the module:
from core_base import AviationBaseClass class PredeterminedCoordinates2DD(AviationBaseClass): def __init__(self): AviationBaseClass.__init__(self) self._lat_dd = None self._lon_dd = None @staticmethod def check_dms_parts(d, m, s, ctype): result = None if ctype == 'LAT': if -90 <= d <= 90: result = True else: result = False elif ctype == 'LON': if -180 <= d <= 180: result = True else: result = False if m < 0 or m >= 60: result = False else: result = True if s < 0 or s >= 60: result = False else: result = True return result def dmsh2dd(self, dms_lat, dms_lon): self.err_msg = '' try: h = dms_lat[-1] if h in ['N', 'S']: try: lat_d = int(dms_lat[0:2]) lat_m = int(dms_lat[2:4]) lat_s = float(dms_lat[4:-1]) if self.check_dms_parts(lat_d, lat_m, lat_s, 'LAT') is False: self.err_msg += 'Latitude error' self.is_valid = False else: self.lat_dd = float(lat_d) + float(lat_m) / 60 + lat_s / 3600 except ValueError: self.err_msg += 'Latitude error' self.is_valid = False else: self.err_msg += 'Latitude error' self.is_valid = False except: self.err_msg += 'Latitude error' self.is_valid = False try: h = dms_lon[-1] if h in ['E', 'W']: try: lon_d = int(dms_lon[0:3]) lon_m = int(dms_lon[3:5]) lon_s = float(dms_lon[5:-1]) if self.check_dms_parts(lon_d, lon_m, lon_s, 'LON') is False: self.err_msg += 'Longitude error' self.is_valid = False else: self.lon_dd = float(lon_d) + float(lon_m) / 60 + lon_s / 3600 except ValueError: self.err_msg += 'Longitude error' self.is_valid = False else: self.err_msg += 'Longitude error' self.is_valid = False except: self.err_msg += 'Longitude error' self.is_valid = False if self.lat_dd is not None and self.lon_dd is not None: self.is_valid = True @property def lat_dd(self): return self._lat_dd @lat_dd.setter def lat_dd(self, value): self._lat_dd = value @property def lon_dd(self): return self._lon_dd @lon_dd.setter def lon_dd(self, value): self._lon_dd = value
Module can be also found here: https://github.com/strpaw/aviation_gis_tools2/blob/master/core_predermined_angle.py
No comments:
Post a Comment