Commit 839fd52a authored by Stephen D's avatar Stephen D
Browse files

Fixed ISS irregularities

parent dc045c79
......@@ -125,6 +125,8 @@ function loadSatelliteData(callback) {
for(var i = 0; i < json.length; i++) {
idsAndNames[json[i].norad_cat_id] = json[i].names;
}
//ISS is silly
idsAndNames[25544] = "ISS";
$.get("ham.txt", function(data) {
var splitLines = data.split(/\r?\n/);
var satellites = []
......
function initMap() {
var f_coords = {lat: 44.648862, lng: -63.575320};
var s_coords = {lat: 51.165691, lng: 10.451526};
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 4,
center: f_coords
});
var f_marker = new google.maps.Marker({
position: f_coords,
map: map
});
var s_marker = new google.maps.Marker({
position: s_coords,
map: map
});
google.maps.event.addListener(map, 'mousemove', function (event) {
var lat = event.latLng.lat();
var long = event.latLng.lng();
console.log(latLongToCartesian({lat: lat, lng: long}));
});
var f = latLongToCartesian(f_coords);
f.ang = 10;
var s = latLongToCartesian(s_coords);
s.ang = 10;
slopes = getSlopes(f, s);
heatmap_data = [];
for(var lat = -90; lat < 90; lat++) {
for(var long = -180; long < 180; long++) {
var coordsToCheck = latLongToCartesian({lat: lat, lng: long}, 6000);
var y = coordsToCheck.x;
var x = coordsToCheck.y;
coordsToCheck.y = y;
coordsToCheck.x = x;
if(checkIfPointValid(coordsToCheck, slopes, f, s))
{
console.log("Lat:" + lat + " Long: " + long + " works");
heatmap_data.push(new google.maps.LatLng(lat, long));
}
}
}
var heatmap = new google.maps.visualization.HeatmapLayer({
data: heatmap_data,
dissipating: false,
map: map
});
}
var getSlopes = function(f, s) {
var fAng = f.ang * (Math.PI / 180);
var sAng = s.ang * (Math.PI / 180);
var fNorthernHemi = true;
var sNorthernHemi = true;
//Fix for southern hemisphere
if(f.y < 0) {
fAng *= -1;
fNorthernHemi = false;
}
if(s.y < 0) {
sAng *= -1;
sNorthernHemi = false;
console.log("boop" + s.y);
}
return {
h: Math.tan(fAng + Math.atan(-f.x/f.y)),
i: Math.tan(-sAng + Math.atan(-s.x/s.y)),
j: Math.tan(fAng + Math.atan(-f.z/f.y)),
k: Math.tan(-sAng + Math.atan(-s.z/s.y)),
fNHemi: fNorthernHemi,
sNHemi: sNorthernHemi
};
}
var checkIfPointValid = function(p, m, f, s) { //Point, slopes, first point, second point
var yh = m.h * (p.x - f.x) + f.y;
var yi = m.i * (p.x - s.x) + s.y;
var yj = m.j * (p.z - f.z) + f.y;
var yk = m.k * (p.z - s.z) + s.y;
if ((m.fNHemi && p.y >= yh && p.y >= yj) || (!m.fNHemi && p.y <= yh && p.y <= yj)) {
/*console.log(p.z + " " + s.z + " " + s.y + " " + m.k);
console.log(yk);
console.log(p.y);*/
if ((m.sNHemi && p.y >= yi && p.y >= yk) || (!m.sNHemi && p.y <= yi && p.y <= yk)) {
return true; //Yay!
}
}
return false;
}
var latLongToCartesian = function(point, height = 0) {
var earthRadius = 6371; //KM
var nRadius = earthRadius + height;
var nLat = (Math.PI/180) * point.lat;
var nLong = (Math.PI/180) * point.lng;
return {
/*x: nRadius * Math.cos(nLat) * Math.cos(nLong),
z: nRadius * Math.cos(nLat) * Math.sin(nLong),
y: nRadius * Math.sin(nLat)*/
x: nLat,
y: nLong,
z: height
};
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment