Пример #1
0
def get_poi():
    """
    get a txt file with GPS coordinates and other various infos.
    return a list of points: [name, lat, lon, color],
    natural-sorted by name and with some personal needs.

    this file format is from a Garmin waypoints file in TXT format,
    thanks to Mapsource export. make changes to this fonction
    to reflect your data.
    """
    try:
        poi = []
        with open(os.path.join(app.config['UPLOAD_FOLDER'], 'controle.txt'), 'r') as gps_poi:
            for line in gps_poi:
                if line.startswith('Waypoint'):
                    splitted_line = line.split()
                    name, color, latitude, longitude = splitted_line[1], splitted_line[-4], splitted_line[6], splitted_line[7]
                    point = geo.parse_position(latitude + " " + longitude)
                    poi.append([name, point[0], point[1], color])
    except:
        return list()

    # we want it sorted by name, real-life natural order
    poi = natsorted(poi, key=itemgetter(0))
    # start of the race is always at the end of the list on this file, should be on 1st place
    poi.insert(0, poi.pop())

    return poi
Пример #2
0
 def __iter__(self):
     with open(self.fichier) as f:
         for line in f:
             if line.startswith('Trackpoint'):
                 a = line.split()
                 lat, lon = geo.parse_position(a[1] + " " + a[2])
                 trace = {'id': self.identification, 'lat': lat, 'lon': lon}
                 yield trace
Пример #3
0
	def set_dest(self,*args):
		s=self.dest.get_text()
		pos=geo.parse_position(s)
		if pos==None:
			d = gtk.MessageDialog(type=gtk.MESSAGE_ERROR,buttons=gtk.BUTTONS_OK)
			d.set_markup("Invalid format.")
			d.run()
			d.destroy()
		else:
			if HAVE_MAP:
				self.map.draw_gps(pos[0],pos[1],0.)
			self.data_dest.set_text("Destination: %f\xc2\xb0 N %f\xc2\xb0 E" % pos)
			self.dest_pos=geo.xyz(*pos)
			self.update_data()