im trying to plot latitude ,longitude and display the the completed track but can only display the current position as the file is read . I believe i need to create an array list to store the positions before they can be permanently displayed
can somone offer some help with this.
many thanks
this is the code im running with a sample of the gps code at the bottom.
BufferedReader reader;
String line;
//-----------------------
float latitude =0.0;
String northSouth;
float longitude = 0.0;
String eastWest;
float heading = 0.0;
float speed =0.0;
int hrs,mins,secs;
int thisDay, thisMonth,thisYear;
//-----------------------------------
float x;
float y;
PImage raster;
void setup() {
size(1700, 700);
//-----------------
PFont myFont =createFont(PFont.list()[2],24);
textFont(myFont);
//-------------
ellipseMode(CENTER);
smooth();
frameRate(10);
// Open the file from the createWriter() example
reader = createReader("gprmc.txt");
}
void draw() {
background (0);
fill (255);
text(thisMonth+"/"+thisDay+"/"+thisYear,50,30);
text(hrs+":"+mins+":"+secs +" ",50,50);
text("Lng" +" " +eastWest, 50,70);
text("Lat " +" "+northSouth , 50,90);
text("heading "+ heading + "degrees",50,110);
// text(hrs+":"+mins+":"+secs +"GMT ",50,130);
//text("Lat " +" "+northSouth , 50,130);
// text("heading "+ heading + "degrees",50,150);
text("Speed M/Sec "+ speed ,50,170);
// drawArrow(heading);
try {
line = reader.readLine();
} catch (IOException e) {
e.printStackTrace();
line = null;
}
if (line == null) {
println();
// Stop reading because of an error or file is empty
//noLoop();
} else {
String[] pieces = split(line, ",");
println();
//-----------------------------------
//if (pieces[0].equals("$GPRMC")){
//----------------------------
int time = int(pieces[1]);
//first two digits of time are the hours
//if (pieces[0].equals("$GPRMC")){
// getRMC (pieces);
if (pieces[0].equals("$GPRMC")){
float latitude = float(pieces[3])/100.0;
float longitude= float(pieces[5])/100.0;
heading = float (pieces[7]);
northSouth = (pieces[5]);
eastWest = (pieces [3]);
speed = float(pieces [7]);
int date = int (pieces[9]);
thisYear =date0+2000;
//second two digits are month
thisMonth =(date000)/100;
//first two digits of date are day
thisDay = date/10000 ;
if (pieces.length == 13) {float mapX = float(pieces[3]);
float mapY = float(pieces[5]);
println(mapX + " " + mapY);
//println();
float w_start = 00048.0990; // Longtitude start (largest longitude value)
float w_end = 00048.06929; // Longtitude end (smallest longitude value)
float h_start = 5120.1023; // Latitude start (largest latitude value)
float h_end = 5120.060012; // Latitude end (smallest latitude value)