コード例 #1
0
ファイル: xgps.py プロジェクト: idaohang/CIS2750-GPS-TOOL
def updateMap():
	wayptColNum=0
	if wayptColour.get()=="red":
		wayptColNum=0
	if wayptColour.get()=="blue":
		wayptColNum=1
	if wayptColour.get()=="green":
		wayptColNum=2
		
	trkptColNum=0
	if trkptColour.get()=="red":
		trkptColNum=0
	if trkptColour.get()=="blue":
		trkptColNum=1
	if trkptColour.get()=="green":
		trkptColNum=2
		

	#Start a new GMapData session. Full source code found at GMapData.py
	gmd = GMapData( "XGPS Kelvin Lau 0595198", [waypts[0][0],waypts[0][1]], 12 )
	index=0
	#Setting the route and track color from global variables
	gmd.setColors(routeColour.get())
	gmd.setColors(trackColour.get())
	#If waypt is set to 'show'
	if wayptRadio.get()==1:
		for i in range(len(waypts)):
			gmd.addPoint([waypts[i][0], waypts[i][1]])
			gmd.addOverlay(i, 1, wayptColNum)
		index = int(len(waypts))

	#If route is set to 'show'
	if routeRadio.get()==1:
		for i in range(len(routes)):
			#if element i in the list is selected
			if routeList.selection_includes(i):
				#copy point information
				route = routes[i]
				for j in range(2, len(route)):
					gmd.addPoint([waypts[route[j]][0], waypts[route[j]][1]])
					gmd.addOverlay(index, len(route)-2, 3)
				index += len(route)-2
		
	#If trackpoint is set to 'show'	
	if trkptRadio.get()==1:
		for i in range(len(trkpts)):
			gmd.addPoint([trkpts[i][0], trkpts[i][1]])
			gmd.addOverlay(index+i, 1, trkptColNum)
		index = int(len(trkpts))
		
	#If trackpoint is set to 'show'	
	if trackRadio.get()==1:
		nextSeq=IntVar()
		for i in range(len(tracks)):
			#if element i in the list is selected
			if trackList.selection_includes(i):
				#copy point information
				track = tracks[i]
				#if it is the last element
				if i+1==int(len(tracks)):
					nextSeq = int(len(trkpts)) - track[0]
				else:
					nextSeq = tracks[i+1][0] - track[0]
				for j in range(nextSeq):
					gmd.addPoint([trkpts[track[0]-1+j][0], trkpts[track[0]-1+j][1]])
					gmd.addOverlay(index+j, nextSeq, 4)

	#generate HTML to serve
	gmd.serve( "public_html/index.html" );

	#launch browser
	launchBrowser( "http://localhost:45198/" )
コード例 #2
0
ファイル: xgps.py プロジェクト: dfarr/gps
def updateDisplay():
	
	if filename != () and filename != '':
		# calculate the average lat/lon
		global waypts, trkpts, routes, tracks
		lat = 0
		lon = 0
		avgLat = 0
		avgLon = 0
		
		for item in waypts:
			lat = lat + item[0]
			lon = lon + item[1]
			
		for item in trkpts:
			lat = lat + item[0]
			lon = lon + item[1]
			
		avgLat = lat / (len(waypts) + len(trkpts))
		avgLon = lon / (len(waypts) + len(trkpts))
		
		# make the map, centre it at the average lat/lon
		gMap = GMapData(filename, [avgLat, avgLon], 10)
		count = 0
		
		# set the colours 0->routes, 1->tracks
		colours = (rColour, trColour, "#FFFFFF")
		gMap.setColors(colours)
		
		# add the waypoints
		if(w.get() == 0):
			for item in waypts:
				gMap.addPoint(item)
				gMap.addOverlay(count, 1, wColour)
				count = count + 1
		
		# add the trackpoints
		if(t.get() == 0):
			for item in trkpts:
				gMap.addPoint(item)
				gMap.addOverlay(count, 1, tColour)
				count = count + 1
			
		# add the routes
		rSelect = routeList.curselection()
		rSelect = map(int, rSelect)
		
		if(r.get() == 0):
			for index in rSelect:
				nLegs = 0
				start = count
				
				for leg in routes[index][2]:
					gMap.addPoint(waypts[leg])
					count = count + 1
					nLegs = nLegs + 1
					
				gMap.addOverlay(start, nLegs, 0)
			
		# add the tracks
		trSelect = trackList.curselection()
		trSelect = map(int, trSelect)
		
		if(tr.get() == 0):
			for index in trSelect:
				
				# get the upper value
				if(index < len(tracks) - 1):
					upper = tracks[index + 1][0]
				else:
					upper = len(trkpts) - 1
				
				nTracks = 0
				start = count
				for trk in range(tracks[index][0], upper - 1):
					gMap.addPoint(trkpts[trk])
					count = count + 1
					nTracks = nTracks + 1
					
				gMap.addOverlay(start, nTracks, 1)
			
		gMap.serve("public_html/index.html")
		launchBrowser("http://localhost:49099/")