kopia lustrzana https://github.com/glidernet/ogn-python
Aircraft trail
rodzic
ec6221ae8e
commit
8820f59205
19
app/app.py
19
app/app.py
|
@ -50,10 +50,11 @@ def index():
|
|||
def live():
|
||||
return render_template('live.html')
|
||||
|
||||
|
||||
@app.route('/aircraft_beacons')
|
||||
def aircraft_beacons():
|
||||
sq_last = session.query(AircraftBeacon.address, func.max(AircraftBeacon.timestamp).label('lastseen')) \
|
||||
.filter(AircraftBeacon.timestamp > '2015-11-13 15:00:00') \
|
||||
.filter(AircraftBeacon.timestamp > '2015-11-13 00:00:00') \
|
||||
.group_by(AircraftBeacon.address) \
|
||||
.subquery()
|
||||
|
||||
|
@ -64,9 +65,21 @@ def aircraft_beacons():
|
|||
result = {}
|
||||
for [address, latitude, longitude, registration, aircraft] in aircraft_beacons_query.all():
|
||||
result[address] = {'lat': latitude, 'lng': longitude, 'registration': registration, 'aircraft': aircraft}
|
||||
|
||||
return(json.dumps({'aircraft_beacons': result}))
|
||||
|
||||
#return(json.dumps(aircraft_beacons_query.all(), ensure_ascii=False))
|
||||
|
||||
@app.route('/positions/<address>')
|
||||
def positions(address):
|
||||
positions_query = session.query(AircraftBeacon) \
|
||||
.filter(AircraftBeacon.address == address) \
|
||||
.filter(AircraftBeacon.ground_speed > 0)
|
||||
|
||||
result = []
|
||||
for position in positions_query.all():
|
||||
result.append({'lat': position.latitude, 'lng': position.longitude})
|
||||
return(json.dumps({'positions': result}))
|
||||
|
||||
|
||||
|
||||
@app.route('/flarms')
|
||||
|
@ -107,5 +120,3 @@ def statistics():
|
|||
|
||||
if __name__ == "__main__":
|
||||
app.run(debug=True)
|
||||
#with app.app_context():
|
||||
# aircraft_beacons()
|
||||
|
|
|
@ -34,16 +34,38 @@ function initMap() {
|
|||
$.each(data.aircraft_beacons, function(i, item) {
|
||||
var latlng = new google.maps.LatLng(item.lat,item.lng);
|
||||
var marker = new google.maps.Marker({
|
||||
address: i,
|
||||
position: latlng,
|
||||
map: map
|
||||
});
|
||||
if (item.registration === null) {
|
||||
//marker.setIcon('http://maps.google.com/mapfiles/marker_yellow.png');
|
||||
marker.setTitle(i);
|
||||
} else {
|
||||
marker.setIcon('http://maps.google.com/mapfiles/arrow.png');
|
||||
marker.setIcon('http://maps.google.com/mapfiles/marker_yellow.png');
|
||||
marker.setTitle(item.registration);
|
||||
}
|
||||
|
||||
|
||||
marker.addListener('click', function() {
|
||||
var mypath = new Array();
|
||||
$.getJSON('positions/' + marker.address, function(data) {
|
||||
var i = 0;
|
||||
$.each(data.positions, function(j, item2) {
|
||||
var position = new google.maps.LatLng(item2.lat, item2.lng);
|
||||
mypath.push(position);
|
||||
i = i + 1;
|
||||
})
|
||||
|
||||
var polyline = new google.maps.Polyline({
|
||||
path: mypath,
|
||||
strokeColor: '#ff0000',
|
||||
strokeOpacity: 1.0,
|
||||
strokeWeight: 3
|
||||
});
|
||||
|
||||
polyline.setMap(map);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Ładowanie…
Reference in New Issue