fredag 28 maj 2010

Skol arbete, JAVA...

5% av hela projektet... Tråkig utbildning kan man säga.


import data.GPSDataParser;
import ocss.nmea.api.NMEAClient;
import java.util.ArrayList;
import javax.swing.text.AbstractDocument.Content;
import javax.swing.text.html.HTMLEditorKit.Parser;
import ocss.nmea.api.*;
import ocss.nmea.parser.StringParsers;
import ocss.nmea.api.NMEAException;
/**
* This class use NMEAClient. The class use a string.
* The Arraylist is connected with the String. It is connected with class from
* the second package with name GPSDataParser.
* @see GPSDataParser
* @see String
* @see NMEAClient
* @see StringParsers
*/
public class GPSClient extends NMEAClient{
String sentence;
/**
* this method is to put the value of x and y to use it in main_n_frame
* @see main_n_frame
*/
public static int x2, y2;

int r =0;
ArrayList array = new ArrayList();
StringParsers parsers = new StringParsers();
GPSDataParser parser = new GPSDataParser();
/**
* this method is using 2 strings.
* @see String
* @param prefix
* @param arrayOfIdentifiers
*/
public GPSClient(String prefix, String[] arrayOfIdentifiers) {
super(prefix, arrayOfIdentifiers);
}
/**
* this method is using NMEAEvent.
* The method prints results after calculating.
*


* The results of: Number of saterllites, fix quality, PDOP value, PHOP value,
* PVOP value, Latitude value, Longitude value, X & Y.
* @see NMEAEvent
* @see println
* @see Content
* @param event
*/
@Override
public void dataDetectedEvent(NMEAEvent event) {
if (isRMCSentence(event.getContent())) {
String XX,YY;
XX = parser.getLatitude(event.getContent());
YY = parser.getLongitude(event.getContent());
System.out.println(r+"Latitude: "
+ XX);
System.out.println("Longitude: "
+ YY);r++;
GPSClient.exchangeTOxy(XX, YY);
System.out.println("x and y values: " + x2 +" "+ y2);
}
}
/**
* This method is using String Xlon and String lat to create new value for x and a
* new value for y.
* @param X
* @param Y
* @see String
* @see Parser
*/
public static void exchangeTOxy (String X,String Y) {
double a=918-(11.9395-Double.parseDouble(Y))/0.000014923747277;
x2=(int) ((int) (a * 100000) / 100000.0);
double b=(57.7095-Double.parseDouble(X))/0.000007913669065;
y2=(int) ((int) (b * 100000) / 100000.0);
}
/**
* This method is usin boolean and string.
* This method is getting information from the package data.
* @see data.
* @see Boolean
* @see String
* @return
*/
private boolean isRMCSentence(String sentence) {
String identifier = sentence.substring(0, 6);
if (identifier.equals("$GPRMC")) {
return true;
} else {
return false;
}
}
}

Inga kommentarer:

Skicka en kommentar