Skip to content

Commit

Permalink
This branch is now finished, it has met its obejectives and some extr…
Browse files Browse the repository at this point in the history
…a changes. waypointer.pyc has been added as that script is now finished so the compiled version is available for faster run time. waypointer now supports lines from waypoint to waypoint, hovering over waypoints for waypoint number, new sidebar instead of an alert box. Last commit for this branch.
  • Loading branch information
shmink committed Oct 1, 2016
1 parent b8fa8e4 commit b91e069
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 36 deletions.
Binary file modified simplemap/__init__.pyc
Binary file not shown.
Binary file modified simplemap/html_render.pyc
Binary file not shown.
Binary file modified simplemap/map.pyc
Binary file not shown.
19 changes: 5 additions & 14 deletions simplemap/templates/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,32 @@
<title>{{map_title}}</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet">
<link rel="stylesheet" href="simplemap/templates/static/css/basic.css">
</head>
<body>
<div id="sidebar">
<h2>Waypointer</h2>
<!--<p>Sequence:</p>
<p>Date:</p>
<p>UUID:</p>-->
<p>{{ message|safe }}</p>
</div>
<div id="map"></div>
<script>

function initMap() {

/*var message = "{{ message|safe }}";
//If a message has been added to the alert system be sure to write it.
if (message) {
alert(message);
}*/

var bounds = new google.maps.LatLngBounds();
var center_lat_lon = {{center|safe}};

var map = new google.maps.Map(document.getElementById('map'), {
zoom: {{ zoom|safe }},
center: center_lat_lon
});

// markers is the actual pins you'll see on gmaps.
var markers = {{ markers|safe }};
//points need to be {lon:5.4..., lng:6.342...}
var points = {{ points|safe }}
//points are close to markers but formatted differently as the flightPath var needs it like so.
var points = {{ points|safe }};

//Doing this on the 'lines' branch
//Draw a line from point to point, not working currently.
// flightPath takes the points and draws lines between them all.
var flightPath = new google.maps.Polyline({
path: points,
geodesic: true,
Expand Down
6 changes: 4 additions & 2 deletions simplemap/templates/static/css/basic.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ html, body {
margin: 0;
padding: 0;
}

/* Width at 80% for sidebar */
#map {
height: 100%;
width: 80%;
}

/* sidebar on the right of the screen,
because it's not always relavant. */
#sidebar {
float:right;
margin-right: 1%;
overflow: auto;
font-family: 'Ubuntu', sans-serif;
}
35 changes: 15 additions & 20 deletions waypointer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# @author Tom Nicklin
### @author Tom Nicklin
# This has been specifically set up for the GroundStation application data tables.
# more file types and diffferent SQL querys will change based on new information.

from datetime import datetime
import simplemap
Expand All @@ -23,7 +25,7 @@
alert = ''


# In an effor to make this system more modular the user passes in a sequence number and table for the waypoints.
# In an effort to make this system more modular the user passes in a sequence number and table for the waypoints.
# this is that argument system. It still doesn't seem right to me but I've tested it enough that it works.
if __name__ == '__main__':
if len(sys.argv) == 3:
Expand Down Expand Up @@ -99,22 +101,23 @@ def get_alert(database):
#from import datetime library you can simply convert seconds elapsed from 1/1/1970 to get a date. Which is what we are doing here.
date = datetime.fromtimestamp(timeinseconds)
# Finally we return the string of relevant info that'll eventually be inserted into the alert box.
get_alertOutput = "Sequence: " + str(sequence) + "<br>Flown on: " + str(date) + "<br>UUID: " + str(uuid)
get_alertOutput = "Sequence: " + str(sequence) + "<br><br>Flown on: " + str(date) + "<br><br>UUID: " + str(uuid)
return get_alertOutput
except:
return 'Could not retrieve either UUID or date from database.'


# Here we change the formatting of the waypoints so gmaps api can use them to plot lines
def make_points(coords):
if(coords):
# Firstly we don't need the way point number in this as we already have our waypoints in order.
for x in range(0, len(coords)):
coords[x].pop(0)
#coords[x] = str(coords[x])
coords[x] = str(coords[x]).replace("[", "{lat: ").replace(",", ", lng:").replace("]", "}")
#coords[x].replace(",", ", lng:")
#coords[x].replace("]", "}")
print '\n', coords[x]
return coords
# List comprehensions are fun. Basically telling it the format I want and then it has its
# own little for loop and then changes all elements. It's more obvious when you look at
# var points in a generated html file.
new_list = [{'lat': d[0], 'lng': d[1]} for d in coords]
# Return the new list after the list comprehension.
return new_list



Expand All @@ -130,16 +133,8 @@ def make_points(coords):
gps_markers = get_coordinates(db)
# This gets the information to display in the alert pop up box
alert = get_alert(db)


#Test
plots = make_points(get_coordinates(db))

print plots

#print plots[0]
#print type(plots[0])
#print str(plots[0]).replace("[", "{lat: ").replace(",", ", lng:").replace("]", "}")
# This will take the points and make sure they can be used to make lines on the map
plots = make_points(gps_markers)

# Here we generate the html page by passing the above
# information to the relevant files
Expand Down
Binary file added waypointer.pyc
Binary file not shown.

0 comments on commit b91e069

Please sign in to comment.