def relative_location(self) : gps = get("gps") compass = get("compass") polar_to_waypoint = gps.latlong.gc_polar_to(self.latlong) waypoint_bearing = int(round(polar_to_waypoint.bearing,0)) relative_bearing = int(round((waypoint_bearing - compass.bearing + 360 ) % 360, 0)) distance = round(convert.value(polar_to_waypoint.distance,"Nm","km"),1) if distance > 1 : string =str(distance) + " km" else : string = str(int(round(convert.value(distance,"km","m"),0))) + " m" string = self.name + " is " + string + " away " + geo.degrees_to_compass_point(waypoint_bearing) + " . " string += " The Relative bearing is " + str(geo.degrees_to_hours(relative_bearing)) + " oclock " return string
def eta(self): gps = get("gps") polar_to_waypoint = gps.latlong.gc_polar_to(self.latlong) waypoint_bearing = int(round(polar_to_waypoint.bearing, 0)) relative_bearing = (waypoint_bearing - gps.courseOverGround + 360) % 360 distance = round(polar_to_waypoint.distance, 2) speed = round(convert.value(gps.speedOverGround, "kt", "kph"), 1) string = "" if relative_bearing > 270 or relative_bearing < 90: dir = "toward" else: dir = "away from" vmg = round(speed * math.cos(math.radians(relative_bearing)), 1) course = int(gps.courseOverGround) if vmg != 0.0: if dir == "toward": hours = round(distance / vmg, 2) if hours < 1.0: minutes = int(round(hours * 60, 0)) string += " Arrival in " + str(minutes) + " minutes time." else: string += " Arrival in " + str(hours) + " hours time." else: string += "you are stationary." if self.datetime is not None: string += " Due in " + date_time.time_to_go( self.datetime) + " time." return string
def eta(self) : gps = get("gps") polar_to_waypoint = gps.latlong.gc_polar_to(self.latlong) waypoint_bearing = int(round(polar_to_waypoint.bearing,0)) relative_bearing = (waypoint_bearing - gps.courseOverGround + 360 ) % 360 distance = round(polar_to_waypoint.distance,2) speed = round(convert.value(gps.speedOverGround,"kt","kph"),1) string = "" if relative_bearing > 270 or relative_bearing < 90 : dir = "toward" else : dir = "away from" vmg = round(speed * math.cos(math.radians(relative_bearing)),1) course = int(gps.courseOverGround) if vmg != 0.0 : if dir == "toward" : hours = round(distance / vmg,2) if hours < 1.0 : minutes = int(round(hours * 60 ,0)) string += " Arrival in " + str(minutes) + " minutes time." else : string += " Arrival in " + str(hours) + " hours time." else : string += "you are stationary." if self.datetime is not None : string += " Due in " + date_time.time_to_go(self.datetime) + " time." return string
def relative_location(self): gps = get("gps") compass = get("compass") polar_to_waypoint = gps.latlong.gc_polar_to(self.latlong) waypoint_bearing = int(round(polar_to_waypoint.bearing, 0)) relative_bearing = int( round((waypoint_bearing - compass.bearing + 360) % 360, 0)) distance = round(convert.value(polar_to_waypoint.distance, "Nm", "km"), 1) if distance > 1: string = str(distance) + " km" else: string = str(int(round(convert.value(distance, "km", "m"), 0))) + " m" string = self.name + " is " + string + " away " + geo.degrees_to_compass_point( waypoint_bearing) + " . " string += " The Relative bearing is " + str( geo.degrees_to_hours(relative_bearing)) + " oclock " return string
def as_kml(self) : distance = convert.value(self.length()[0],"Nm","km") kml = "<Placemark><name>" + self.name + "</name>" kml += "<description>" + "Length along path " + str(round(distance,2)) + " km" + "</description>" kml += "<LineString><altitudeMode>absolute</altitudeMode><coordinates>" file = open("log/"+self.name+".txt","r") for line in file.readlines(): if line == "": continue data = line.strip().split(",") if data[0] == "gps" : latitude = data[2] longitude = data[3] altitude = data[4] coords = ",".join((str(round(float(longitude),4)), str(round(float(latitude),4)) , str(round(float(altitude),4)) )) kml+= coords + "\n" kml += "</coordinates></LineString>" kml += "</Placemark>" return kml
def relative_velocity(self) : gps = get("gps") polar_to_waypoint = gps.latlong.gc_polar_to(self.latlong) waypoint_bearing = int(round(polar_to_waypoint.bearing,0)) relative_bearing = (waypoint_bearing - gps.courseOverGround + 360 ) % 360 distance = round(polar_to_waypoint.distance,2) speed = round(convert.value(gps.speedOverGround,"kt","kph"),1) if relative_bearing > 270 or relative_bearing < 90 : dir = "toward" else : dir = "away from" vmg = round(speed * math.cos(math.radians(relative_bearing)),1) course = int(gps.courseOverGround) if vmg != 0.0 : vmg_text= "you are moving "+ dir + " " + self.name + " at " + str(abs(vmg)) + " kph " + " relative bearing " + str(int(round(relative_bearing,0))) else : vmg_text = "you are stationary." return vmg_text
def relative_velocity(self): gps = get("gps") polar_to_waypoint = gps.latlong.gc_polar_to(self.latlong) waypoint_bearing = int(round(polar_to_waypoint.bearing, 0)) relative_bearing = (waypoint_bearing - gps.courseOverGround + 360) % 360 distance = round(polar_to_waypoint.distance, 2) speed = round(convert.value(gps.speedOverGround, "kt", "kph"), 1) if relative_bearing > 270 or relative_bearing < 90: dir = "toward" else: dir = "away from" vmg = round(speed * math.cos(math.radians(relative_bearing)), 1) course = int(gps.courseOverGround) if vmg != 0.0: vmg_text = "you are moving " + dir + " " + self.name + " at " + str( abs(vmg)) + " kph " + " relative bearing " + str( int(round(relative_bearing, 0))) else: vmg_text = "you are stationary." return vmg_text
def velocity (self) : speed = round(convert.value(self.speedOverGround,"kt","kph"),1) course = int(self.courseOverGround) points = geo.degrees_to_compass_point(course) string = "Speed is "+ str(speed) + " kph " + " at " + str(course) + " degrees " + " towards " + points return string
def distance(self, units="Nm"): gps = get("gps") distance = gps.latlong.gc_polar_to(self.latlong).distance return convert.value(distance, "Nm", units)
def distance(self,units="Nm") : gps = get("gps") distance = gps.latlong.gc_polar_to(self.latlong).distance return convert.value(distance,"Nm",units)