예제 #1
0
  /**
   * Converts TMS tile coordinates to QuadTree
   *
   * @param aTile The tile coordinates to convert
   * @return The QuadTree as String.
   */
  protected String quadTree(final MapTile aTile) {
    final StringBuilder quadKey = new StringBuilder();
    for (int i = aTile.getZoomLevel(); i > 0; i--) {
      int digit = 0;
      final int mask = 1 << (i - 1);
      if ((aTile.getX() & mask) != 0) digit += 1;
      if ((aTile.getY() & mask) != 0) digit += 2;
      quadKey.append("" + digit);
    }

    return quadKey.toString();
  }
예제 #2
0
  public byte[] getImage(final ITileSource pTileSource, final MapTile pTile) {

    try {
      byte[] bits = null;
      final String[] tile = {COLUMN_TILE};
      final long x = (long) pTile.getX();
      final long y = (long) pTile.getY();
      final long z = (long) pTile.getZoomLevel();
      final long index = ((z << z) + x << z) + y;
      final Cursor cur =
          mDatabase.query(
              TABLE,
              tile,
              COLUMN_KEY
                  + " = "
                  + index
                  + " and "
                  + COLUMN_PROVIDER
                  + " = '"
                  + pTileSource.name()
                  + "'",
              null,
              null,
              null,
              null);

      if (cur.getCount() != 0) {
        cur.moveToFirst();
        bits = (cur.getBlob(0));
      }
      cur.close();
      if (bits != null) {
        return bits;
      }
    } catch (final Throwable e) {
      Log.w(IMapView.LOGTAG, "Error getting db stream: " + pTile, e);
    }

    return null;
  }