Skip to content

Instantly share code, notes, and snippets.

@nutiteq
Created May 9, 2014 12:47
Show Gist options
  • Save nutiteq/374854b97c65b708dda0 to your computer and use it in GitHub Desktop.
Save nutiteq/374854b97c65b708dda0 to your computer and use it in GitHub Desktop.
// Shows International Space Station location as marker on map, for current time
{
MapPos issPos = predictISS(System.currentTimeMillis());
iss = new Marker(
mapView.getComponents().layers.getBaseProjection().fromWgs84(issPos.x, issPos.y),
new DefaultLabel("ISS"), markerStyle, null);
markerLayer.add(iss);
}
private MapPos predictISS(long timeMillis){
// requires: commons-lang-2.1.jar, joda-time-jar-1.6.jar and predict4java_1.1.158.4.jar from https://code.google.com/p/predict4java/downloads/list
// from http://celestrak.com/NORAD/elements/stations.txt
String[] ISS_TLE = {
"ISS (ZARYA)",
"1 25544U 98067A 14126.92299264 .00007994 00000-0 14853-3 0 2319",
"2 25544 51.6500 304.1061 0002752 337.8472 139.1065 15.49877967884923"};
GroundStationPosition GROUND_STATION =
new GroundStationPosition(0, 0, 0);
final TLE tle = new TLE(ISS_TLE);
final Satellite satellite = SatelliteFactory.createSatellite(tle);
final SatPos satellitePosition = satellite.getPosition(GROUND_STATION, new Date(timeMillis));
Log.info("ISS position :"+Math.toDegrees(satellitePosition.getLongitude())+", "+Math.toDegrees(satellitePosition.getLatitude())+ " Altitude: " + satellitePosition.getAltitude());
// normalize x
double x = Math.toDegrees(satellitePosition.getLongitude());
if (x > 180){
x -= 360;
}
return new MapPos(x,Math.toDegrees(satellitePosition.getLatitude()),satellitePosition.getAltitude());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment