Exemplo n.º 1
0
  private boolean funcLocMixVeloOk(Context ctx1, Context ctx2) { // boolean function 4

    String v1 = (String) ctx1.get(Context.FLD_OBJECT);
    String v2 = (String) ctx1.get(Context.FLD_TIMESTAMP);
    String v3 = (String) ctx2.get(Context.FLD_OBJECT);
    String v4 = (String) ctx2.get(Context.FLD_TIMESTAMP);
    if (v1 == null || v2 == null || v3 == null || v4 == null) {
      return false;
    }

    StringTokenizer st = new StringTokenizer(v1);
    double x1 = Double.parseDouble(st.nextToken());
    double y1 = Double.parseDouble(st.nextToken());
    st = new StringTokenizer(v3);
    double x2 = Double.parseDouble(st.nextToken());
    double y2 = Double.parseDouble(st.nextToken());
    double dist = Coordinates.calDist(x1, y1, x2, y2);
    long t = TimeFormat.convert(v4) - TimeFormat.convert(v2) - STAY_TIME; // Different here

    // The velocity should be between vmin and vmax
    boolean result = false;
    double vmin = (VELOCITY * ((double) t / 1000) - 2 * ERR) / ((double) t / 1000);
    double vmax = (VELOCITY * ((double) t / 1000) + 2 * ERR) / ((double) t / 1000);
    double ve = dist / ((double) t / 1000);
    if (ve >= vmin && ve <= vmax) {
      result = true;
    }

    return result;
  }
Exemplo n.º 2
0
 private boolean funcLocMixVeloOk(ccr.app.Context ctx1, ccr.app.Context ctx2) {
   java.lang.String v1 = (java.lang.String) ctx1.get(Context.FLD_OBJECT);
   java.lang.String v2 = (java.lang.String) ctx1.get(Context.FLD_TIMESTAMP);
   java.lang.String v3 = (java.lang.String) ctx2.get(Context.FLD_OBJECT);
   java.lang.String v4 = (java.lang.String) ctx2.get(Context.FLD_TIMESTAMP);
   if (v1 == null || v2 == null || v3 == null || v4 == null) {
     return false;
   }
   java.util.StringTokenizer st = new java.util.StringTokenizer(v1);
   double x1 = Double.parseDouble(st.nextToken());
   double y1 = Double.parseDouble(st.nextToken());
   st = new java.util.StringTokenizer(v3);
   double x2 = Double.parseDouble(st.nextToken());
   double y2 = Double.parseDouble(st.nextToken());
   double dist = Coordinates.calDist(x1, y1, x2, y2);
   long t = TimeFormat.convert(v4) - TimeFormat.convert(v2) - STAY_TIME;
   boolean result = false;
   double vmin = (VELOCITY * ((double) t / 1000) - 2 * ERR) / ((double) t / 1000);
   double vmax = (VELOCITY * ((double) t / 1000) + 2 * ERR) / ((double) t / 1000);
   double ve = dist / ((double) t / 1000);
   if (ve >= vmin && ve <= vmax) {
     result = true;
   }
   return result;
 }
Exemplo n.º 3
0
 private boolean funcLocDistOk(ccr.app.Context ctx1, ccr.app.Context ctx2) {
   java.lang.String v1 = (java.lang.String) ctx1.get(Context.FLD_OBJECT);
   java.lang.String v2 = (java.lang.String) ctx2.get(Context.FLD_OBJECT);
   if (v1 == null || v2 == null) {
     return false;
   }
   java.util.StringTokenizer st = new java.util.StringTokenizer(v1);
   double x1 = Double.parseDouble(st.nextToken());
   double y1 = Double.parseDouble(st.nextToken());
   st = new java.util.StringTokenizer(v2);
   double x2 = Double.parseDouble(st.nextToken());
   double y2 = Double.parseDouble(st.nextToken());
   double dist = Coordinates.calDist(x1, y1, x2, y2);
   boolean result = false;
   if (dist <= 2 * ERR) {
     result = true;
   }
   return result;
 }
Exemplo n.º 4
0
  private boolean funcLocDistOk(Context ctx1, Context ctx2) { // boolean function 1

    String v1 = (String) ctx1.get(Context.FLD_OBJECT);
    String v2 = (String) ctx2.get(Context.FLD_OBJECT);
    if (v1 == null || v2 == null) {
      return false;
    }

    StringTokenizer st = new StringTokenizer(v1);
    double x1 = Double.parseDouble(st.nextToken());
    double y1 = Double.parseDouble(st.nextToken());
    st = new StringTokenizer(v2);
    double x2 = Double.parseDouble(st.nextToken());
    double y2 = Double.parseDouble(st.nextToken());
    double dist = Coordinates.calDist(x1, y1, x2, y2);

    // The distance should not be larger than two times the allowed error
    boolean result = false;
    if (dist <= 2 * ERR) {
      result = true;
    }

    return result;
  }
Exemplo n.º 5
0
 public java.lang.Object application(java.lang.String testcase) {
   int seed = Integer.parseInt(testcase);
   queue = new java.util.Vector();
   ccr.app.Coordinates location = null;
   java.util.Random rand = new java.util.Random(seed);
   ccr.app.CCRScenarios scenarios = new ccr.app.CCRScenarios(seed);
   long t;
   ccr.app.Coordinates actLoc;
   ccr.app.Coordinates estLoc;
   ccr.app.Coordinates lastLoc;
   double dist;
   double displace;
   double error;
   int c = 0;
   int bPos = -1;
   int cPos = -1;
   int stay = 0;
   int lastPos = -1;
   timestamp = System.currentTimeMillis();
   counter = 0;
   int moved = 0;
   int reliable = 0;
   ccr.app.Coordinates lastLocation = new ccr.app.Coordinates(0, 0);
   cPos = rand.nextInt(CCRScenarios.POS_NUM);
   stay = rand.nextInt(MAX_STAY) + 1;
   c = c + stay;
   bPos = cPos;
   stay = stay - 1;
   actLoc = scenarios.getActLoc(sid, cPos);
   estLoc = scenarios.getEstLoc(sid, cPos);
   curEstX = estLoc.x;
   curEstY = estLoc.y;
   curEstX = curEstX + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE;
   curEstY = curEstY + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE;
   t = 0;
   timestamp = timestamp + t;
   lastPos = cPos;
   candidate = generateCtx();
   resolve();
   location = toCoordinates(candidate);
   displace =
       Math.sqrt(
           (location.x - lastLocation.x) * (location.x - lastLocation.x)
               + (location.y - lastLocation.y) * (location.y - lastLocation.y));
   moved = moved + toBoolean(displace);
   error =
       Math.sqrt(
           (actLoc.x - location.x) * (actLoc.x - location.x)
               + (actLoc.y - location.y) * (actLoc.y - location.y));
   lastLocation = location;
   counter = counter + 1;
   while (stay > 0) {
     stay = stay - 1;
     actLoc = scenarios.getActLoc(sid, cPos);
     estLoc = scenarios.getEstLoc(sid, cPos);
     curEstX = estLoc.x;
     curEstY = estLoc.y;
     curEstX = curEstX + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE;
     curEstY = curEstY + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE;
     lastLoc = scenarios.getActLoc(sid, lastPos);
     dist = Coordinates.calDist(lastLoc, actLoc);
     t = STAY_TIME;
     timestamp = timestamp + t;
     candidate = generateCtx();
     resolve();
     location = toCoordinates(candidate);
     displace =
         Math.sqrt(
             (location.x - lastLocation.x) * (location.x - lastLocation.x)
                 + (location.y - lastLocation.y) * (++location.y - lastLocation.y));
     moved = moved + toBoolean(displace);
     error =
         Math.sqrt(
             (actLoc.x - location.x) * (actLoc.x - location.x)
                 + (actLoc.y - location.y) * (actLoc.y - location.y));
     if (error <= ERR) {
       reliable = reliable + 1;
     }
     lastLocation = location;
     counter = counter + 1;
   }
   cPos = rand.nextInt(CCRScenarios.POS_NUM);
   while (cPos == -1
       || cPos == bPos
       || Coordinates.calDist(scenarios.getActLoc(sid, bPos), scenarios.getActLoc(sid, cPos))
           < WALK_DIST) {
     cPos = rand.nextInt(CCRScenarios.POS_NUM);
   }
   stay = rand.nextInt(MAX_STAY) + 1;
   c = c + stay;
   bPos = cPos;
   stay = stay - 1;
   actLoc = scenarios.getActLoc(sid, cPos);
   estLoc = scenarios.getEstLoc(sid, cPos);
   curEstX = estLoc.x;
   curEstY = estLoc.y;
   curEstX = curEstX + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE;
   curEstY = curEstY + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE;
   lastLoc = scenarios.getActLoc(sid, lastPos);
   dist = Coordinates.calDist(lastLoc, actLoc);
   t = (long) (dist / VELOCITY * 1000);
   timestamp = timestamp + t;
   lastPos = cPos;
   candidate = generateCtx();
   resolve();
   location = toCoordinates(candidate);
   displace =
       Math.sqrt(
           (location.x - lastLocation.x) * (location.x - lastLocation.x)
               + (location.y - lastLocation.y) * (location.y - lastLocation.y));
   moved = moved + toBoolean(displace);
   error =
       Math.sqrt(
           (actLoc.x - location.x) * (actLoc.x - location.x)
               + (actLoc.y - location.y) * (actLoc.y - location.y));
   lastLocation = location;
   counter = counter + 1;
   while (stay > 0) {
     stay = stay - 1;
     actLoc = scenarios.getActLoc(sid, cPos);
     estLoc = scenarios.getEstLoc(sid, cPos);
     curEstX = estLoc.x;
     curEstY = estLoc.y;
     curEstX = curEstX + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE;
     curEstY = curEstY + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE;
     lastLoc = scenarios.getActLoc(sid, lastPos);
     dist = Coordinates.calDist(lastLoc, actLoc);
     t = STAY_TIME;
     timestamp = timestamp + t;
     lastPos = cPos;
     candidate = generateCtx();
     resolve();
     location = toCoordinates(candidate);
     displace =
         Math.sqrt(
             (location.x - lastLocation.x) * (location.x - lastLocation.x)
                 + (location.y - lastLocation.y) * (location.y - lastLocation.y));
     moved = moved + toBoolean(displace);
     error =
         Math.sqrt(
             (actLoc.x - location.x) * (actLoc.x - location.x)
                 + (actLoc.y - location.y) * (actLoc.y - location.y));
     if (error <= ERR) {
       reliable = reliable + 1;
     }
     lastLocation = location;
     counter = counter + 1;
   }
   cPos = rand.nextInt(CCRScenarios.POS_NUM);
   while (cPos == -1
       || cPos == bPos
       || Coordinates.calDist(scenarios.getActLoc(sid, bPos), scenarios.getActLoc(sid, cPos))
           < WALK_DIST) {
     cPos = rand.nextInt(CCRScenarios.POS_NUM);
   }
   stay = rand.nextInt(MAX_STAY) + 1;
   c = c + stay;
   bPos = cPos;
   stay = stay - 1;
   actLoc = scenarios.getActLoc(sid, cPos);
   estLoc = scenarios.getEstLoc(sid, cPos);
   curEstX = estLoc.x;
   curEstY = estLoc.y;
   curEstX = curEstX + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE;
   curEstY = curEstY + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE;
   lastLoc = scenarios.getActLoc(sid, lastPos);
   dist = Coordinates.calDist(lastLoc, actLoc);
   t = (long) (dist / VELOCITY * 1000);
   timestamp = timestamp + t;
   lastPos = cPos;
   candidate = generateCtx();
   resolve();
   location = toCoordinates(candidate);
   displace =
       Math.sqrt(
           (location.x - lastLocation.x) * (location.x - lastLocation.x)
               + (location.y - lastLocation.y) * (location.y - lastLocation.y));
   moved = moved + toBoolean(displace);
   error =
       Math.sqrt(
           (actLoc.x - location.x) * (actLoc.x - location.x)
               + (actLoc.y - location.y) * (actLoc.y - location.y));
   lastLocation = location;
   counter = counter + 1;
   while (stay > 0) {
     stay = stay - 1;
     actLoc = scenarios.getActLoc(sid, cPos);
     estLoc = scenarios.getEstLoc(sid, cPos);
     curEstX = estLoc.x;
     curEstY = estLoc.y;
     curEstX = curEstX + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE;
     curEstY = curEstY + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE;
     lastLoc = scenarios.getActLoc(sid, lastPos);
     dist = Coordinates.calDist(lastLoc, actLoc);
     t = STAY_TIME;
     timestamp = timestamp + t;
     lastPos = cPos;
     candidate = generateCtx();
     resolve();
     location = toCoordinates(candidate);
     displace =
         Math.sqrt(
             (location.x - lastLocation.x) * (location.x - lastLocation.x)
                 + (location.y - lastLocation.y) * (location.y - lastLocation.y));
     moved = moved + toBoolean(displace);
     error =
         Math.sqrt(
             (actLoc.x - location.x) * (actLoc.x - location.x)
                 + (actLoc.y - location.y) * (actLoc.y - location.y));
     if (error <= ERR) {
       reliable = reliable + 1;
     }
     lastLocation = location;
     counter = counter + 1;
   }
   cPos = rand.nextInt(CCRScenarios.POS_NUM);
   while (cPos == -1
       || cPos == bPos
       || Coordinates.calDist(scenarios.getActLoc(sid, bPos), scenarios.getActLoc(sid, cPos))
           < WALK_DIST) {
     cPos = rand.nextInt(CCRScenarios.POS_NUM);
   }
   stay = rand.nextInt(MAX_STAY) + 1;
   c = c + stay;
   bPos = cPos;
   stay = stay - 1;
   actLoc = scenarios.getActLoc(sid, cPos);
   estLoc = scenarios.getEstLoc(sid, cPos);
   curEstX = estLoc.x;
   curEstY = estLoc.y;
   curEstX = curEstX + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE;
   curEstY = curEstY + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE;
   lastLoc = scenarios.getActLoc(sid, lastPos);
   dist = Coordinates.calDist(lastLoc, actLoc);
   t = (long) (dist / VELOCITY * 1000);
   timestamp = timestamp + t;
   lastPos = cPos;
   candidate = generateCtx();
   resolve();
   location = toCoordinates(candidate);
   displace =
       Math.sqrt(
           (location.x - lastLocation.x) * (location.x - lastLocation.x)
               + (location.y - lastLocation.y) * (location.y - lastLocation.y));
   moved = moved + toBoolean(displace);
   error =
       Math.sqrt(
           (actLoc.x - location.x) * (actLoc.x - location.x)
               + (actLoc.y - location.y) * (actLoc.y - location.y));
   lastLocation = location;
   counter = counter + 1;
   while (stay > 0) {
     stay = stay - 1;
     actLoc = scenarios.getActLoc(sid, cPos);
     estLoc = scenarios.getEstLoc(sid, cPos);
     curEstX = estLoc.x;
     curEstY = estLoc.y;
     curEstX = curEstX + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE;
     curEstY = curEstY + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE;
     lastLoc = scenarios.getActLoc(sid, lastPos);
     dist = Coordinates.calDist(lastLoc, actLoc);
     t = STAY_TIME;
     timestamp = timestamp + t;
     lastPos = cPos;
     candidate = generateCtx();
     resolve();
     location = toCoordinates(candidate);
     displace =
         Math.sqrt(
             (location.x - lastLocation.x) * (location.x - lastLocation.x)
                 + (location.y - lastLocation.y) * (location.y - lastLocation.y));
     moved = moved + toBoolean(displace);
     error =
         Math.sqrt(
             (actLoc.x - location.x) * (actLoc.x - location.x)
                 + (actLoc.y - location.y) * (actLoc.y - location.y));
     if (error <= ERR) {
       reliable = reliable + 1;
     }
     lastLocation = location;
     counter = counter + 1;
   }
   cPos = rand.nextInt(CCRScenarios.POS_NUM);
   while (cPos == -1
       || cPos == bPos
       || Coordinates.calDist(scenarios.getActLoc(sid, bPos), scenarios.getActLoc(sid, cPos))
           < WALK_DIST) {
     cPos = rand.nextInt(CCRScenarios.POS_NUM);
   }
   stay = rand.nextInt(MAX_STAY) + 1;
   c = c + stay;
   bPos = cPos;
   stay = stay - 1;
   actLoc = scenarios.getActLoc(sid, cPos);
   estLoc = scenarios.getEstLoc(sid, cPos);
   curEstX = estLoc.x;
   curEstY = estLoc.y;
   curEstX = curEstX + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE;
   curEstY = curEstY + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE;
   lastLoc = scenarios.getActLoc(sid, lastPos);
   dist = Coordinates.calDist(lastLoc, actLoc);
   t = (long) (dist / VELOCITY * 1000);
   timestamp = timestamp + t;
   lastPos = cPos;
   candidate = generateCtx();
   resolve();
   location = toCoordinates(candidate);
   displace =
       Math.sqrt(
           (location.x - lastLocation.x) * (location.x - lastLocation.x)
               + (location.y - lastLocation.y) * (location.y - lastLocation.y));
   moved = moved + toBoolean(displace);
   error =
       Math.sqrt(
           (actLoc.x - location.x) * (actLoc.x - location.x)
               + (actLoc.y - location.y) * (actLoc.y - location.y));
   lastLocation = location;
   counter = counter + 1;
   while (stay > 0) {
     stay = stay - 1;
     actLoc = scenarios.getActLoc(sid, cPos);
     estLoc = scenarios.getEstLoc(sid, cPos);
     curEstX = estLoc.x;
     curEstY = estLoc.y;
     curEstX = curEstX + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE;
     curEstY = curEstY + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE;
     lastLoc = scenarios.getActLoc(sid, lastPos);
     dist = Coordinates.calDist(lastLoc, actLoc);
     t = STAY_TIME;
     timestamp = timestamp + t;
     lastPos = cPos;
     candidate = generateCtx();
     resolve();
     location = toCoordinates(candidate);
     displace =
         Math.sqrt(
             (location.x - lastLocation.x) * (location.x - lastLocation.x)
                 + (location.y - lastLocation.y) * (location.y - lastLocation.y));
     moved = moved + toBoolean(displace);
     error =
         Math.sqrt(
             (actLoc.x - location.x) * (actLoc.x - location.x)
                 + (actLoc.y - location.y) * (actLoc.y - location.y));
     if (error <= ERR) {
       reliable = reliable + 1;
     }
     lastLocation = location;
     counter = counter + 1;
   }
   cPos = rand.nextInt(CCRScenarios.POS_NUM);
   while (cPos == -1
       || cPos == bPos
       || Coordinates.calDist(scenarios.getActLoc(sid, bPos), scenarios.getActLoc(sid, cPos))
           < WALK_DIST) {
     cPos = rand.nextInt(CCRScenarios.POS_NUM);
   }
   stay = rand.nextInt(MAX_STAY) + 1;
   c = c + stay;
   bPos = cPos;
   stay = stay - 1;
   actLoc = scenarios.getActLoc(sid, cPos);
   estLoc = scenarios.getEstLoc(sid, cPos);
   curEstX = estLoc.x;
   curEstY = estLoc.y;
   curEstX = curEstX + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE;
   curEstY = curEstY + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE;
   lastLoc = scenarios.getActLoc(sid, lastPos);
   dist = Coordinates.calDist(lastLoc, actLoc);
   t = (long) (dist / VELOCITY * 1000);
   timestamp = timestamp + t;
   lastPos = cPos;
   candidate = generateCtx();
   resolve();
   location = toCoordinates(candidate);
   displace =
       Math.sqrt(
           (location.x - lastLocation.x) * (location.x - lastLocation.x)
               + (location.y - lastLocation.y) * (location.y - lastLocation.y));
   moved = moved + toBoolean(displace);
   error =
       Math.sqrt(
           (actLoc.x - location.x) * (actLoc.x - location.x)
               + (actLoc.y - location.y) * (actLoc.y - location.y));
   lastLocation = location;
   counter = counter + 1;
   while (stay > 0) {
     stay = stay - 1;
     actLoc = scenarios.getActLoc(sid, cPos);
     estLoc = scenarios.getEstLoc(sid, cPos);
     curEstX = estLoc.x;
     curEstY = estLoc.y;
     curEstX = curEstX + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE;
     curEstY = curEstY + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE;
     lastLoc = scenarios.getActLoc(sid, lastPos);
     dist = Coordinates.calDist(lastLoc, actLoc);
     t = STAY_TIME;
     timestamp = timestamp + t;
     lastPos = cPos;
     candidate = generateCtx();
     resolve();
     location = toCoordinates(candidate);
     displace =
         Math.sqrt(
             (location.x - lastLocation.x) * (location.x - lastLocation.x)
                 + (location.y - lastLocation.y) * (location.y - lastLocation.y));
     moved = moved + toBoolean(displace);
     error =
         Math.sqrt(
             (actLoc.x - location.x) * (actLoc.x - location.x)
                 + (actLoc.y - location.y) * (actLoc.y - location.y));
     if (error <= ERR) {
       reliable = reliable + 1;
     }
     lastLocation = location;
     counter = counter + 1;
   }
   ccr.app.ApplicationResult result = new ccr.app.ApplicationResult(moved, reliable);
   return result;
 }
Exemplo n.º 6
0
  public Object application(String testcase) {

    // Program ID [c]

    // Ordinary Variable [location, lastLocation, moved, reliable, displace, error, curEstX,
    // curEstY, c, bPos, cPos, stay, lastPos, timestamp, counter, t, actLoc, estLoc, lastLoc, dist]

    // Context Variable [candidate]

    // Assignment [=]

    int seed = Integer.parseInt(testcase);
    queue = new Vector();
    Coordinates location = null;
    Random rand = new Random(seed);
    CCRScenarios scenarios = new CCRScenarios(seed);
    long t;
    Coordinates actLoc;
    Coordinates estLoc;
    Coordinates lastLoc;
    double dist;
    double displace;
    double error;

    // ENTRY // NODE

    int c = 0;
    int bPos = -1;
    int cPos = -1;
    int stay = 0;
    //	int mode = MODE_MIX;
    int lastPos = -1;
    timestamp = System.currentTimeMillis();
    counter = 0;
    //	double distance = 0;
    int moved = 0;
    int reliable = 0;
    Coordinates lastLocation = new Coordinates(0, 0);

    // initial
    //	if (bPos == -1) {
    cPos = rand.nextInt(CCRScenarios.POS_NUM);
    //	} else {
    //		cPos = rand.nextInt(CCRScenarios.POS_NUM);
    //		while (cPos == -1 || cPos == bPos ||
    //			Coordinates.calDist(scenarios.getActLoc(sid, bPos), scenarios.getActLoc(sid, cPos)) <
    // WALK_DIST) {
    //			cPos = rand.nextInt(CCRScenarios.POS_NUM);
    //		}
    //	}
    stay = rand.nextInt(MAX_STAY) + 1;
    //	mode = MODE_MIX; // Experimentation: Variation on mode
    //	if (mode == MODE_WALK) {
    //		stay = 1;  // Always walk without stay
    //	}
    //	if (c + stay > PATH_LEN) {
    //		stay = PATH_LEN - c;
    //	}
    c = c + stay;
    bPos = cPos;

    stay = stay - 1; // initial

    actLoc = scenarios.getActLoc(sid, cPos);
    // Set the estimated location for pos
    estLoc = scenarios.getEstLoc(sid, cPos);
    curEstX = estLoc.x;
    curEstY = estLoc.y;

    // Apply the noise
    curEstX = curEstX + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE; // [- NOISE, + NOISE)
    curEstY = curEstY + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE; // [- NOISE, + NOISE)

    // Decide the time we should wait before sending the next context
    t = 0; // Only for the first time
    //	if (lastPos != -1) {  // Not the first time
    //		lastLoc = scenarios.getActLoc(sid, lastPos); // The actual location for lastPos
    //		dist = Coordinates.calDist(lastLoc, actLoc);
    //		if (lastPos != cPos) {  // Walk
    //			t = (long) (dist / VELOCITY * 1000); // Estimated time required from lastLoc to actLoc
    //		} else {  // Stay
    //			t = STAY_TIME;
    //		}
    //	}
    timestamp = timestamp + t;
    lastPos = cPos;
    candidate = generateCtx();
    resolve();
    location = toCoordinates(candidate);
    //	System.out.println(counter + ":\t(" + location.x + ", " + location.y + ")");
    //	distance = distance + Coordinates.calDist(location, lastLocation); // Experiments: calculate
    // distance
    displace =
        Math.sqrt(
            (location.x - lastLocation.x) * (location.x - lastLocation.x)
                + (location.y - lastLocation.y) * (location.y - lastLocation.y));
    moved = moved + toBoolean(displace);
    error =
        Math.sqrt(
            (actLoc.x - location.x) * (actLoc.x - location.x)
                + (actLoc.y - location.y) * (actLoc.y - location.y));
    lastLocation = location;
    counter = counter + 1;

    while (stay > 0) { // initial
      stay = stay - 1;

      actLoc = scenarios.getActLoc(sid, cPos);
      // Set the estimated location for pos
      estLoc = scenarios.getEstLoc(sid, cPos);
      curEstX = estLoc.x;
      curEstY = estLoc.y;

      // Apply the noise
      curEstX =
          curEstX + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE; // [- NOISE, + NOISE)
      curEstY =
          curEstY + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE; // [- NOISE, + NOISE)

      // Decide the time we should wait before sending the next context
      lastLoc = scenarios.getActLoc(sid, lastPos); // The actual location for lastPos
      dist = Coordinates.calDist(lastLoc, actLoc);
      //	if (lastPos != cPos) {  // Walk
      //		t = (long) (dist / VELOCITY * 1000); // Estimated time required from lastLoc to actLoc
      //	} else {  // Stay
      t = STAY_TIME;
      //	}
      timestamp = timestamp + t;
      //	lastPos = cPos;
      candidate = generateCtx();
      resolve();
      location = toCoordinates(candidate);
      //	System.out.println(counter + ":\t(" + location.x + ", " + location.y + ")");
      //	distance = distance + Coordinates.calDist(location, lastLocation); // Experiments:
      // calculate distance
      displace =
          Math.sqrt(
              (location.x - lastLocation.x) * (location.x - lastLocation.x)
                  + (location.y - lastLocation.y) * (location.y - lastLocation.y));
      moved = moved + toBoolean(displace);
      error =
          Math.sqrt(
              (actLoc.x - location.x) * (actLoc.x - location.x)
                  + (actLoc.y - location.y) * (actLoc.y - location.y));
      if (error <= ERR) {
        reliable = reliable + 1;
      }
      lastLocation = location;
      counter = counter + 1;
    }

    // 1
    cPos = rand.nextInt(CCRScenarios.POS_NUM);
    while (cPos == -1
        || cPos == bPos
        || Coordinates.calDist(scenarios.getActLoc(sid, bPos), scenarios.getActLoc(sid, cPos))
            < WALK_DIST) {
      cPos = rand.nextInt(CCRScenarios.POS_NUM);
    }
    stay = rand.nextInt(MAX_STAY) + 1;
    c = c + stay;
    bPos = cPos;
    stay = stay - 1; // 1
    actLoc = scenarios.getActLoc(sid, cPos);
    estLoc = scenarios.getEstLoc(sid, cPos);
    curEstX = estLoc.x;
    curEstY = estLoc.y;
    curEstX = curEstX + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE; // [- NOISE, + NOISE)
    curEstY = curEstY + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE; // [- NOISE, + NOISE)
    lastLoc = scenarios.getActLoc(sid, lastPos); // The actual location for lastPos
    dist = Coordinates.calDist(lastLoc, actLoc);
    t =
        (long)
            (dist / VELOCITY
                * 1000); // Experimentation: Estimated time required from lastLoc to actLoc
    timestamp = timestamp + t;
    lastPos = cPos;
    candidate = generateCtx();
    resolve();
    location = toCoordinates(candidate);
    //	distance = distance + Coordinates.calDist(location, lastLocation); // Experiments: calculate
    // distance
    displace =
        Math.sqrt(
            (location.x - lastLocation.x) * (location.x - lastLocation.x)
                + (location.y - lastLocation.y) * (location.y - lastLocation.y));
    moved = moved + toBoolean(displace);
    error =
        Math.sqrt(
            (actLoc.x - location.x) * (actLoc.x - location.x)
                + (actLoc.y - location.y) * (actLoc.y - location.y));
    lastLocation = location;
    counter = counter + 1;
    while (stay > 0) { // 1
      stay = stay - 1;
      actLoc = scenarios.getActLoc(sid, cPos);
      estLoc = scenarios.getEstLoc(sid, cPos);
      curEstX = estLoc.x;
      curEstY = estLoc.y;
      curEstX =
          curEstX + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE; // [- NOISE, + NOISE)
      curEstY =
          curEstY + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE; // [- NOISE, + NOISE)
      lastLoc = scenarios.getActLoc(sid, lastPos); // The actual location for lastPos
      dist = Coordinates.calDist(lastLoc, actLoc);
      t = STAY_TIME; // Experimentation:
      timestamp = timestamp + t;
      lastPos = cPos;
      candidate = generateCtx();
      resolve();
      location = toCoordinates(candidate);
      //	distance = distance + Coordinates.calDist(location, lastLocation); // Experiments:
      // calculate distance
      displace =
          Math.sqrt(
              (location.x - lastLocation.x) * (location.x - lastLocation.x)
                  + (location.y - lastLocation.y) * (location.y - lastLocation.y));
      moved = moved + toBoolean(displace);
      error =
          Math.sqrt(
              (actLoc.x - location.x) * (actLoc.x - location.x)
                  + (actLoc.y - location.y) * (actLoc.y - location.y));
      if (error <= ERR) {
        reliable = reliable + 1;
      }
      lastLocation = location;
      counter = counter + 1;
    }

    // 2
    cPos = rand.nextInt(CCRScenarios.POS_NUM);
    while (cPos == -1
        || cPos == bPos
        || Coordinates.calDist(scenarios.getActLoc(sid, bPos), scenarios.getActLoc(sid, cPos))
            < WALK_DIST) {
      cPos = rand.nextInt(CCRScenarios.POS_NUM);
    }
    stay = rand.nextInt(MAX_STAY) + 1;
    c = c + stay;
    bPos = cPos;
    stay = stay - 1; // 2
    actLoc = scenarios.getActLoc(sid, cPos);
    estLoc = scenarios.getEstLoc(sid, cPos);
    curEstX = estLoc.x;
    curEstY = estLoc.y;
    curEstX = curEstX + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE; // [- NOISE, + NOISE)
    curEstY = curEstY + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE; // [- NOISE, + NOISE)
    lastLoc = scenarios.getActLoc(sid, lastPos); // The actual location for lastPos
    dist = Coordinates.calDist(lastLoc, actLoc);
    t =
        (long)
            (dist / VELOCITY
                * 1000); // Experimentation: Estimated time required from lastLoc to actLoc
    timestamp = timestamp + t;
    lastPos = cPos;
    candidate = generateCtx();
    resolve();
    location = toCoordinates(candidate);
    //	distance = distance + Coordinates.calDist(location, lastLocation); // Experiments: calculate
    // distance
    displace =
        Math.sqrt(
            (location.x - lastLocation.x) * (location.x - lastLocation.x)
                + (location.y - lastLocation.y) * (location.y - lastLocation.y));
    moved = moved + toBoolean(displace);
    error =
        Math.sqrt(
            (actLoc.x - location.x) * (actLoc.x - location.x)
                + (actLoc.y - location.y) * (actLoc.y - location.y));
    lastLocation = location;
    counter = counter + 1;
    while (stay > 0) { // 2
      stay = stay - 1;
      actLoc = scenarios.getActLoc(sid, cPos);
      estLoc = scenarios.getEstLoc(sid, cPos);
      curEstX = estLoc.x;
      curEstY = estLoc.y;
      curEstX =
          curEstX + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE; // [- NOISE, + NOISE)
      curEstY =
          curEstY + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE; // [- NOISE, + NOISE)
      lastLoc = scenarios.getActLoc(sid, lastPos); // The actual location for lastPos
      dist = Coordinates.calDist(lastLoc, actLoc);
      t = STAY_TIME; // Experimentation:
      timestamp = timestamp + t;
      lastPos = cPos;
      candidate = generateCtx();
      resolve();
      location = toCoordinates(candidate);
      //	distance = distance + Coordinates.calDist(location, lastLocation); // Experiments:
      // calculate distance
      displace =
          Math.sqrt(
              (location.x - lastLocation.x) * (location.x - lastLocation.x)
                  + (location.y - lastLocation.y) * (location.y - lastLocation.y));
      moved = moved + toBoolean(displace);
      error =
          Math.sqrt(
              (actLoc.x - location.x) * (actLoc.x - location.x)
                  + (actLoc.y - location.y) * (actLoc.y - location.y));
      if (error <= ERR) {
        reliable = reliable + 1;
      }
      lastLocation = location;
      counter = counter + 1;
    }

    // 3
    cPos = rand.nextInt(CCRScenarios.POS_NUM);
    while (cPos == -1
        || cPos == bPos
        || Coordinates.calDist(scenarios.getActLoc(sid, bPos), scenarios.getActLoc(sid, cPos))
            < WALK_DIST) {
      cPos = rand.nextInt(CCRScenarios.POS_NUM);
    }
    stay = rand.nextInt(MAX_STAY) + 1;
    c = c + stay;
    bPos = cPos;
    stay = stay - 1; // 3
    actLoc = scenarios.getActLoc(sid, cPos);
    estLoc = scenarios.getEstLoc(sid, cPos);
    curEstX = estLoc.x;
    curEstY = estLoc.y;
    curEstX = curEstX + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE; // [- NOISE, + NOISE)
    curEstY = curEstY + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE; // [- NOISE, + NOISE)
    lastLoc = scenarios.getActLoc(sid, lastPos); // The actual location for lastPos
    dist = Coordinates.calDist(lastLoc, actLoc);
    t =
        (long)
            (dist / VELOCITY
                * 1000); // Experimentation: Estimated time required from lastLoc to actLoc
    timestamp = timestamp + t;
    lastPos = cPos;
    candidate = generateCtx();
    resolve();
    location = toCoordinates(candidate);
    //	distance = distance + Coordinates.calDist(location, lastLocation); // Experiments: calculate
    // distance
    displace =
        Math.sqrt(
            (location.x - lastLocation.x) * (location.x - lastLocation.x)
                + (location.y - lastLocation.y) * (location.y - lastLocation.y));
    moved = moved + toBoolean(displace);
    error =
        Math.sqrt(
            (actLoc.x - location.x) * (actLoc.x - location.x)
                + (actLoc.y - location.y) * (actLoc.y - location.y));
    lastLocation = location;
    counter = counter + 1;
    while (stay > 0) { // 3
      stay = stay - 1;
      actLoc = scenarios.getActLoc(sid, cPos);
      estLoc = scenarios.getEstLoc(sid, cPos);
      curEstX = estLoc.x;
      curEstY = estLoc.y;
      curEstX =
          curEstX + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE; // [- NOISE, + NOISE)
      curEstY =
          curEstY + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE; // [- NOISE, + NOISE)
      lastLoc = scenarios.getActLoc(sid, lastPos); // The actual location for lastPos
      dist = Coordinates.calDist(lastLoc, actLoc);
      t = STAY_TIME; // Experimentation:
      timestamp = timestamp + t;
      lastPos = cPos;
      candidate = generateCtx();
      resolve();
      location = toCoordinates(candidate);
      //	distance = distance + Coordinates.calDist(location, lastLocation); // Experiments:
      // calculate distance
      displace =
          Math.sqrt(
              (location.x - lastLocation.x) * (location.x - lastLocation.x)
                  + (location.y - lastLocation.y) * (location.y - lastLocation.y));
      moved = moved + toBoolean(displace);
      error =
          Math.sqrt(
              (actLoc.x - location.x) * (actLoc.x - location.x)
                  + (actLoc.y - location.y) * (actLoc.y - location.y));
      if (error <= ERR) {
        reliable = reliable + 1;
      }
      lastLocation = location;
      counter = counter + 1;
    }

    // 4
    cPos = rand.nextInt(CCRScenarios.POS_NUM);
    while (cPos == -1
        || cPos == bPos
        || Coordinates.calDist(scenarios.getActLoc(sid, bPos), scenarios.getActLoc(sid, cPos))
            < WALK_DIST) {
      cPos = rand.nextInt(CCRScenarios.POS_NUM);
    }
    stay = rand.nextInt(MAX_STAY) + 1;
    c = c + stay;
    bPos = cPos;
    stay = stay - 1; // 4
    actLoc = scenarios.getActLoc(sid, cPos);
    estLoc = scenarios.getEstLoc(sid, cPos);
    curEstX = estLoc.x;
    curEstY = estLoc.y;
    curEstX = curEstX + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE; // [- NOISE, + NOISE)
    curEstY = curEstY + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE; // [- NOISE, + NOISE)
    lastLoc = scenarios.getActLoc(sid, lastPos); // The actual location for lastPos
    dist = Coordinates.calDist(lastLoc, actLoc);
    t =
        (long)
            (dist / VELOCITY
                * 1000); // Experimentation: Estimated time required from lastLoc to actLoc
    timestamp = timestamp + t;
    lastPos = cPos;
    candidate = generateCtx();
    resolve();
    location = toCoordinates(candidate);
    //	distance = distance + Coordinates.calDist(location, lastLocation); // Experiments: calculate
    // distance
    displace =
        Math.sqrt(
            (location.x - lastLocation.x) * (location.x - lastLocation.x)
                + (location.y - lastLocation.y) * (location.y - lastLocation.y));
    moved = moved + toBoolean(displace);
    error =
        Math.sqrt(
            (actLoc.x - location.x) * (actLoc.x - location.x)
                + (actLoc.y - location.y) * (actLoc.y - location.y));
    lastLocation = location;
    counter = counter + 1;
    while (stay > 0) { // 4
      stay = stay - 1;
      actLoc = scenarios.getActLoc(sid, cPos);
      estLoc = scenarios.getEstLoc(sid, cPos);
      curEstX = estLoc.x;
      curEstY = estLoc.y;
      curEstX =
          curEstX + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE; // [- NOISE, + NOISE)
      curEstY =
          curEstY + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE; // [- NOISE, + NOISE)
      lastLoc = scenarios.getActLoc(sid, lastPos); // The actual location for lastPos
      dist = Coordinates.calDist(lastLoc, actLoc);
      t = STAY_TIME; // Experimentation:
      timestamp = timestamp + t;
      lastPos = cPos;
      candidate = generateCtx();
      resolve();
      location = toCoordinates(candidate);
      //	distance = distance + Coordinates.calDist(location, lastLocation); // Experiments:
      // calculate distance
      displace =
          Math.sqrt(
              (location.x - lastLocation.x) * (location.x - lastLocation.x)
                  + (location.y - lastLocation.y) * (location.y - lastLocation.y));
      moved = moved + toBoolean(displace);
      error =
          Math.sqrt(
              (actLoc.x - location.x) * (actLoc.x - location.x)
                  + (actLoc.y - location.y) * (actLoc.y - location.y));
      if (error <= ERR) {
        reliable = reliable + 1;
      }
      lastLocation = location;
      counter = counter + 1;
    }

    // 5
    cPos = rand.nextInt(CCRScenarios.POS_NUM);
    while (cPos == -1
        || cPos == bPos
        || Coordinates.calDist(scenarios.getActLoc(sid, bPos), scenarios.getActLoc(sid, cPos))
            < WALK_DIST) {
      cPos = rand.nextInt(CCRScenarios.POS_NUM);
    }
    stay = rand.nextInt(MAX_STAY) + 1;
    c = c + stay;
    bPos = cPos;
    stay = stay - 1; // 5
    actLoc = scenarios.getActLoc(sid, cPos);
    estLoc = scenarios.getEstLoc(sid, cPos);
    curEstX = estLoc.x;
    curEstY = estLoc.y;
    curEstX = curEstX + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE; // [- NOISE, + NOISE)
    curEstY = curEstY + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE; // [- NOISE, + NOISE)
    lastLoc = scenarios.getActLoc(sid, lastPos); // The actual location for lastPos
    dist = Coordinates.calDist(lastLoc, actLoc);
    t =
        (long)
            (dist / VELOCITY
                * 1000); // Experimentation: Estimated time required from lastLoc to actLoc
    timestamp = timestamp + t;
    lastPos = cPos;
    candidate = generateCtx();
    resolve();
    location = toCoordinates(candidate);
    //	distance = distance + Coordinates.calDist(location, lastLocation); // Experiments: calculate
    // distance
    displace =
        Math.sqrt(
            (location.x - lastLocation.x) * (location.x - lastLocation.x)
                + (location.y - lastLocation.y) * (location.y - lastLocation.y));
    moved = moved + toBoolean(displace);
    error =
        Math.sqrt(
            (actLoc.x - location.x) * (actLoc.x - location.x)
                + (actLoc.y - location.y) * (actLoc.y - location.y));
    lastLocation = location;
    counter = counter + 1;
    while (stay > 0) { // 5
      stay = stay - 1;
      actLoc = scenarios.getActLoc(sid, cPos);
      estLoc = scenarios.getEstLoc(sid, cPos);
      curEstX = estLoc.x;
      curEstY = estLoc.y;
      curEstX =
          curEstX + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE; // [- NOISE, + NOISE)
      curEstY =
          curEstY + ((double) 2 * rand.nextDouble() - (double) 1) * NOISE; // [- NOISE, + NOISE)
      lastLoc = scenarios.getActLoc(sid, lastPos); // The actual location for lastPos
      dist = Coordinates.calDist(lastLoc, actLoc);
      t = STAY_TIME; // Experimentation:
      timestamp = timestamp + t;
      lastPos = cPos;
      candidate = generateCtx();
      resolve();
      location = toCoordinates(candidate);
      //	distance = distance + Coordinates.calDist(location, lastLocation); // Experiments:
      // calculate distance
      displace =
          Math.sqrt(
              (location.x - lastLocation.x) * (location.x - lastLocation.x)
                  + (location.y - lastLocation.y) * (location.y - lastLocation.y));
      moved = moved + toBoolean(displace);
      error =
          Math.sqrt(
              (actLoc.x - location.x) * (actLoc.x - location.x)
                  + (actLoc.y - location.y) * (actLoc.y - location.y));
      if (error <= ERR) {
        reliable = reliable + 1;
      }
      lastLocation = location;
      counter = counter + 1;
    }

    //	Double result = new Double(distance);
    ApplicationResult result = new ApplicationResult(moved, reliable);
    // EXIT // NODE

    return result;
  }
Exemplo n.º 7
0
  /** @param args */
  public static void main(String[] args) {

    try {

      // force dot as decimal separator
      Locale.setDefault(new Locale("en", "US"));

      // Get current time
      long start = System.currentTimeMillis();

      RinexNavigation navigationIn =
          new RinexNavigation(RinexNavigation.IGN_NAVIGATION_HOURLY_ZIM2);

      FileInputStream fis = new FileInputStream(".\\data\\aphemeris.dat");
      // FileInputStream fis = new FileInputStream(".\\data\\assistnow.dat");
      DataInputStream dis = new DataInputStream(fis);
      String msg = null;
      try {
        msg = dis.readUTF();
        while (msg != null) {
          System.out.println("Msg:[" + msg + "]");
          if (msg.equalsIgnoreCase(Streamable.MESSAGE_OBSERVATIONS)) {
            Observations o = new Observations(dis, false);

          } else if (msg.equalsIgnoreCase(Streamable.MESSAGE_EPHEMERIS)) {
            EphGps eph1 = new EphGps(dis, false);
            System.out.println(
                "found sat" + eph1.getSatID() + " time:" + eph1.getRefTime().getGpsTime());

            EphGps eph2 =
                navigationIn.findEph(
                    eph1.getRefTime().getMsec(), eph1.getSatID(), eph1.getSatType());

            // Compare
            if (eph2 != null) {
              double ms = eph1.getRefTime().getGpsTime() - eph2.getRefTime().getGpsTime();
              System.out.println(" time dif:" + (ms / 1000) + "s " + (ms % 1000) + "ms");
              ;
              equalDouble("Af0", eph1.getAf0(), eph2.getAf0());
              equalDouble("Af1", eph1.getAf1(), eph2.getAf1());
              equalDouble("Af2", eph1.getAf2(), eph2.getAf2());
              equalDouble("Cic", eph1.getCic(), eph2.getCic());
              equalDouble("Cis", eph1.getCis(), eph2.getCis());
              equalDouble("Crc", eph1.getCrc(), eph2.getCrc());
              equalDouble("Crs", eph1.getCrs(), eph2.getCrs());
              equalDouble("Cuc", eph1.getCuc(), eph2.getCuc());
              equalDouble("Cus", eph1.getCus(), eph2.getCus());
              equalDouble("DeltaN", eph1.getDeltaN(), eph2.getDeltaN());
              equalDouble("E", eph1.getE(), eph2.getE());
              equalDouble("FitInt", eph1.getFitInt(), eph2.getFitInt());
              equalDouble("I0", eph1.getI0(), eph2.getI0());
              equalDouble("iDot", eph1.getiDot(), eph2.getiDot());
              equalDouble("M0", eph1.getM0(), eph2.getM0());
              equalDouble("Omega", eph1.getOmega(), eph2.getOmega());
              equalDouble("Omega0", eph1.getOmega0(), eph2.getOmega0());
              equalDouble("OmegaDot", eph1.getOmegaDot(), eph2.getOmegaDot());
              equalDouble("RootA", eph1.getRootA(), eph2.getRootA());
              equalDouble("Tgd", eph1.getTgd(), eph2.getTgd());
              equalDouble("Toc", eph1.getToc(), eph2.getToc());
              equalDouble("Toe", eph1.getToe(), eph2.getToe());
              equalDouble("Iodc", eph1.getIodc(), eph2.getIodc());
              equalDouble("Iode", eph1.getIode(), eph2.getIode());
              equalDouble("L2Code", eph1.getL2Code(), eph2.getL2Code());
              equalDouble("L2Flag", eph1.getL2Flag(), eph2.getL2Flag());
              equalDouble("SvAccur", eph1.getSvAccur(), eph2.getSvAccur());
              equalDouble("SvHealth", eph1.getSvHealth(), eph2.getSvHealth());

            } else {
              System.out.println(
                  "EPH 2 not found for " + eph1.getSatID() + " at " + eph1.getRefTime());
            }

          } else if (msg.equalsIgnoreCase(Streamable.MESSAGE_OBSERVATIONS_SET)) {
            ObservationSet eps = new ObservationSet(dis, false);
            // nothing to do with ?
          } else if (msg.equalsIgnoreCase(Streamable.MESSAGE_IONO)) {
            IonoGps iono = new IonoGps(dis, false);
            // addIonospheric(iono);
          } else if (msg.equalsIgnoreCase(Streamable.MESSAGE_COORDINATES)) {
            Coordinates c = Coordinates.readFromStream(dis, false);
            // setDefinedPosition(c);

          } else {
            System.out.println("Unknow Msg:[" + msg + "]");
          }

          msg = dis.readUTF();
        }
      } catch (EOFException eof) {
        // ok
      }
      fis.close();

      try {
        navigationIn.release(true, 10000);
      } catch (InterruptedException ie) {
        ie.printStackTrace();
      }

      // Get and display elapsed time
      int elapsedTimeSec = (int) Math.floor((System.currentTimeMillis() - start) / 1000);
      int elapsedTimeMillisec =
          (int) ((System.currentTimeMillis() - start) - elapsedTimeSec * 1000);
      System.out.println(
          "\nElapsed time (read + proc + display + write): "
              + elapsedTimeSec
              + " seconds "
              + elapsedTimeMillisec
              + " milliseconds.");
    } catch (Exception e) {
      e.printStackTrace();
    }
  }