/**************************************************************************** * OrbTrak: A satellite orbit visualization library * * Copyright Andrew T. West, 2008 * * Last update: 07-Jun-2008 * ***************************************************************************** * * * This program is free software; you can redistribute it and/or modify it * * under the terms of the GNU General Public License as published by the * * Free Software Foundation; either version 2 of the License or any later * * version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * General Public License for more details. * * * *****************************************************************************/ // orbtrak.js and predictlib.js both work for one satellite now // Jogi, 2011-08-22 var Orb = { satelliteMarkers: new Array(), satellitePoint: new Object (), satLayer: new OpenLayers.Layer.Vector ("satLayer"), homeLayer: new OpenLayers.Layer.Vector ("homeLayer"), trackLayer: new OpenLayers.Layer.Vector ("trackLayer"), track: new Array (), from: new OpenLayers.Projection ("EPSG:4326"), to: new OpenLayers.Projection ("EPSG:900913"), startOSMTracking: function (longitude, latitude, altitude, name) { PLib.InitializeData(); PLib.configureGroundStation(latitude, longitude, altitude, name); document.getElementById ("gsName").innerHTML = name; document.getElementById ("gsLongitude").innerHTML = longitude; document.getElementById ("gsLatitude").innerHTML = latitude; document.getElementById ("gsAltitude").innerHTML = altitude; Orb.createOSMSatellite (); var map = new OpenLayers.Map ("osm"); var mousePosition = new OpenLayers.Control.MousePosition(); mousePosition.displayProjection = Orb.from; map.addControl(new OpenLayers.Control.LayerSwitcher()); map.addControl(mousePosition); map.addLayers ([new OpenLayers.Layer.OSM (), Orb.trackLayer, Orb.satLayer, Orb.homeLayer]); // map.addLayers ([new OpenLayers.Layer.WMS ("OpenLayers WMS", "http://vmap0.tiles.osgeo.org/wms/vmap0", {layers:'basic'}), Orb.trackLayer, Orb.satLayer, Orb.homeLayer]); map.zoomTo (1); var satStyle = {fillColor: "#ffed00", pointRadius: 3, stroke: false}; var homeStyle = {fill: true, pointRadius: 5, stroke: false, fillColor: "#003366", fillOpacity: 0.6}; var home = new OpenLayers.LonLat (longitude, latitude).transform (Orb.from, Orb.to); Orb.createSatelliteTrack (); Orb.homeLayer.addFeatures ([ new OpenLayers.Feature.Vector ( new OpenLayers.Geometry.Point (home.lon, home.lat), null, homeStyle)]); // map.zoomToMaxExtent (); Orb.satLayer.addFeatures ([ new OpenLayers.Feature.Vector (Orb.satellitePoint, null, satStyle)]); setTimeout ("Orb.updateOSMSatellite ()", document.getElementById ("refresh").value); }, createSatelliteTrack: function () { if (document.getElementById ("previewMinutes") == null) minutes = 90; else minutes = document.getElementById ("previewMinutes").value; Orb.trackLayer.destroyFeatures (); var curve = new Array (); var points = new Array (); var track = PLib.calculateTrack (minutes); var lineStyle = {strokeColor: '#003366', strokeOpacity: 1, strokeWidth: 1}; var last = "east"; for (var i = 0; i < track.length; i++) { var lonlat = new OpenLayers.LonLat (track[i][0], track[i][1]).transform (Orb.from, Orb.to); var lon = "" + track[i][0]; if (lon.substring (0, 1) == "-") { if (last == "east") { curve.push (new OpenLayers.Feature.Vector (new OpenLayers.Geometry.LineString (points), null, lineStyle)) points = new Array (); } last = "west"; } else last = "east"; points.push (new OpenLayers.Geometry.Point (lonlat.lon, lonlat.lat)); } curve.push (new OpenLayers.Feature.Vector (new OpenLayers.Geometry.LineString (points), null, lineStyle)) Orb.trackLayer.addFeatures (curve); }, updateOSMSatellite: function () { var satInfo; var satellites = Orb.satLayer.features; satInfo = PLib.QuickFind (PLib.sat.name); var pos = new OpenLayers.LonLat (satInfo.longitude, satInfo.latitude).transform (Orb.from, Orb.to); satellites[0].move (pos); Orb.printSatellite (satInfo); setTimeout ("Orb.updateOSMSatellite ()", document.getElementById ("refresh").value); }, createOSMSatellite: function () { var satInfo; satInfo = PLib.QuickFind (PLib.sat.name); var pos = new OpenLayers.LonLat (satInfo.longitude, satInfo.latitude).transform (Orb.from, Orb.to); Orb.satellitePoint = new OpenLayers.Geometry.Point (pos.lon, pos.lat); Orb.printSatellite (satInfo); }, // startTracking: function(map, homeLat, homeLng) // { // Orb.map = map; // Orb.crossBrowserSetStyle(map, "background-image: url(orbimages/world.jpg); overflow: hidden;", true); // // var frag = document.createDocumentFragment(); // var div = document.createElement("div"); // div.id = "home"; // Orb.crossBrowserSetStyle(div, "position:relative; width: 24px; height: 24px; background-image: url(orbimages/home.gif);", false); // frag.appendChild(div); // Orb.map.appendChild(frag); // Orb.home = document.getElementById("home"); // // PLib.InitializeData(); // Orb.setHomeCoordinates(homeLat, homeLng); // Orb.createSatelliteMarkers(); // Orb.updateSatellites(); // }, setHomeCoordinates: function(homeLat, homeLng) { PLib.configureGroundStation(homeLat, homeLng); Orb.home.style.top = ((-homeLat + 90) * 1.5 - 12.0) + "px"; Orb.home.style.left = ((parseInt(homeLng) + 180) * 1.5 - 12.0) + "px"; }, crossBrowserSetStyle: function(element, css, append) { var obj, attributeName; var useStyleObject = element.style.setAttribute; obj = useStyleObject ? element.style : element; attributeName = useStyleObject ? "cssText" : "style"; if (append) css += obj.getAttribute(attributeName); obj.setAttribute(attributeName, css); }, createOneMarker: function(txt) { var frag = document.createDocumentFragment(); var markerCount = Orb.satelliteMarkers.length; var div = document.createElement("div"); div.id = "satelliteMarker" + markerCount; Orb.crossBrowserSetStyle(div, "position:absolute; width: 24px; height: 24px; background-image: url(orbimages/saticon.gif);", false); var innerDiv = document.createElement("div"); Orb.crossBrowserSetStyle(innerDiv, "position:absolute; left: 7px; top: 5px;"); var txt = document.createTextNode(txt); innerDiv.appendChild(txt); div.appendChild(innerDiv); frag.appendChild(div); Orb.map.appendChild(frag); Orb.satelliteMarkers[markerCount] = document.getElementById(div.id) }, createSatelliteMarkers: function() { for (var i = 1; i <= PLib.sat.length; i++) Orb.createOneMarker(i); }, // updateSatellites: function() // { // var satInfo; // // for (var i = 0; i < PLib.sat.length; i++) // { // satInfo = PLib.QuickFind(PLib.sat[i].name); // // Orb.satelliteMarkers[i].style.top = ((-satInfo.latitude + 90) * 1.5 - 12.0) + "px"; // Orb.satelliteMarkers[i].style.left = ((satInfo.longitude + 180) * 1.5 - 12.0) + "px"; // Orb.printSatellite (satInfo); // } // // setTimeout("Orb.updateSatellites()", 1000); // }, printSatellite: function (satInfo) { document.getElementById ("name").innerHTML = satInfo.satname; document.getElementById ("longitude").innerHTML = satInfo.longitude; document.getElementById ("latitude").innerHTML = satInfo.latitude; document.getElementById ("elevation").innerHTML = satInfo.elevation; document.getElementById ("azimuth").innerHTML = satInfo.azimuth; document.getElementById ("altitude").innerHTML = satInfo.altitude; }, printTLE: function () { return PLib.tleData[0] + "\n" + PLib.tleData[1] + "\n" + PLib.tleData[2]; }, createCell: function(tr, className, txt) { var td = document.createElement("td"); td.className = className; txt = document.createTextNode(txt); td.appendChild(txt); tr.appendChild(td); }, createHeaderColumn: function(tr, txt) { var th = document.createElement("th"); th.className = "orb-header"; txt = document.createTextNode(txt); th.appendChild(txt); tr.appendChild(th); }, generateTable: function(divTable) { var tr, visibilityText, detailClassName; var frag = document.createDocumentFragment(); var satInfoColl = PLib.getTodaysPasses(); while (divTable.childNodes.length > 0) { divTable.removeChild(divTable.firstChild); } var tbl = document.createElement("table"); Orb.crossBrowserSetStyle(tbl, "border-collapse: collapse; margin-left: auto; margin-right: auto;", false); var thead = document.createElement("thead"); tr = document.createElement("tr"); Orb.createHeaderColumn(tr, '# on Map'); Orb.createHeaderColumn(tr, 'Name'); Orb.createHeaderColumn(tr, 'Pass #'); Orb.createHeaderColumn(tr, 'Date'); Orb.createHeaderColumn(tr, 'Local Time'); Orb.createHeaderColumn(tr, 'Peak Elev.'); Orb.createHeaderColumn(tr, 'Azimuth'); Orb.createHeaderColumn(tr, 'Range (km)'); Orb.createHeaderColumn(tr, 'Visibility'); thead.appendChild(tr); tbl.appendChild(thead); var tbody = document.createElement("tbody"); for (var i = 0; i < satInfoColl.length; i++) { tr = document.createElement("tr"); detailClassName = satInfoColl[i].visibility == "+" ? "orb-detailVisible" : "orb-detail"; Orb.createCell(tr, detailClassName, satInfoColl[i].number); Orb.createCell(tr, detailClassName, satInfoColl[i].name); Orb.createCell(tr, detailClassName, satInfoColl[i].passNo); Orb.createCell(tr, detailClassName, PLib.formatDateOnly(satInfoColl[i].dateTimeStart)); Orb.createCell(tr, detailClassName, PLib.formatTimeOnly(satInfoColl[i].dateTimeStart) + " - " + PLib.formatTimeOnly(satInfoColl[i].dateTimeEnd)); Orb.createCell(tr, detailClassName, satInfoColl[i].peakElevation + "\u00B0"); Orb.createCell(tr, detailClassName, satInfoColl[i].riseAzimuth + ", " + satInfoColl[i].peakAzimuth + ", " + satInfoColl[i].decayAzimuth); Orb.createCell(tr, detailClassName, satInfoColl[i].riseRange + ", " + satInfoColl[i].peakRange + ", " + satInfoColl[i].decayRange); switch(satInfoColl[i].visibility) { case "+": visibilityText = 'Visible'; break; case "*": visibilityText = 'Not Visible'; break; default: visibilityText = 'Eclipsed'; } Orb.createCell(tr, detailClassName, visibilityText); tbody.appendChild(tr); } tbl.appendChild(tbody); frag.appendChild(tbl); divTable.appendChild(frag); } } // vim: ts=2 tw=0 expandtab // EOF