Beispiel #1
0
def convert_dives(overwrite_db=False):
    # WARNING! This will overwrite data in the db in place. Only run once and be sure what you're doing
    if not overwrite_db:
        return
    session = Session()
    dives = session.query(Dives)
    for dive in dives:
        print(dive.DiveInfoID)
        dive.Latitude = coord_db_decimal(dive.Latitude)
        dive.Longitude = coord_db_decimal(dive.Longitude)
    session.commit()
    session.close()
 def validate(self):
     if not self.missionid or not self.name.strip(
     ) or not self.lon or not self.lat or not self.info:
         self.error = 'Please fill in all fields'
     missions = mission_service.mission_ids()
     id_list = [y for x in missions for y in x]
     self.missionid = int(self.missionid)
     if self.missionid not in id_list:
         self.error = 'Mission ' + str(self.missionid) + ' does not exist'
     if self.format == 'dec_degree':
         self.lat = float(self.lat)
         self.lon = float(self.lon)
     elif self.format == 'deg_min':
         self.lat = coord_db_decimal(float(self.lat))
         self.lon = coord_db_decimal(float(self.lon))
     elif self.format == 'seaglider':
         self.lat = coord_db_decimal(float(self.lat), kongsberg=True)
         self.lon = coord_db_decimal(float(self.lon), kongsberg=True)
     else:
         self.error = 'coordinate format not recognised'
     if abs(self.lat) > 90 or abs(self.lon) > 180:
         self.error = 'coordinates out of bounds'