TilesFetcher constructor

TilesFetcher(
  1. TileEntry tileEntry, {
  2. int? zoomLevel,
})

Implementation

TilesFetcher(this.tileEntry, {this.zoomLevel}) {
  tileMatricies = tileEntry.getTileMatricies();
  if (tileMatricies.isEmpty) {
    throw StateError("No tile matrices available.");
  }
  TileMatrix? tileMatrix = tileMatricies.last;
  if (zoomLevel != null) {
    tileMatrix = tileMatricies
        .firstWhere((tm) => tm.getZoomLevel() == zoomLevel, orElse: null);
  }

  zoomLevel = tileMatrix.zoomLevel;

  matrixWidth = tileMatrix.getMatrixWidth();
  matrixHeight = tileMatrix.getMatrixHeight();

  var tileMatrixSetBounds = tileEntry.getTileMatrixSetBounds();

  deltaX = tileMatrixSetBounds.getWidth() / matrixWidth;
  deltaY = tileMatrixSetBounds.getHeight() / matrixHeight;

  tileSetMinX = tileMatrixSetBounds.getMinX();
  tileSetMaxY = tileMatrixSetBounds.getMaxY();

  tableName = tileEntry.getTableName();

  xPixels = tileMatrix.getTileWidth();
  yPixels = tileMatrix.getTileHeight();
}