// EPS: Elgaard Positioning System: GPS navigation software. // Copyright (C) 1997, 1999, 2000 Niels Elgaard Larsen // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // Niels Elgaard Larsen, // import java.awt.*; import java.io.*; import java.net.*; import java.lang.Runtime; import java.util.Date; import java.text.*; import java.util.Locale; class TrackC { static int nTR=0, maxTR=200; static TRPos track[] = new TRPos[maxTR]; static TRPos lastPlotted=new TRPos(null,null); static TRPos lastTimed=new TRPos(null,null); static double adist=0; static int mx,my; static boolean mfound=true; static void readTracks(URL epsBase, String trfile, int filf, GMenv menv){ int posFmt=Pone.DDD; URL tURL; BufferedReader dis; String inputLine; int lineN =0; //GMenv.trfile = trfile; Datum pDatum = Pos.WGS84; try { tURL =new URL(epsBase,trfile); if (GMenv.useFShield) { dis = ChartFrame1.fShield.getBuf(tURL); } else { dis = new BufferedReader(new InputStreamReader(tURL.openStream())); } inputLine = ChartFrame1.readline(dis); if (inputLine !=null) { if (filf==Pone.ffGPSTRANS){ if (inputLine.substring(0,7).equals("Format:")){ if (inputLine.substring(8,11).equals("DDD")){ posFmt =Pone.DDD; } else { posFmt =Pone.MDD; } int datumNo = Integer.parseInt(inputLine.substring(43,46)); pDatum = Pos.getGtDatum(datumNo); inputLine = ChartFrame1.readline(dis); } } else if (filf==Pone.ffGRM){ inputLine = ChartFrame1.readline(dis); while (inputLine != null && inputLine.length()==0 || inputLine.charAt(0)!='T') { inputLine = ChartFrame1.readline(dis); } } inputLine = ChartFrame1.readline(dis); while (inputLine != null) { lineN++; if (inputLine.length()<3){ insertTrack(new TRPos(null,new Date(0))); }else{ TRPos newTP; newTP = new TRPos(); if (filf==Pone.ffGPSTRANS){ String ds; newTP.tpos.y = Pone.str2Pone(inputLine,2,posFmt,filf); newTP.tpos.x = Pone.str2Pone(inputLine,3,posFmt,filf); ds = CAux.getCol(inputLine,1,'\t'); //System.out.println(" ds=" + ds); newTP.tm = CAux.readDate(ds); } else if (filf==Pone.ffGRM){ newTP.tpos.y = Pone.str2Pone(inputLine,1,posFmt,filf); newTP.tpos.x = Pone.str2Pone(inputLine,2,posFmt,filf); newTP.tm = CAux.readDate(inputLine.substring(26,44)); } // System.out.println(" parsing time"+CAux.getCol(inputLine,1,'\t')); newTP.tpos.theDatum = pDatum; insertTrack(newTP); // System.out.println("new tr" + " "+track[nTR].toString(0)); // System.out.println("new tr" + " " + newTP.toString(1)); } inputLine = ChartFrame1.readline(dis); } } dis.close(); } catch (MalformedURLException me) { System.out.println("MalformedURLException: " + me); } catch (FileNotFoundException fe) { System.out.println("Tracks file not found: " + fe); } catch (IOException ioe) { System.out.println("Track not found: " + ioe); } catch (StringIndexOutOfBoundsException ioe) { System.out.println("Could not read Track file line" + lineN); ioe.printStackTrace(); } catch (NumberFormatException ioe) { System.out.println("Could not read Track file " + ioe); ioe.printStackTrace(); } catch (SecurityException ioe) { System.out.println("tr read not allowed " + ioe); ioe.printStackTrace(); } } static void deleteAll() { nTR=0; } static void insertTrack(TRPos tr){ if (nTR>= maxTR) { int xi; TRPos t0[] = track; track = new TRPos[2*maxTR]; for (xi=0; xi