Пример #1
0
  /*
   * (non-Javadoc)
   * @see org.oscim.map.reader.IMapDatabase#executeQuery(org.oscim.core.Tile,
   * org.oscim.map.reader.MapDatabaseCallback)
   */
  @Override
  public QueryResult executeQuery(JobTile tile, IMapDatabaseCallback mapDatabaseCallback) {
    if (sMapFileHeader == null) return QueryResult.FAILED;

    if (mIntBuffer == null) mIntBuffer = new int[MAXIMUM_WAY_NODES_SEQUENCE_LENGTH * 2];

    mWayNodePosition = 0;

    try {
      // prepareExecution();
      QueryParameters queryParameters = new QueryParameters();
      queryParameters.queryZoomLevel = sMapFileHeader.getQueryZoomLevel(tile.zoomLevel);
      // get and check the sub-file for the query zoom level
      SubFileParameter subFileParameter =
          sMapFileHeader.getSubFileParameter(queryParameters.queryZoomLevel);
      if (subFileParameter == null) {
        LOG.warning("no sub-file for zoom level: " + queryParameters.queryZoomLevel);
        return QueryResult.FAILED;
      }

      QueryCalculations.calculateBaseTiles(queryParameters, tile, subFileParameter);
      QueryCalculations.calculateBlocks(queryParameters, subFileParameter);
      processBlocks(mapDatabaseCallback, queryParameters, subFileParameter);
    } catch (IOException e) {
      LOG.log(Level.SEVERE, null, e);
      return QueryResult.FAILED;
    }
    return QueryResult.SUCCESS;
  }
Пример #2
0
  @Override
  public void query(MapTile tile, ITileDataSink sink) {

    if (mTileSource.fileHeader == null) {
      sink.completed(FAILED);
      return;
    }

    if (mIntBuffer == null) mIntBuffer = new int[MAXIMUM_WAY_NODES_SEQUENCE_LENGTH * 2];

    try {
      mTileProjection.setTile(tile);
      // mTile = tile;

      /* size of tile in map coordinates; */
      double size = 1.0 / (1 << tile.zoomLevel);

      /* simplification tolerance */
      int pixel = (tile.zoomLevel > 11) ? 1 : 2;

      int simplify = Tile.SIZE / pixel;

      /* translate screen pixel for tile to latitude and longitude
       * tolerance for point reduction before projection. */
      minDeltaLat =
          (int)
                  (Math.abs(
                          MercatorProjection.toLatitude(tile.y + size)
                              - MercatorProjection.toLatitude(tile.y))
                      * 1e6)
              / simplify;
      minDeltaLon =
          (int)
                  (Math.abs(
                          MercatorProjection.toLongitude(tile.x + size)
                              - MercatorProjection.toLongitude(tile.x))
                      * 1e6)
              / simplify;

      QueryParameters queryParameters = new QueryParameters();
      queryParameters.queryZoomLevel = mTileSource.fileHeader.getQueryZoomLevel(tile.zoomLevel);

      /* get and check the sub-file for the query zoom level */
      SubFileParameter subFileParameter =
          mTileSource.fileHeader.getSubFileParameter(queryParameters.queryZoomLevel);

      if (subFileParameter == null) {
        log.warn("no sub-file for zoom level: " + queryParameters.queryZoomLevel);

        sink.completed(FAILED);
        return;
      }

      QueryCalculations.calculateBaseTiles(queryParameters, tile, subFileParameter);
      QueryCalculations.calculateBlocks(queryParameters, subFileParameter);
      processBlocks(sink, queryParameters, subFileParameter);
    } catch (IOException e) {
      log.error(e.getMessage());
      sink.completed(FAILED);
      return;
    }

    sink.completed(SUCCESS);
  }