コード例 #1
0
ファイル: GCMap.java プロジェクト: samueltardieu/cgeo
  /**
   * Searches the view port on the live map with Strategy.AUTO
   *
   * @param viewport Area to search
   * @param tokens Live map tokens
   */
  @NonNull
  public static SearchResult searchByViewport(final Viewport viewport, final MapTokens tokens) {
    final int speed =
        (int) Sensors.getInstance().currentGeo().getSpeed() * 60 * 60 / 1000; // in km/h
    LivemapStrategy strategy = Settings.getLiveMapStrategy();
    if (strategy == LivemapStrategy.AUTO) {
      strategy = speed >= 30 ? LivemapStrategy.FAST : LivemapStrategy.DETAILED;
    }

    final SearchResult result = searchByViewport(viewport, tokens, strategy);

    if (Settings.isDebug()) {
      final StringBuilder text =
          new StringBuilder(Formatter.SEPARATOR)
              .append(strategy.getL10n())
              .append(Formatter.SEPARATOR)
              .append(Units.getSpeed(speed));
      result.setUrl(result.getUrl() + text);
    }

    return result;
  }