Example #1
0
    def xy_to_coordinates(self,x,y):
        xleft, ytop, w, h = self.allocation
        xrel=w/2-x
        yrel=h/2-y
        #if xrel==0 and yrel==0: return self.session.sleek_position
        radius = self.get_radar_pixel_radius(w,h)        
        pixel_distance = math.sqrt((xrel*xrel)+(yrel*yrel))
        dist = pixel_distance / radius * RADAR_RADIUS_IN_KM        
        head = math.degrees(math.atan2(xrel,-yrel))+180

        head += self._session.sleek_position.heading
        coord = Coordinates()
        coord.set_from_heading_and_distance(self._session.sleek_position, head, dist)
        return coord
Example #2
0
 def on_add(self, widget, data=None):
     clipboard = gtk.Clipboard()
     text = clipboard.wait_for_text()
     wp = None
     if text != None:
         try:
             coord = Coordinates.parse_string(text)
             wp =  Waypoint(coord.lat, coord.lon, coord.alt)
         except(ValueError):
             pass
     
     if wp == None:
         pos = self._session.sleek_position
         wp = Waypoint()
         wp.lat=pos.lat
         wp.lon=pos.lon
         wp.alt=pos.alt
     
     new_row = self._session.wpList.append(self._session.get_manual_list_iter(),(wp,))
Example #3
0
 def on_latlon_edited( self, cell, path, new_text, model ):
     c = Coordinates.parse_string(new_text)
     wp = model[path][0]
     wp.lat = c.lat
     wp.lon = c.lon
     print wp.strlatlon()