Exemple #1
0
def mapSelect():
	cardSelect = mlb.curselection()
	geoFlag = 0
	photoFlag = 0
	if len(cardSelect) != 0:
		cardNumber = int(cardSelect[0])
		for i in range(0, len(cardList[cardNumber])):
			if cardList[cardNumber][i][0] == "GEO":
				if geoFlag == 0:
					geo = cardList[cardNumber][i][3]
					geoFlag = 1
			if cardList[cardNumber][i][0] == "PHOTO":
				photo = cardList[cardNumber][i][3]
				photoFlag = 1
			if cardList[cardNumber][i][0] == "ADR":
				address = cardList[cardNumber][i][3]

		if photoFlag == 1:
			if "http://" in photo:
				photoFlag = 2
			else:
				insertText("Invalid Photo property (in wrong format)\n")

		if geoFlag == 1:
			if len(geo) == 0:
				if photoFlag == 2:
					launchBrowser(photo)
					insertText("Valid Photo but invalid GEO\n")
					return
				insertText("Invalid GEO property\n")
				return
			if geo == None:
				if photoFlag == 2:
					launchBrowser(photo)
					insertText("Valid Photo but invalid GEO\n")
					return
				insertText("Invalid GEO property\n")
				return
			print(geo)
			if "," in geo:
				splitGeo = geo.split(",")
				lat = float(splitGeo[0])
				lon = float(splitGeo[1])
			elif ";" in geo:
				splitGeo = geo.split(";")
				lat = float(splitGeo[0])
				lon = float(splitGeo[1])
			else:
				insertText("Invalid GEO property\n")
				return
			gmd = GMapData("Google Map", "Location", [lat,lon], 14)
			gmd.addPoint( [lat,lon], photo, address)
			gmd.addOverlay( 0, 1 ,3 )
			gmd.serve( "public_html/index.html" )
			launchBrowser( "http://localhost:44704" )
		else:
			insertText("No GEO property found\n")
Exemple #2
0
def mapButton():

	global selectedCard

	gotGeo = 0
	gotPhoto = 0
	gotAdr = 0
	name = ""
	geo = ""
	photo = ""
	address = ""
	for prop in selectedCard:
		if (prop[0] == 3):
			name = prop[3]
		if (prop[0] == 12 and gotGeo == 0): #if property is geo
			geo = prop[3]
			gotGeo = 1
		if (prop[0] == 6 and gotPhoto == 0): #if property is photo
			photo = prop[3]
			gotPhoto = 1
		if (prop[0] == 8 and gotAdr == 0): #if property is address
			address = prop[3]
			gotAdr = 1

	geoS = geo.split(",")
	if (len(geoS) == 2):
		lat = float(geoS[0])#convert geos to floats
		lon = float(geoS[1])
	geoS = geo.split(";")
	if (len(geoS) == 2):
		lat = float(geoS[0])#convert geos to floats
		lon = float(geoS[1])

	gmd = GMapData( name, address, [lat,lon], 14 )
	gmd.addPoint( [lat,lon], photo, address )	# s.b. center of map
	gmd.addOverlay( 0, 1, 3 )	# single point, blue icon

	logText.insert(tkinter.INSERT, "Loading Map... Please wait\n")
	logText.see(END)
	
	#3. generate HTML to serve
	gmd.serve( "public_html/index.html" );

	#4. launch browser
	launchBrowser( "http://localhost:43887/" )
Exemple #3
0
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/" )
Exemple #4
0
def main():
	
	#1. start CGI/HTTP server
	startWebServer()

	#2. create GMapData object and populate with data
	gmd = GMapData( "Univ. of Guelph", [43.530318,-80.223241], 14 )	# use default values
	gmd.addPoint( [43.530318,-80.223241] )	# s.b. center of map
	gmd.addOverlay( 0, 1, 2 )	# single point, blue icon

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

	#4. launch browser
	launchBrowser( "http://localhost:8080/" )


	raw_input( "Press enter:" )		# pause
	
	gmd.addPoint( [43.530318,-80.223241] )	# 3-point red line
	gmd.addPoint( [43.535538,-80.223461] )
	gmd.addPoint( [43.520758,-80.220681] )
	gmd.addOverlay( 1, 3, 0 )
	
	gmd.serve( "public_html/index.html" );
	launchBrowser( "http://localhost:8080/" )


	raw_input( "Press enter:" )
	
	gmd.addPoint( [43.530318,-80.223241] )	# 3-point blue line
	gmd.addPoint( [43.515538,-80.220461] )
	gmd.addPoint( [43.520758,-80.225681] )
	gmd.addOverlay( 4, 3, 2 )
	
	gmd.serve( "public_html/index.html" );
	launchBrowser( "http://localhost:8080/" )


	print "Close the Tk window to proceed with server shutdown..."
	root = Tk()
	root.mainloop()				# open a Tk window

	#5. kill servers
	killServers()
Exemple #5
0
		def mapIt():
			select = hikes.curselection();
			
			allHikes = []
			for item in select:
			
				# get the ones selected in the list
				index = int(item[0])
				
				# get the fileno and ptnos to reference the WAYPTS table
				getInfo = "SELECT DISTINCT fileno from HIKEPTS WHERE hikeno = '%d'" % (hikeno[index])
				cursor.execute(getInfo)
				fetch = cursor.fetchone()
				tempFileno = fetch[0]
				
				getInfo = "SELECT ptno from HIKEPTS WHERE hikeno = '%d' AND fileno = '%d'" % (hikeno[index], tempFileno)
				cursor.execute(getInfo)
				fetch = cursor.fetchall()
				
				# get the lat/lon with information from the WAYPTS table
				mapData = []
				for item in fetch:
					
					tempPtno = int(item[0])
					coordinate = []
					
					# get the latitude
					getLat = "SELECT lat from WAYPTS where fileno = '%d' AND ptno = '%d'" % (tempFileno, tempPtno)
					cursor.execute(getLat)
					temp = cursor.fetchone()
					coordinate.append(temp[0])
					
					# get the longitude
					getLon = "SELECT lon from WAYPTS where fileno = '%d' AND ptno = '%d'" % (tempFileno, tempPtno)
					cursor.execute(getLon)
					temp = cursor.fetchone()
					coordinate.append(temp[0])
					
					mapData.append(coordinate)
					
				# add the hike to the list
				allHikes.append(mapData)
					
			# generate the map
			if len(select) > 0:
				
				# calculate average lat/lon
				lat = 0
				lon = 0
				noCoords = 0
				for thing in allHikes:
					for item in thing:
						lat = lat + item[0]
						lon = lon + item[1]
						noCoords = noCoords + 1
						
				avgLat = lat / noCoords
				avgLon = lon / noCoords
					
				# make the map, centre it at the average lat/lon
				gMap = GMapData("hello world", [avgLat, avgLon], 10)
					
				count = 0
				for thing in allHikes:
					start = count
					points = 0
					for item in thing:
						gMap.addPoint(item)
						gMap.addOverlay(count, 1, 0)
						count = count + 1
						points = points + 1
						
					gMap.addOverlay(start, points, 1)
					
				gMap.serve("public_html/index.html")
				launchBrowser("http://localhost:49099/")
Exemple #6
0
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/")
Exemple #7
0
def main():
	
	#1. start CGI/HTTP server
	startWebServer(46875)

	#2. create GMapData object and populate with data
	gmd = GMapData( "maptest", "Univ. of Guelph", [43.530318,-80.223241], 14 )	# use default values
	photo = "http://www.uoguelph.ca/~gardnerw/head.gif" # photo url
	address = ";;50 Stone Road East\, Reynolds 105;\\nGuelph;Ontario;N1G2W1" # address
	gmd.addPoint( [43.530318,-80.223241], photo, address )	# s.b. center of map
	gmd.addOverlay( 0, 1, 3 )	# single point, blue icon

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

	#4. launch browser
	launchBrowser( "http://localhost:42637/" )


	input( "Press enter:" )		# pause
	
	gmd.addPoint( [43.530318,-80.223241] )	# 3-point red line
	gmd.addPoint( [43.535538,-80.223461] )
	gmd.addPoint( [43.520758,-80.220681] )
	gmd.addOverlay( 1, 3, 0 )
	
	gmd.serve( "public_html/index.html" );
	launchBrowser( "http://localhost:46875/" )


	input( "Press enter:" )
	
	gmd.addPoint( [43.530318,-80.223241] )	# 3-point blue line
	gmd.addPoint( [43.515538,-80.220461] )
	gmd.addPoint( [43.520758,-80.225681] )
	gmd.addOverlay( 4, 3, 2 )
	
	gmd.serve( "public_html/index.html" );
	launchBrowser( "http://localhost:46875/" )


	print( "Close the Tk window to proceed with server shutdown..." )
	root = Tk()
	root.mainloop()				# open a Tk window

	#5. kill servers
	killServers()