public int[] getContainedPositions(BoundingBox boundingBox) {
   List<Integer> result = new ArrayList<>();
   List<P> positions = getPositions();
   for (int i = 0; i < positions.size(); i++) {
     P position = positions.get(i);
     if (position.hasCoordinates() && boundingBox.contains(position)) result.add(i);
   }
   return toArray(result);
 }
  @SuppressWarnings("UnusedDeclaration")
  public ViaMichelinRoute asViaMichelinFormat() {
    if (getFormat() instanceof ViaMichelinFormat) return (ViaMichelinRoute) this;

    List<Wgs84Position> wgs84Positions = new ArrayList<>();
    for (P position : getPositions()) {
      wgs84Positions.add(position.asWgs84Position());
    }
    return new ViaMichelinRoute(getName(), wgs84Positions);
  }
  @SuppressWarnings("UnusedDeclaration")
  public TourRoute asTourFormat() {
    if (getFormat() instanceof TourFormat) return (TourRoute) this;

    List<TourPosition> tourPositions = new ArrayList<>();
    for (P position : getPositions()) {
      tourPositions.add(position.asTourPosition());
    }
    return new TourRoute(getName(), tourPositions);
  }
  @SuppressWarnings("UnusedDeclaration")
  public OvlRoute asOvlFormat() {
    if (getFormat() instanceof OvlFormat) return (OvlRoute) this;

    List<Wgs84Position> ovlPositions = new ArrayList<>();
    for (P position : getPositions()) {
      ovlPositions.add(position.asOvlPosition());
    }
    return new OvlRoute(getCharacteristics(), getName(), ovlPositions);
  }
  @SuppressWarnings("UnusedDeclaration")
  public MagicMapsPthRoute asMagicMapsPthFormat() {
    if (getFormat() instanceof MagicMapsPthFormat) return (MagicMapsPthRoute) this;

    List<GkPosition> gkPositions = new ArrayList<>();
    for (P position : getPositions()) {
      gkPositions.add(position.asGkPosition());
    }
    return new MagicMapsPthRoute(getCharacteristics(), gkPositions);
  }
  @SuppressWarnings("UnusedDeclaration")
  public MagicMapsIktRoute asMagicMapsIktFormat() {
    if (getFormat() instanceof MagicMapsIktFormat) return (MagicMapsIktRoute) this;

    List<Wgs84Position> wgs84Positions = new ArrayList<>();
    for (P position : getPositions()) {
      wgs84Positions.add(position.asWgs84Position());
    }
    return new MagicMapsIktRoute(getName(), getDescription(), wgs84Positions);
  }
  @SuppressWarnings("UnusedDeclaration")
  public GarminFlightPlanRoute asGarminFlightPlanFormat() {
    if (getFormat() instanceof GarminFlightPlanFormat) return (GarminFlightPlanRoute) this;

    List<GarminFlightPlanPosition> flightPlanPositions = new ArrayList<>();
    for (P position : getPositions()) {
      flightPlanPositions.add(position.asGarminFlightPlanPosition());
    }
    return new GarminFlightPlanRoute(getName(), getDescription(), flightPlanPositions);
  }
  @SuppressWarnings("UnusedDeclaration")
  public NokiaLandmarkExchangeRoute asNokiaLandmarkExchangeFormat() {
    if (getFormat() instanceof NokiaLandmarkExchangeFormat)
      return (NokiaLandmarkExchangeRoute) this;

    List<Wgs84Position> wgs84Positions = new ArrayList<>();
    for (P position : getPositions()) {
      wgs84Positions.add(position.asWgs84Position());
    }
    return new NokiaLandmarkExchangeRoute(getName(), getDescription(), wgs84Positions);
  }
 public int[] getPositionsWithinDistanceToPredecessor(double distance) {
   List<Integer> result = new ArrayList<>();
   List<P> positions = getPositions();
   if (positions.size() <= 2) return new int[0];
   P previous = positions.get(0);
   for (int i = 1; i < positions.size() - 1; i++) {
     P next = positions.get(i);
     if (!next.hasCoordinates() || next.calculateDistance(previous) <= distance) result.add(i);
     else previous = next;
   }
   return toArray(result);
 }
Exemple #10
0
  public void revert() {
    List<P> positions = getPositions();
    List<P> reverted = new ArrayList<>();
    for (P position : positions) {
      reverted.add(0, position);
    }
    order(reverted);

    String routeName = getName();
    if (!routeName.endsWith(REVERSE_ROUTE_NAME_POSTFIX))
      routeName = routeName + REVERSE_ROUTE_NAME_POSTFIX;
    else
      routeName = routeName.substring(0, routeName.length() - REVERSE_ROUTE_NAME_POSTFIX.length());
    setName(routeName);
  }