Compare commits

..

No commits in common. 'b81078c1d4e8e01f06fbb80d26e57841a1edd7c9' and '2b6904d62b53e9e0912aecfcf265d51a541eec90' have entirely different histories.

@ -24,7 +24,7 @@ app.config['SECRET_KEY'] = 'super secret key'
#app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/mydatabase.db' #app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/mydatabase.db'
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
#app.config['SQLALCHEMY_DATABASE_URI'] = 'rqlite+pyrqlite://localhost:4001/' #app.config['SQLALCHEMY_DATABASE_URI'] = 'rqlite+pyrqlite://localhost:4001/'
app.config['DEBUG'] = False app.config['DEBUG'] = True
app.config['PORT'] = 80 app.config['PORT'] = 80
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, 'mydatabase.db') app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, 'mydatabase.db')

@ -91,7 +91,9 @@ ul em{
width: 10%; width: 10%;
} }
.locations_list .row div:last-of-type {} .locations_list .row div:last-of-type{
}
.locations_list .row div{ .locations_list .row div{
width: 20%; width: 20%;
@ -287,8 +289,7 @@ ul em{
} }
#button_group button, #button_group button, #button_group select{
#button_group select {
background-color: grey; background-color: grey;
color: white; color: white;
font-size: 0.9em; font-size: 0.9em;

@ -6,23 +6,8 @@
<div class="compass"> <div class="compass">
<div id="arrow" class="arrow"><svg viewBox="0 0 25 25" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" <div id="arrow" class="arrow"><svg viewBox="0 0 25 25" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd"><path class="st0" d="M13,2.6l6.2,7.5L20,9.5l-7.5-9L5,9.5l0.8,0.6L12,2.6v21.9h1C13,24.5,13,2.6,13,2.6z"/></svg></div>
clip-rule="evenodd"> <div id="goal" class="compass-goal"><svg id="Layer_2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 21.94 21.94"><defs><style>.cls-1{fill:#3fb800;opacity:.3;}</style></defs><g id="Layer_1-2"><circle class="cls-1" cx="10.97" cy="10.97" r="10.97"/></g></svg></div>
<path class="st0" d="M13,2.6l6.2,7.5L20,9.5l-7.5-9L5,9.5l0.8,0.6L12,2.6v21.9h1C13,24.5,13,2.6,13,2.6z" /></svg>
</div>
<div id="goal" class="compass-goal"><svg id="Layer_2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 21.94 21.94">
<defs>
<style>
.cls-1 {
fill: #3fb800;
opacity: .3;
}
</style>
</defs>
<g id="Layer_1-2">
<circle class="cls-1" cx="10.97" cy="10.97" r="10.97" />
</g>
</svg></div>
<div class="my-point"></div> <div class="my-point"></div>
</div> </div>
@ -31,10 +16,8 @@
<!-- <h1 class="header" id="title">GEO</h1> --> <!-- <h1 class="header" id="title">GEO</h1> -->
<div id="button_group"> <div id="button_group">
<div id="distance_close">(distance to mosquito)</div> <div id="distance_close">(distance to mosquito)</div>
<button id="store_location" onclick="store_location()"><img src="/static/img/hangout.png" alt="">add <button id="store_location" onclick="store_location()"><img src="/static/img/hangout.png" alt="">add hangout</button>
hangout</button> <button id="store_location_mosquito" onclick="store_location_mosquito()"><img src="/static/img/mosquito.png" alt="">add mosquito</button>
<button id="store_location_mosquito" onclick="store_location_mosquito()"><img src="/static/img/mosquito.png"
alt="">add mosquito</button>
<button id="add_text" onclick="add_text()"><img src="/static/img/text.png" alt="">add message</button> <button id="add_text" onclick="add_text()"><img src="/static/img/text.png" alt="">add message</button>
<button id="add_audio" onclick="add_audio()"><img src="/static/img/audio.png" alt=""> add audio</button> <button id="add_audio" onclick="add_audio()"><img src="/static/img/audio.png" alt=""> add audio</button>
@ -50,6 +33,9 @@
</div> </div>
</div> </div>
<!-- HEADING DIRECTION https://stackoverflow.com/questions/46033649/heading-javascript-geolocation --> <!-- HEADING DIRECTION https://stackoverflow.com/questions/46033649/heading-javascript-geolocation -->
<!-- COMPASS CROSS DEVICE https://stackoverflow.com/questions/16048514/can-i-use-javascript-to-get-the-compass-heading-for-ios-and-android--> <!-- COMPASS CROSS DEVICE https://stackoverflow.com/questions/16048514/can-i-use-javascript-to-get-the-compass-heading-for-ios-and-android-->
@ -78,18 +64,14 @@
var markerArray = []; var markerArray = [];
var circleArray = []; var circleArray = [];
var mosquitoArray = []; var mosquitoArray = [];
var view = "me"; var view="closest";
var workingCompass = false; var workingCompass = false;
var map_view = false; var map_view = false;
function assign_data(data) { function assign_data(data) {
locations = data; locations = data;
} }
assign_data({ assign_data({{ data_locations|tojson }});
{
data_locations | tojson
}
});
var map = L.map('map', { var map = L.map('map', {
attributionControl:false, attributionControl:false,
@ -108,27 +90,18 @@
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>' attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}) })
function toggle_map(){ function toggle_map(){
if(map_view){ if(map_view){
map.removeLayer(backgroundLayer) map.removeLayer(backgroundLayer)
} else { }
else{
map.addLayer(backgroundLayer) map.addLayer(backgroundLayer)
} }
map_view = !map_view map_view = !map_view
} }
var myIcon = L.icon({
iconUrl: '/static/img/me.png',
iconSize: [30, 30],
iconAnchor: [15, 15],
popupAnchor: [-3, -76],
});
var myPositionCircle = L.marker([50.505, 30.57], {
icon: myIcon
}).addTo(map);
circleArray.push(myPositionCircle);
locations.forEach(function (item, index) { locations.forEach(function (item, index) {
try { try {
@ -140,21 +113,24 @@
iconAnchor: [25, 25], iconAnchor: [25, 25],
popupAnchor: [-3, -76], popupAnchor: [-3, -76],
}); });
} else if (item.loc_type == "audio") { }
else if(item.loc_type=="audio"){
icon = L.icon({ icon = L.icon({
iconUrl: '/static/img/audio.png', iconUrl: '/static/img/audio.png',
iconSize: [50, 50], iconSize: [50, 50],
iconAnchor: [25, 25], iconAnchor: [25, 25],
popupAnchor: [-3, -76], popupAnchor: [-3, -76],
}); });
} else if (item.loc_type == "mosquito") { }
else if(item.loc_type=="mosquito"){
icon = L.icon({ icon = L.icon({
iconUrl: '/static/img/mosquito.png', iconUrl: '/static/img/mosquito.png',
iconSize: [50, 50], iconSize: [50, 50],
iconAnchor: [25, 25], iconAnchor: [25, 25],
popupAnchor: [-3, -76], popupAnchor: [-3, -76],
}); });
} else if (item.loc_type == "hangout") { }
else if(item.loc_type=="hangout"){
icon = L.icon({ icon = L.icon({
iconUrl: '/static/img/hangout.png', iconUrl: '/static/img/hangout.png',
iconSize: [50, 50], iconSize: [50, 50],
@ -162,9 +138,7 @@
popupAnchor: [-3, -76], popupAnchor: [-3, -76],
}); });
} }
var circle = L.marker([item.latitude, item.longitude], { var circle = L.marker([item.latitude, item.longitude], {icon: icon}).addTo(map).on("click", e => circleClick(e));
icon: icon
}).addTo(map).on("click", e => circleClick(e));
circle.id = item.id; circle.id = item.id;
circleArray.push(circle); circleArray.push(circle);
@ -177,16 +151,36 @@
} }
}); });
// var myPositionCircle = L.circle([48.172934, 9.01236], {
// color: 'red',
// stroke:false,
// fillColor: 'red',
// fillOpacity: 0.5,
// radius: 10
// }).addTo(map);
var myIcon = L.icon({
iconUrl: '/static/img/me.png',
iconSize: [50, 50],
iconAnchor: [25, 25],
popupAnchor: [-3, -76],
});
var myPositionCircle = L.marker([50.505, 30.57], {icon: myIcon}).addTo(map);
circleArray.push(myPositionCircle);
var x = document.getElementById("position"); var x = document.getElementById("position");
let id; let id;
let target; let target;
let options; let options;
//first: latitude, second: longitude 51.915528423609125, 4.477065873620031 //first: latitude, second: longitude
target = { target = {
latitude: 51.915528423609125, latitude : 48.172934,
longitude: 4.477065873620031 longitude: 9.01236
}; };
var my_location = { var my_location = {
@ -199,7 +193,9 @@
my_location.longitude = crd.longitude; my_location.longitude = crd.longitude;
my_location.latitude = crd.latitude; my_location.latitude = crd.latitude;
updateView() if(view == "closest") updateView()
console.log("updated")
x.innerHTML = "Latitude: " + crd.latitude + x.innerHTML = "Latitude: " + crd.latitude +
"<br>Longitude: " + crd.longitude + "<br>Longitude: " + crd.longitude +
@ -220,6 +216,7 @@
// id = navigator.geolocation.watchPosition(success, error, options); // id = navigator.geolocation.watchPosition(success, error, options);
} }
options = { options = {
enableHighAccuracy: true, enableHighAccuracy: true,
timeout: 1000, timeout: 1000,
@ -240,7 +237,8 @@
var text; var text;
if(d < 1){ if(d < 1){
text = Math.round(d * 100) / 100*1000+" m"; text = Math.round(d * 100) / 100*1000+" m";
} else { }
else{
text = Math.round(d * 100) / 100+" km" text = Math.round(d * 100) / 100+" km"
} }
return text; return text;
@ -254,11 +252,42 @@
} }
function store_location(){ function store_location(){
// console.log("storing location");
// console.log(my_location)
// var xhr = new XMLHttpRequest();
// xhr.open("POST", "./addlocation", true);
// xhr.setRequestHeader('Content-Type', 'application/json');
// xhr.send(JSON.stringify({
// longitude: my_location.longitude,
// latitude: my_location.latitude
// }));
// xhr.onreadystatechange=function(){
// if (xhr.readyState==4 && xhr.status==200){
// location.reload();
// }
// }
window.location.href = "addhangout/"+ my_location.longitude +"/"+my_location.latitude+"/"; window.location.href = "addhangout/"+ my_location.longitude +"/"+my_location.latitude+"/";
} }
function store_location_mosquito(){ function store_location_mosquito(){
// console.log("storing location");
// console.log(my_location)
// var xhr = new XMLHttpRequest();
// xhr.open("POST", "./addlocationmosquito", true);
// xhr.setRequestHeader('Content-Type', 'application/json');
// xhr.send(JSON.stringify({
// longitude: my_location.longitude,
// latitude: my_location.latitude
// }));
// xhr.onreadystatechange=function(){
// if (xhr.readyState==4 && xhr.status==200){
// location.reload();
// }
// }
window.location.href = "addmosquito/"+my_location.longitude +"/"+my_location.latitude+"/"; window.location.href = "addmosquito/"+my_location.longitude +"/"+my_location.latitude+"/";
} }
@ -278,16 +307,22 @@
if(view == "all"){ if(view == "all"){
var group = new L.featureGroup(circleArray); var group = new L.featureGroup(circleArray);
map.fitBounds(group.getBounds().pad(0.4)); map.fitBounds(group.getBounds().pad(0.4));
} else if (view == "closest") { }
else if(view == "closest"){
var closest = L.GeometryUtil.closestLayer(map, mosquitoArray, myPositionCircle.getLatLng()); var closest = L.GeometryUtil.closestLayer(map, mosquitoArray, myPositionCircle.getLatLng());
document.getElementById("distance_close").innerHTML = "closest mosquito: " + distance(closest.layer.getLatLng() // L.polyline([closest.layer.getLatLng(), myPositionCircle.getLatLng()], {
.lng, closest.layer.getLatLng().lat, myPositionCircle.getLatLng().lng, myPositionCircle.getLatLng().lat) // color: 'black',
// weight: 1,
// }).addTo(map)
document.getElementById("distance_close").innerHTML = "closest mosquito: " + distance(closest.layer.getLatLng().lat,closest.layer.getLatLng().lng,myPositionCircle.getLatLng().lat, myPositionCircle.getLatLng().lng)
var group = new L.featureGroup([closest.layer, myPositionCircle]); var group = new L.featureGroup([closest.layer, myPositionCircle]);
map.fitBounds(group.getBounds().pad(0.4)); map.fitBounds(group.getBounds().pad(0.4));
} else if (view == "me") { }
else if(view == "me"){
map.setView([my_location.latitude, my_location.longitude], zoom_level); map.setView([my_location.latitude, my_location.longitude], zoom_level);
} else if (view == "free") { }
else if(view == "free"){
} }
} }
@ -364,10 +399,7 @@
function locationHandler(position) { function locationHandler(position) {
const { const { latitude, longitude } = position.coords;
latitude,
longitude
} = position.coords;
pointDegree = calcDegreeToPoint(latitude, longitude); pointDegree = calcDegreeToPoint(latitude, longitude);
if (pointDegree < 0) { if (pointDegree < 0) {
@ -379,11 +411,11 @@
// Qibla geolocation // Qibla geolocation
var closest = L.GeometryUtil.closestLayer(map, mosquitoArray, myPositionCircle.getLatLng()); var closest = L.GeometryUtil.closestLayer(map, mosquitoArray, myPositionCircle.getLatLng());
if(workingCompass == true){ if(workingCompass == true){
if (parseFloat(distance(closest.layer.getLatLng().lat, closest.layer.getLatLng().lng, myPositionCircle.getLatLng() if(parseFloat(distance(closest.layer.getLatLng().lat,closest.layer.getLatLng().lng,myPositionCircle.getLatLng().lat, myPositionCircle.getLatLng().lng).split(" "))<20){
.lat, myPositionCircle.getLatLng().lng).split(" ")) < 20) {
document.getElementById("arrow").style.display = "none"; document.getElementById("arrow").style.display = "none";
document.getElementById("goal").style.display = "block"; document.getElementById("goal").style.display = "block";
} else { }
else{
document.getElementById("arrow").style.display = "block"; document.getElementById("arrow").style.display = "block";
document.getElementById("goal").style.display = "none"; document.getElementById("goal").style.display = "none";
} }
@ -410,6 +442,8 @@
init(); init();
// //
</script> </script>
{% endblock js %} {% endblock js %}

@ -117,6 +117,8 @@ def addtext(lng, lat):
upload_form = UploadText() upload_form = UploadText()
longitude = lng longitude = lng
latitude = lat latitude = lat
print(longitude)
print(latitude)
if request.method == 'POST': if request.method == 'POST':
if upload_form.validate_on_submit(): if upload_form.validate_on_submit():
@ -145,6 +147,7 @@ def addaudio(lng, lat):
longitude = upload_form.longitude.data longitude = upload_form.longitude.data
latitude = upload_form.latitude.data latitude = upload_form.latitude.data
file = request.files['file'] file = request.files['file']
print(file.filename)
locations = db.session.query(Location).all() locations = db.session.query(Location).all()
id = len(locations)+1 id = len(locations)+1
# Getting the current date and time # Getting the current date and time

Loading…
Cancel
Save