From 1caba29952307e005eae662fcace54b2252b8c97 Mon Sep 17 00:00:00 2001 From: manut Date: Sun, 12 Aug 2007 11:39:18 +0000 Subject: Initial git-svn-id: svn+ssh://mecka.net/home/svn/geoc@1 58fc9717-fb00-483d-b79c-3a878c4e3be5 --- trunk/build/preprocessed/nav/processLoc.java | 104 +++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100755 trunk/build/preprocessed/nav/processLoc.java (limited to 'trunk/build/preprocessed/nav/processLoc.java') diff --git a/trunk/build/preprocessed/nav/processLoc.java b/trunk/build/preprocessed/nav/processLoc.java new file mode 100755 index 0000000..fdcd863 --- /dev/null +++ b/trunk/build/preprocessed/nav/processLoc.java @@ -0,0 +1,104 @@ +/* + * processLoc.java + * + * Created on July 14, 2007, 4:59 PM + * + * To change this template, choose Tools | Template Manager + * and open the template in the editor. + */ + +package nav; + +import java.lang.Thread; +import javax.microedition.location.*; + +import gui.*; + +/** + * + * @author manut + */ +public class processLoc extends Thread { + + private geoc gui; + private Landmark dest; + private Location loc; + private Coordinates lastloc; + private Coordinates north; + + /** Creates a new instance of processLoc */ + public processLoc(geoc _gui) { + gui = _gui; + north = new Coordinates(90, 0, 0); + lastloc = null; + } + + public void set(Location _loc, Landmark _dest){ + + loc = _loc; + dest = _dest; + + } + + private double arcsin(double azimuth){ + double calc; + double last_calc = 0; + + for(double i = -1; i <= 1; i=i+0.001){ + calc = java.lang.Math.sin(i); + if ( calc == azimuth ){ + return i; + } else if (last_calc <= azimuth && calc > azimuth){ + return i; + } else + last_calc = calc; + } + return -2; + } + + public void run(){ + // calc course, distance + // A = LastPosition + // B = Destination + // C = Northpole + // D = ActPosition + // E = going further on straight forward, until you meet BC + // + // alphaI = arcsin( ( CD * sin(gammaI) ) / AB ) + // betaI = arcsin( ( CD * sin(gammaII)) / BD ) + // deltaI = 180 - alphaI - gammaI + // deltaII = 180 - deltaI + // epsilI = 180 - deltaII - gammaII + // epsilII = 180 - epsilI + // gesucht = 180 - epsilII - betaI + // --> courseCorrection = - 180 - arcsin( (CD * sin(gammaI)) / AB ) - gammaI - gammaII - arcsin( CD * (sin(gammaII)) / BD ) + + if( (lastloc!= null) && loc.isValid()) + { + + float gammaI = lastloc.azimuthTo(loc.getQualifiedCoordinates()); + float gammaII = loc.getQualifiedCoordinates().azimuthTo(dest.getQualifiedCoordinates()); + float AB = lastloc.distance(dest.getQualifiedCoordinates()); + float BD = loc.getQualifiedCoordinates().distance(dest.getQualifiedCoordinates()); + float CD = loc.getQualifiedCoordinates().distance(north); + + double actC = ( - 180 - arcsin( (CD * java.lang.Math.sin(gammaI)) / AB ) - gammaI - gammaII - arcsin( CD * (java.lang.Math.sin(gammaII)) / BD ) ) % 360; + int actCourse = (int) actC; + if (actCourse < 0) + actCourse = actCourse+360; + + // set GUI + gui.get_stringItemActNorth().setText(Coordinates.convert(loc.getQualifiedCoordinates().getLatitude(), 2)); + gui.get_stringItemActEast().setText(Coordinates.convert(loc.getQualifiedCoordinates().getLongitude(), 2)); + gui.get_stringItemActHeight().setText(String.valueOf(loc.getQualifiedCoordinates().getAltitude())); + if ( (actCourse != 112) ) + gui.get_stringItemCourse().setText(String.valueOf(actCourse)); + gui.get_stringItemDistance().setText(String.valueOf(BD)); + + } + + if ( loc.isValid() ) + lastloc = loc.getQualifiedCoordinates(); + } + +} -- cgit v1.2.3