I am trying to draw an orbit on a ground track map using TLE lines like this using JS:
1 45657U 20035A 20196.59974008 .38210219 12083-4 47903-3 0 9997
2 45657 53.0001 319.7129 0028054 181.2741 293.9291 16.46735707 7405
var attribution =
'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors';
var tile = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png";
var tle_Pos = getPosVel();
var longitude = tle_Pos.longitude
var latitude = tle_Pos.latitude
var worldMap = drawMap();
var objectDrawer = drawObject();
function getPosVel(){
var tleLine1 = '1 45657U 20035A 20196.59974008 .38210219 12083-4 47903-3 0 9997',
tleLine2 = '2 45657 53.0001 319.7129 0028054 181.2741 293.9291 16.46735707 7405';
var gmst = satellite.gstime(new Date());
var satrec = satellite.twoline2satrec(tleLine1, tleLine2);
var positionAndVelocity = satellite.propagate(satrec, new Date());
var gmst = satellite.gstime(new Date());
var geodeticCoords = satellite.eciToGeodetic(positionAndVelocity.position, gmst);
console.log(geodeticCoords);
return geodeticCoords
}
function drawMap() {
var map = L.map("mapid").setView([0, 0], 4);
L.tileLayer(tile, {
maxZoom: 25,
minZoom: 1.8,
attribution: attribution
}).addTo(map);
return map;
}
function drawObject() {
return L.marker([longitude, latitude]).addTo(worldMap);
}
I have tried to use satellite.js and Leaflet map but I ran into couple of problems doing this, First thing I cant figure how to predict and draw the orbit and not only the object's current latitude and longitude, Secondly, when I provide the TLE lines below it doesnt work at all, and when I provided the regular ISS TLE lines it worked but I dont think the latitude and longitude are accurate at all.
Is there anything alternative to use other than satellite.js or is there a right way to draw the full orbit of the TLE lines?
EXTRA: Here is an image of how I want the map to look like.
from Displaying orbits on ground track map using TLE lines
No comments:
Post a Comment