|
|
@ -6,7 +6,7 @@ $(function () { |
|
|
|
$("#toDate").datepicker().datepicker("setDate", then); |
|
|
|
}); |
|
|
|
|
|
|
|
var app = angular.module('satTrackApp',[] /*, ['ngMap']*/); |
|
|
|
var app = angular.module('satTrackApp',[]); |
|
|
|
|
|
|
|
app.controller('satTrack-ctrl', function($scope) { |
|
|
|
$scope.places = []; |
|
|
@ -16,24 +16,25 @@ app.controller('satTrack-ctrl', function($scope) { |
|
|
|
$scope.satellites = []; |
|
|
|
$scope.selectAllSats = true; |
|
|
|
|
|
|
|
//Fixes map
|
|
|
|
angular.element(document).ready(function() { |
|
|
|
$scope.lmap.invalidateSize(); |
|
|
|
}); |
|
|
|
|
|
|
|
loadSatelliteData(function(satList) { |
|
|
|
$scope.satellites = satList; |
|
|
|
}); |
|
|
|
|
|
|
|
//Init leaflet map
|
|
|
|
var lmap = L.map('lmap').setView([39.82, -77.01], 4); |
|
|
|
$scope.lmap = L.map('lmap').setView([39.82, -77.01], 4); |
|
|
|
|
|
|
|
L.tileLayer('https://map.stormwindmc.com/styles/osm-bright/{z}/{x}/{y}.png', { |
|
|
|
L.tileLayer('https://map.scd31.com/hot/{z}/{x}/{y}.png', { |
|
|
|
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>', |
|
|
|
maxZoom: 20, |
|
|
|
//id: 'mapbox.streets',
|
|
|
|
//accessToken: 'your.mapbox.access.token'
|
|
|
|
}).addTo(lmap); |
|
|
|
|
|
|
|
//var elevator;
|
|
|
|
}).addTo($scope.lmap); |
|
|
|
|
|
|
|
$scope.removePoint = function(id) { |
|
|
|
lmap.removeLayer($scope.places[id].marker); |
|
|
|
$scope.lmap.removeLayer($scope.places[id].marker); |
|
|
|
$scope.places[id].marker = null; |
|
|
|
$scope.places.splice(id, 1); |
|
|
|
for(var i = 0; i < $scope.places.length; i++) { |
|
|
@ -43,7 +44,7 @@ app.controller('satTrack-ctrl', function($scope) { |
|
|
|
|
|
|
|
function onMapClick(map) |
|
|
|
{ |
|
|
|
var marker = new L.marker(map.latlng, {draggable: 'true'}).addTo(lmap); |
|
|
|
var marker = new L.marker(map.latlng, {draggable: 'true'}).addTo($scope.lmap); |
|
|
|
|
|
|
|
marker.on('dragend', function(e) { |
|
|
|
$scope.$apply(); |
|
|
@ -53,68 +54,58 @@ app.controller('satTrack-ctrl', function($scope) { |
|
|
|
$scope.$apply(); |
|
|
|
} |
|
|
|
|
|
|
|
lmap.on('click', onMapClick); |
|
|
|
/*NgMap.getMap().then(function(map) { |
|
|
|
|
|
|
|
google.maps.event.addListener(map, 'click', function(event) { |
|
|
|
var marker = new google.maps.Marker({ |
|
|
|
position: event.latLng, |
|
|
|
map: map, |
|
|
|
label: ($scope.places.length + 1).toString(), |
|
|
|
draggable: true |
|
|
|
}); |
|
|
|
|
|
|
|
elevator = new google.maps.ElevationService; |
|
|
|
|
|
|
|
google.maps.event.addListener(marker, 'dragend', function () { |
|
|
|
$scope.$apply(); |
|
|
|
}); |
|
|
|
|
|
|
|
$scope.places.push({marker: marker, angle: 10}); |
|
|
|
$scope.$apply(); |
|
|
|
}); |
|
|
|
});*/ |
|
|
|
$scope.lmap.on('click', onMapClick); |
|
|
|
|
|
|
|
$scope.getPasses = function() { |
|
|
|
$scope.isGettingPasses = true; |
|
|
|
//callsRemaining = $scope.places.length;
|
|
|
|
|
|
|
|
var processPasses = function() { |
|
|
|
var coords = $scope.places.map(function(a) { |
|
|
|
return { |
|
|
|
lat: a.marker.getLatLng().lat, |
|
|
|
lng: a.marker.getLatLng().lng, |
|
|
|
height: a.height, |
|
|
|
angle: a.angle |
|
|
|
}; |
|
|
|
}); |
|
|
|
|
|
|
|
var worker = new Worker('js/calc.js'); |
|
|
|
worker.addEventListener('message', function(e) { |
|
|
|
|
|
|
|
$scope.passes = e.data; |
|
|
|
$scope.isGettingPasses = false; |
|
|
|
$scope.$apply(); |
|
|
|
}, false); |
|
|
|
var fromDate = $("#fromDate").datepicker('getDate'); |
|
|
|
var toDate = $("#toDate").datepicker('getDate'); |
|
|
|
var duration = Math.abs(moment(toDate).diff(fromDate) / 1000) + 86400; |
|
|
|
worker.postMessage({coords: coords, satellites: $scope.satellites, fromDate: minDate(fromDate, toDate), toDuration: duration}); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Get elevations
|
|
|
|
var latlons = []; |
|
|
|
for(var i = 0; i < $scope.places.length; i++) { |
|
|
|
let place = $scope.places[i]; |
|
|
|
place.height = 10; /* ------------TODO-------------- */ |
|
|
|
/*elevator.getElevationForLocations({locations: [$scope.places[i].marker.position]}, function(results, status) { |
|
|
|
if(status === 'OK' && results[0]) { |
|
|
|
place.height = Math.max(results[0].elevation / 1000, 0); |
|
|
|
callsRemaining--; |
|
|
|
if(callsRemaining <= 0) sendCoords(); |
|
|
|
} else { |
|
|
|
alert('Something went very wrong'); |
|
|
|
} |
|
|
|
});*/ |
|
|
|
let place = $scope.places[i].marker.getLatLng(); |
|
|
|
latlons.push({latitude: place.lat, longitude: place.lng}); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var coords = $scope.places.map(function(a) { |
|
|
|
return { |
|
|
|
lat: a.marker.getLatLng().lat, |
|
|
|
lng: a.marker.getLatLng().lng, |
|
|
|
height: a.height, |
|
|
|
angle: a.angle |
|
|
|
}; |
|
|
|
}); |
|
|
|
|
|
|
|
var worker = new Worker('js/calc.js'); |
|
|
|
worker.addEventListener('message', function(e) { |
|
|
|
|
|
|
|
$scope.passes = e.data; |
|
|
|
$scope.isGettingPasses = false; |
|
|
|
$scope.$apply(); |
|
|
|
}, false); |
|
|
|
var fromDate = $("#fromDate").datepicker('getDate'); |
|
|
|
var toDate = $("#toDate").datepicker('getDate'); |
|
|
|
var duration = Math.abs(moment(toDate).diff(fromDate) / 1000) + 86400; |
|
|
|
worker.postMessage({coords: coords, satellites: $scope.satellites, fromDate: minDate(fromDate, toDate), toDuration: duration}); |
|
|
|
$.ajax({type: "POST", |
|
|
|
url: "https://map.scd31.com/elevation/api/v1/lookup", |
|
|
|
data: JSON.stringify({"locations": latlons}), |
|
|
|
contentType: "application/json", |
|
|
|
success: function(data, status) { |
|
|
|
for(var i = 0; i < $scope.places.length; i++) { |
|
|
|
$scope.places[i].height = data.results[i].elevation; |
|
|
|
}; |
|
|
|
processPasses(); |
|
|
|
}, |
|
|
|
error: function() { |
|
|
|
for(var i = 0; i < $scope.places.length; i++) { |
|
|
|
$scope.places[i].height = 0; |
|
|
|
} |
|
|
|
processPasses(); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
$scope.getDate = function(date) { |
|
|
|