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 { ...@@ -47,18 +47,10 @@ public class Application {
static TrackerList trackList = new TrackerList(); static TrackerList trackList = new TrackerList();
static SatelliteDB satellites = new SatelliteDB("SatelliteDB"); static SatelliteDB satellites = new SatelliteDB("SatelliteDB");
static view3D threeDview = new view3D(); 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() { static ActionListener addtrack = new ActionListener() {
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
threeDview.addSatellite(TrackerList.getTracks()); threeDview.addSatellite(TrackerList.getTracks());
//System.out.println(TrackerList.getTracks().get(0).getLat());
} }
}; };
......
...@@ -87,34 +87,24 @@ public class view3D extends JInternalFrame{ ...@@ -87,34 +87,24 @@ public class view3D extends JInternalFrame{
Iterable<Renderable> iter = layer.getRenderables(); Iterable<Renderable> iter = layer.getRenderables();
while(iter.iterator().hasNext()){ while(iter.iterator().hasNext()){
System.out.println("Iterator ");
Renderable rend = iter.iterator().next(); Renderable rend = iter.iterator().next();
if(rend instanceof PointPlacemark){ if(rend instanceof PointPlacemark){
PointPlacemark delp = (PointPlacemark)rend; PointPlacemark delp = (PointPlacemark)rend;
System.out.println(delp.getLabelText());
if(delp.getLabelText().equals(name)){ if(delp.getLabelText().equals(name)){
delp.setPosition(Position.fromDegrees(lat, lon, alt* 1000)); delp.setPosition(Position.fromDegrees(lat, lon, alt* 1000));
System.out.println(lat + " " + lon + " " + alt*1000); System.out.println(lat + " " + lon + " " + alt*1000);
wwd.redraw(); wwd.redraw();
return; return;
}else{
return;
} }
} else {
System.out.println("Not a PP");
} }
} }
PointPlacemark pp = new PointPlacemark(Position.fromDegrees(lat, lon, alt *1000 )); 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);
pp.setLabelText(name); pp.setLabelText(name);
pp.setValue(AVKey.DISPLAY_NAME, "Label, Semi-transparent, Audio icon"); pp.setValue(AVKey.DISPLAY_NAME, "Label, Semi-transparent, Audio icon");
pp.setLineEnabled(false); pp.setLineEnabled(false);
...@@ -126,7 +116,7 @@ public class view3D extends JInternalFrame{ ...@@ -126,7 +116,7 @@ public class view3D extends JInternalFrame{
attrsP.setImageOffset(new Offset(175d,175d,AVKey.PIXELS, AVKey.PIXELS)); attrsP.setImageOffset(new Offset(175d,175d,AVKey.PIXELS, AVKey.PIXELS));
pp.setAttributes(attrsP); pp.setAttributes(attrsP);
layer.addRenderable(pp); layer.addRenderable(pp);
// Add the layer to the model. // Add the layer to the model.
wwd.getModel().getLayers().add(layer); wwd.getModel().getLayers().add(layer);
// Update layer panel // Update layer panel
...@@ -134,8 +124,10 @@ public class view3D extends JInternalFrame{ ...@@ -134,8 +124,10 @@ public class view3D extends JInternalFrame{
} }
public void addSatellite(List<satPosition> positions){ public void addSatellite(List<satPosition> positions){
System.out.println("Size " + positions.size());
for(int i = 0; i<positions.size();i++){ 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()); 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 { ...@@ -165,7 +165,8 @@ public class SatelliteTrack {
satPosition pos = new satPosition(satellite.calculateSatelliteGroundTrack().getLatitude(), satPosition pos = new satPosition(satellite.calculateSatelliteGroundTrack().getLatitude(),
satellite.calculateSatelliteGroundTrack().getLongitude(), satellite.calculateSatelliteGroundTrack().getLongitude(),
satellite.calculateSatelliteGroundTrack().getAltitude(), satellite.calculateSatelliteGroundTrack().getAltitude(),
satellite.calculateSatelliteGroundTrack().getTime()); satellite.calculateSatelliteGroundTrack().getTime(),
satellite.getTLE().getName());
return pos; return pos;
} }
......
...@@ -5,39 +5,38 @@ import java.util.List; ...@@ -5,39 +5,38 @@ import java.util.List;
public class TrackerList { 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){ public static void startTrack(String sat, String gs){
int satNum = SatelliteDB.getSatIndex(sat); int satNum = SatelliteDB.getSatIndex(sat);
SatelliteTrack satellite = SatelliteDB.sat(satNum); SatelliteTrack satellite = SatelliteDB.sat(satNum);
threadList.add(new tracker(satellite)); threadList.add(satellite);
threadList.get(threadList.size()-1).start();
} }
public static void stopTrack(String sat){ public static void stopTrack(String sat){
for(int i = 0;i<threadList.size();i++){ for(int i = 0;i<threadList.size();i++){
if(threadList.get(i).name.equals(sat)){ if(threadList.get(i).getTLE().getName().equals(sat)){
threadList.get(i).stop(); threadList.remove(i);
} }
} }
} }
public static satPosition getSatPos(String sat){ public static satPosition getSatPos(String sat){
int satNum = searchThread(sat); int satNum = searchThread(sat);
return threadList.get(satNum).sat.getPosition(); return threadList.get(satNum).getPosition();
} }
public static List<satPosition> getTracks(){ public static List<satPosition> getTracks(){
List<satPosition> positions = new ArrayList<satPosition>(); List<satPosition> positions = new ArrayList<satPosition>();
for(int i =0;i<threadList.size();i++){ for(int i =0;i<threadList.size();i++){
positions.add(threadList.get(i).getPos()); positions.add(threadList.get(i).getPosition());
} }
return positions; return positions;
} }
private static int searchThread(String sat){ private static int searchThread(String sat){
for(int i = 0;i<threadList.size();i++){ 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; return i;
} }
} }
......
...@@ -28,6 +28,15 @@ public class satPosition{ ...@@ -28,6 +28,15 @@ public class satPosition{
this.time = new Date(); 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(){ public String getName(){
return name; 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