Commit 7e3dd6df authored by Christopher Reis's avatar Christopher Reis

Fixed LatLon coordination....still freezes with multiple sats

parent 32f98c7a
......@@ -47,18 +47,10 @@ public class Application {
static TrackerList trackList = new TrackerList();
static SatelliteDB satellites = new SatelliteDB("SatelliteDB");
static view3D threeDview = new view3D();
static ActionListener updateTracks = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
List<satPosition> pos = TrackerList.getTracks();
threeDview.updateTracks(pos);
}
};
static ActionListener addtrack = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
threeDview.addSatellite(TrackerList.getTracks());
//System.out.println(TrackerList.getTracks().get(0).getLat());
}
};
......
......@@ -87,34 +87,24 @@ public class view3D extends JInternalFrame{
Iterable<Renderable> iter = layer.getRenderables();
while(iter.iterator().hasNext()){
System.out.println("Iterator ");
Renderable rend = iter.iterator().next();
if(rend instanceof PointPlacemark){
PointPlacemark delp = (PointPlacemark)rend;
System.out.println(delp.getLabelText());
if(delp.getLabelText().equals(name)){
delp.setPosition(Position.fromDegrees(lat, lon, alt* 1000));
System.out.println(lat + " " + lon + " " + alt*1000);
wwd.redraw();
return;
}else{
return;
}
} else {
System.out.println("Not a PP");
}
}
PointPlacemark pp = new PointPlacemark(Position.fromDegrees(lat, lon, alt *1000 ));
// pp.setValue(AVKey.DISPLAY_NAME, "Clamp to ground, Audio icon, Heading -45, Globe relative");
// pp.setLabelText(name);
// pp.setLineEnabled(false);
// pp.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
// PointPlacemarkAttributes attrs = new PointPlacemarkAttributes();
// attrs.setImageAddress("D:\\MyDocuments\\GitHub\\Satellite\\satellite.png");
// attrs.setHeading(-45d);
// attrs.setHeadingReference(AVKey.RELATIVE_TO_GLOBE);
// attrs.setScale(0.05);
// attrs.setImageOffset(new Offset(0.5, 0.5, AVKey.FRACTION, AVKey.FRACTION));
// attrs.setImageOffset(new Offset(19d, 8d, AVKey.PIXELS, AVKey.PIXELS));
// attrs.setLabelColor("ffffffff");
// attrs.setLabelOffset(new Offset(0.9d, 0.6d, AVKey.FRACTION, AVKey.FRACTION));
// pp.setAttributes(attrs);
// layer.addRenderable(pp);
PointPlacemark pp = new PointPlacemark(Position.fromDegrees(lat, lon, alt *1000 ));
pp.setLabelText(name);
pp.setValue(AVKey.DISPLAY_NAME, "Label, Semi-transparent, Audio icon");
pp.setLineEnabled(false);
......@@ -126,7 +116,7 @@ public class view3D extends JInternalFrame{
attrsP.setImageOffset(new Offset(175d,175d,AVKey.PIXELS, AVKey.PIXELS));
pp.setAttributes(attrsP);
layer.addRenderable(pp);
// Add the layer to the model.
wwd.getModel().getLayers().add(layer);
// Update layer panel
......@@ -134,8 +124,10 @@ public class view3D extends JInternalFrame{
}
public void addSatellite(List<satPosition> positions){
System.out.println("Size " + positions.size());
for(int i = 0; i<positions.size();i++){
addTrack(positions.get(i).getName(),positions.get(i).getLat(),positions.get(i).getLon(),positions.get(i).getAlt());
System.out.println(positions.get(i).getName()+ " Added!");
}
}
}
......@@ -165,7 +165,8 @@ public class SatelliteTrack {
satPosition pos = new satPosition(satellite.calculateSatelliteGroundTrack().getLatitude(),
satellite.calculateSatelliteGroundTrack().getLongitude(),
satellite.calculateSatelliteGroundTrack().getAltitude(),
satellite.calculateSatelliteGroundTrack().getTime());
satellite.calculateSatelliteGroundTrack().getTime(),
satellite.getTLE().getName());
return pos;
}
......
......@@ -5,39 +5,38 @@ import java.util.List;
public class TrackerList {
private static List<tracker> threadList = new ArrayList<tracker>();
private static List<SatelliteTrack> threadList = new ArrayList<SatelliteTrack>();
public static void startTrack(String sat, String gs){
int satNum = SatelliteDB.getSatIndex(sat);
SatelliteTrack satellite = SatelliteDB.sat(satNum);
threadList.add(new tracker(satellite));
threadList.get(threadList.size()-1).start();
threadList.add(satellite);
}
public static void stopTrack(String sat){
for(int i = 0;i<threadList.size();i++){
if(threadList.get(i).name.equals(sat)){
threadList.get(i).stop();
if(threadList.get(i).getTLE().getName().equals(sat)){
threadList.remove(i);
}
}
}
public static satPosition getSatPos(String sat){
int satNum = searchThread(sat);
return threadList.get(satNum).sat.getPosition();
return threadList.get(satNum).getPosition();
}
public static List<satPosition> getTracks(){
List<satPosition> positions = new ArrayList<satPosition>();
for(int i =0;i<threadList.size();i++){
positions.add(threadList.get(i).getPos());
positions.add(threadList.get(i).getPosition());
}
return positions;
}
private static int searchThread(String sat){
for(int i = 0;i<threadList.size();i++){
if(sat.trim().equals(threadList.get(i).name)){
if(sat.trim().equals(threadList.get(i).getTLE().getName())){
return i;
}
}
......
......@@ -28,6 +28,15 @@ public class satPosition{
this.time = new Date();
}
public satPosition(double lat, double lon, double alt, Date time, String name) {
super();
this.lat = lat;
this.lon = lon;
this.alt = alt;
this.name = name;
this.time = time;
}
public String getName(){
return name;
}
......
package satellite;
public class tracker extends Thread{
public tracker(SatelliteTrack satellite){
this.sat = satellite;
this.name = satellite.getTLE().getName();
this.image = satellite.getImage();
this.color = satellite.getTrackColor();
}
public String name;
public SatelliteTrack sat;
String image;
String color;
int seconds = 0;
public void run(){
while(true){
System.out.println("Tracking " + sat.getTLE().getName() + " for: "+ seconds +" seconds");
System.out.println(sat.getPosition().getLat() + " " + sat.getPosition().getLon());
seconds++;
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
public satPosition getPos(){
satPosition satPos = new satPosition(sat.getPosition().getLat(),sat.getPosition().getLon(),sat.getPosition().getAlt(),sat.getTLE().getName());
return satPos;
}
}
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