checkMetadata method

void checkMetadata()

** **

Implementation

// * Get the bounds of a zoomlevel in tile indexes.
// *
// * <p>This comes handy when one wants to navigate all tiles of a zoomlevel.
// *
// * @param zoomlevel the zoom level.
// * @return the tile indexes as [minTx, maxTx, minTy, maxTy].
// * @throws Exception
// */
//public int[] getBoundsInTileIndex( int zoomlevel ) throws Exception {
//String sql = "select min(tile_column), max(tile_column), min(tile_row), max(tile_row) from tiles where zoom_level="
//    + zoomlevel;
//return database.execOnConnection(connection -> {
//try (IHMStatement statement = connection.createStatement(); IHMResultSet resultSet = statement.executeQuery(sql);) {
//if (resultSet.next()) {
//int minTx = resultSet.getInt(1);
//int maxTx = resultSet.getInt(2);
//int minTy = resultSet.getInt(3);
//int maxTy = resultSet.getInt(4);
//return new int[]{minTx, maxTx, minTy, maxTy};
//}
//}
//return null;
//});
//}
//
//public List<Integer> getAvailableZoomLevels() throws Exception {
//String sql = "select distinct zoom_level from tiles order by zoom_level";
//return database.execOnConnection(connection -> {
//List<Integer> zoomLevels = new ArrayList<>();
//try (IHMStatement statement = connection.createStatement(); IHMResultSet resultSet = statement.executeQuery(sql);) {
//while( resultSet.next() ) {
//int z = resultSet.getInt(1);
//zoomLevels.add(z);
//}
//}
//return zoomLevels;
//});
//}
//
///**
// * Get the image format of the db.
// *
// * @return the image format (jpg, png).
// * @throws Exception
// */
//public String getImageFormat() throws Exception {
//checkMetadata();
//return metadataMap.get("format");
//}
//
//public String getName() throws Exception {
//checkMetadata();
//return metadataMap.get("name");
//}
//public String getDescription() throws Exception {
//checkMetadata();
//return metadataMap.get("description");
//}
//
//public String getAttribution() throws Exception {
//checkMetadata();
//return metadataMap.get("attribution");
//}
//
//public String getVersion() throws Exception {
//checkMetadata();
//return metadataMap.get("version");
//}
//
//public int getMinZoom() throws Exception {
//checkMetadata();
//String minZoomStr = metadataMap.get("minzoom");
//if (minZoomStr != null) {
//return Integer.parseInt(minZoomStr);
//}
//return -1;
//}
//
//public int getMaxZoom() throws Exception {
//checkMetadata();
//String maxZoomStr = metadataMap.get("maxzoom");
//if (maxZoomStr != null) {
//return Integer.parseInt(maxZoomStr);
//}
//return -1;
//}
//
void checkMetadata() {
  if (metadataMap == null) {
    metadataMap = {};

    var res = database.select(SELECT_METADATA);
    res.forEach((QueryResultRow row) {
      metadataMap![row.get(COL_METADATA_NAME).toLowerCase()] =
          row.get(COL_METADATA_VALUE);
    });
  }
}