public EphGps findEph(long unixTime, int satID, char satType, Location initialLocation) { long requestedTime = unixTime; EphGps eph = null; int maxBack = 12; while (eph == null && (maxBack--) > 0) { RinexNavigationParserGps rnp = getRNPByTimestamp(requestedTime, initialLocation); if (rnp != null) { if (rnp.isTimestampInEpocsRange(unixTime)) { eph = rnp.findEph(unixTime, satID, satType); } } if (eph == null) { requestedTime -= (1L * 3600L * 1000L); } } return(eph); }
private RinexNavigationParserGps getFromSUPL(string url, Location initialLocation) /*throws IOException*/ { RinexNavigationParserGps rnp = null; string suplName = url; int serverPort = 7275; bool sslEnabled = true; bool messageLoggingEnabled = true; bool loggingEnabled = true; File rnf = new File(RNP_CACHE, suplName); if (rnf.Exists()) { //System.out.println("Supl from cache file " + rnf); rnp = SuplFileToRnpParserGps(rnf); return(rnp); } //try //{ //Log.Warn(TAG, "getFromSUPL: Getting data using SUPL client..."); //SuplConnectionRequest request = // SuplConnectionRequest.builder() // .setServerHost(suplName) // .setServerPort(serverPort) // .setSslEnabled(sslEnabled) // .setMessageLoggingEnabled(messageLoggingEnabled) // .setLoggingEnabled(loggingEnabled) // .build(); //SuplController mSuplController = new SuplController(request); //mSuplController.sendSuplRequest((long)(initialLocation.Latitude * 1e7), (long)(initialLocation.Longitude * 1e7)); //EphemerisResponse ephResponse = mSuplController.generateEphResponse((long)(initialLocation.Latitude * 1e7), (long)(initialLocation.Longitude * 1e7)); //if (ephResponse != null) //{ // rnp = new RinexNavigationParserGps(ephResponse); //} Log.Warn(TAG, "getFromSUPL: Received data from SUPL server"); //} //catch (/*NullPointerException | //UnsupportedOperationException | //IllegalArgumentException | //IndexOutOfBoundsException e*/Exception e) { //Log.Error(TAG, "Exception thrown getting msg from SUPL server", e); //e.printStackTrace(); //} return(rnp); }
RinexNavigationParserGps getRNPByTimestamp(long unixTime, Location initialLocation) { RinexNavigationParserGps rnp = null; long reqTime = unixTime; // do { // found none, retrieve from urltemplate Time t = new Time(reqTime); //System.out.println("request: "+unixTime+" "+(new Date(t.getMsec()))+" week:"+t.getGpsWeek()+" "+t.getGpsWeekDay()); //final string url = t.formatTemplate(urltemplate); string url = "supl.google.com"; if (pool.ContainsKey(url)) { lock (this) { rnp = pool[url]; } } else { if (!retrievingFromServer.Contains(url)) { retrievingFromServer.Add(url); MyRunnable mr = new MyRunnable(); mr.url = url; mr.initialLocation = initialLocation; mr.retrievingFromServer = retrievingFromServer; mr.pool = pool; ThreadStart childref = new ThreadStart(mr.DoStuff); System.Threading.Thread childThread = new System.Threading.Thread(childref); childThread.Start(); /* * (new Thread(new Runnable() { * @Override * public void run() * { * } * })).start();*/ } return(null); } return(rnp); // } while (waitForData && rnp == null); }
/** Compute the GPS satellite coordinates * * INPUT: * @param unixTime = time of measurement reception - UNIX [milliseconds] * @param range = pseudorange measuremnent [meters] * @param satID = satellite ID * @param satType = satellite type indicating the constellation (E: Galileo, * G: GPS) * @param receiverClockError = 0.0 */ public SatellitePosition getSatPositionAndVelocities(long unixTime, double range, int satID, char satType, double receiverClockError, Location initialLocation) { //long unixTime = obs.getRefTime().getMsec(); //double range = obs.getSatByIDType(satID, satType).getPseudorange(0); RinexNavigationParserGps rnp = getRNPByTimestamp(unixTime, initialLocation); if (rnp != null) { if (rnp.isTimestampInEpocsRange(unixTime)) { return(rnp.getSatPositionAndVelocities(unixTime, range, satID, satType, receiverClockError)); } else { return(null); } } return(null); }
private RinexNavigationParserGps SuplFileToRnpParserGps(File rnf) { RinexNavigationParserGps rnp = null; return(rnp); }