Ejemplo n.º 1
0
  /**
   * Default constructor.
   *
   * @param projection projection for the layer.
   * @param minZoom minimum zoom supported by the layer.
   * @param maxZoom maximum zoom supported by the layer.
   * @param id unique layer id. Id for the layer must be depend ONLY on the layer source, otherwise
   *     tile caching will not work properly.
   * @param path path to the local Sqlite database file. SQLiteException will be thrown if the
   *     database does not exist or can not be opened in read-only mode.
   * @param ctx Android application context.
   * @throws IOException exception if file not exists
   */
  public MBTilesMapLayer(
      Projection projection, int minZoom, int maxZoom, int id, String path, Context ctx)
      throws IOException {
    super(projection, minZoom, maxZoom, id, path); // TODO: use constructor without path

    if (!(new File(path)).exists()) {
      throw new IOException("not existing file: " + path);
    }

    db = new MBTilesDbHelper(ctx, path);
    db.open();

    hasUtfGrid = db.getMetadata().containsKey("template");
  }