Get a map tile from the GeoPackage tile

@param geoPackageTile GeoPackage tile
@return tile
336591
public static Tile getTile(GeoPackageTile geoPackageTile) {
        Tile tile = null;
        if (geoPackageTile != null) {
            tile = new Tile(geoPackageTile.getWidth(), geoPackageTile.getHeight(), geoPackageTile.getData());
        }
        return tile;
    }
421223
public TableIndex getTableIndex() {

		TableIndex tableIndex = null;
		try {
			if (tableIndexDao.isTableExists()) {
				tableIndex = tableIndexDao.queryForId(tableName);
			}
		} catch (SQLException e) {
			throw new GeoPackageException(
					"Failed to query for Table Index for GeoPackage: "
							+ geoPackage.getName() + ", Table Name: "
							+ tableName + ", Column Name: " + columnName, e);
		}
		return tableIndex;
	}
110401
public static void generate() {

		// Open the GeoPackage with the feature table
		featureGeoPackage = GeoPackageManager.open(featureGeoPackageFile);

		// Check if the tile table is to be created in the same GeoPackage file
		if (featureGeoPackageFile.equals(tileGeoPackageFile)) {
			tileGeoPackage = featureGeoPackage;
		} else {

			// If the GeoPackage does not exist create it
			if (!tileGeoPackageFile.exists()) {
				if (!GeoPackageManager.create(tileGeoPackageFile)) {
					throw new GeoPackageException(
							"Failed to create GeoPackage file: "
									+ tileGeoPackageFile.getAbsolutePath());
				}
			}

			// Open the GeoPackage
			tileGeoPackage = GeoPackageManager.open(tileGeoPackageFile);
		}

		FeatureDao featureDao = featureGeoPackage.getFeatureDao(featureTable);

		// Index the feature table if needed
		FeatureTableIndex featureIndex = new FeatureTableIndex(
				featureGeoPackage, featureDao);
		if (!featureIndex.isIndexed()) {
			int numFeatures = featureDao.count();
			LOGGER.log(Level.INFO,
					"Indexing GeoPackage '" + featureGeoPackage.getName()
							+ "' feature table '" + featureTable + "' with "
							+ numFeatures + " features");
			Progress indexProgress = new Progress("Feature Indexer",
					LOG_INDEX_FREQUENCY, LOG_INDEX_TIME_FREQUENCY);
			indexProgress.setMax(numFeatures);
			featureIndex.setProgress(indexProgress);
			int indexed = featureIndex.index();
			LOGGER.log(Level.INFO,
					"Indexed GeoPackage '" + featureGeoPackage.getName()
							+ "' feature table '" + featureTable + "', "
							+ indexed + " features");
		}
		featureIndex.close();

		// Create the feature tiles
		FeatureTiles featureTiles = new DefaultFeatureTiles(featureGeoPackage,
				featureDao);
		if (ignoreGeoPackageStyles) {
			featureTiles.ignoreFeatureTableStyles();
		}
		if (maxFeaturesPerTile != null) {
			featureTiles.setMaxFeaturesPerTile(maxFeaturesPerTile);
			featureTiles.setMaxFeaturesTileDraw(new NumberFeaturesTile());
		}

		// Set the tile styles
		if (tileWidth != null) {
			featureTiles.setTileWidth(tileWidth);
		}
		if (tileHeight != null) {
			featureTiles.setTileHeight(tileHeight);
		}
		if (tileScale != null) {
			featureTiles.setScale(tileScale);
		}
		if (pointRadius != null) {
			featureTiles.setPointRadius(pointRadius);
		}
		if (pointColor != null) {
			featureTiles.setPointColor(pointColor);
		}
		if (icon != null) {
			featureTiles.setPointIcon(icon);
		}
		if (lineStrokeWidth != null) {
			featureTiles.setLineStrokeWidth(lineStrokeWidth);
		}
		if (lineColor != null) {
			featureTiles.setLineColor(lineColor);
		}
		if (polygonStrokeWidth != null) {
			featureTiles.setPolygonStrokeWidth(polygonStrokeWidth);
		}
		if (polygonColor != null) {
			featureTiles.setPolygonColor(polygonColor);
		}
		if (fillPolygon != null) {
			featureTiles.setFillPolygon(fillPolygon);
		}
		if (polygonFillColor != null) {
			featureTiles.setPolygonFillColor(polygonFillColor);
		}
		featureTiles.setSimplifyGeometries(simplifyGeometries);

		// Calculate the tile overlap with the new settings
		featureTiles.calculateDrawOverlap();

		// Default the EPSG
		if (epsg == null) {
			epsg = new Long(ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM);
		}

		BoundingBox webMercatorBoundingBox = null;
		Projection webMercatorProjection = ProjectionFactory
				.getProjection(ProjectionConstants.EPSG_WEB_MERCATOR);

		// Set the projection and default bounding box as needed
		Projection projection = null;
		if (boundingBox != null) {

			projection = ProjectionFactory.getProjection(epsg);

			// Bound WGS84 tiles to Web Mercator limits
			if (projection.isUnit(Units.DEGREES)) {
				boundingBox = TileBoundingBoxUtils
						.boundDegreesBoundingBoxWithWebMercatorLimits(boundingBox);
			}

			// Transform to a Web Mercator bounding box
			ProjectionTransform transform = projection
					.getTransformation(webMercatorProjection);
			webMercatorBoundingBox = boundingBox.transform(transform);

		} else {
			projection = ProjectionFactory
					.getProjection(ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM);
		}

		// Create the tile generator
		FeatureTileGenerator tileGenerator = new FeatureTileGenerator(
				tileGeoPackage, tileTable, featureTiles, featureGeoPackage,
				minZoom, maxZoom, webMercatorBoundingBox, webMercatorProjection);

		if (compressFormat != null) {
			tileGenerator.setCompressFormat(compressFormat);
			if (compressQuality != null) {
				tileGenerator.setCompressQuality(compressQuality);
			}
		}

		if (googleTiles) {
			tileGenerator.setGoogleTiles(true);
		}

		int count = tileGenerator.getTileCount();

		LOGGER.log(
				Level.INFO,
				"Feature GeoPackage: "
						+ featureGeoPackage.getName()
						+ ", Feature Table: "
						+ featureTable
						+ ", Tile GeoPackage: "
						+ tileGeoPackage.getName()
						+ ", Tile Table: "
						+ tileTable
						+ ", Min Zoom: "
						+ minZoom
						+ ", Max Zoom: "
						+ maxZoom
						+ (maxFeaturesPerTile != null ? ", Max Features Per Tile: "
								+ maxFeaturesPerTile
								: "")
						+ (compressFormat != null ? ", Compress Format: "
								+ compressFormat : "")
						+ (compressQuality != null ? ", Compress Quality: "
								+ compressQuality : "")
						+ (googleTiles ? ", Google Tiles" : "")
						+ (boundingBox != null ? ", Min Lon: "
								+ boundingBox.getMinLongitude() + ", Min Lat: "
								+ boundingBox.getMinLatitude() + ", Max Lon: "
								+ boundingBox.getMaxLongitude() + ", Max Lat: "
								+ boundingBox.getMaxLatitude() : "")
						+ (epsg != null ? ", EPSG: " + epsg : "")
						+ ", Expected Tile Count: " + count);

		StringBuilder tileStyle = new StringBuilder();
		if (tileWidth != null) {
			tileStyle.append(", Width: ").append(tileWidth);
		}
		if (tileHeight != null) {
			tileStyle.append(", Height: ").append(tileHeight);
		}
		if (pointRadius != null) {
			tileStyle.append(", Point Radius: ").append(pointRadius);
		}
		if (pointColor != null) {
			tileStyle.append(", Point Color: ").append(colorString(pointColor));
		}
		if (icon != null) {
			tileStyle.append(", Point Icon (height=").append(icon.getHeight())
					.append(", width=").append(icon.getWidth())
					.append(", xoffset=").append(icon.getXOffset())
					.append(", yoffset=").append(icon.getYOffset()).append(")");
		}
		if (lineStrokeWidth != null) {
			tileStyle.append(", Line Stroke Width: ").append(lineStrokeWidth);
		}
		if (lineColor != null) {
			tileStyle.append(", Line Color: ").append(colorString(lineColor));
		}
		if (polygonStrokeWidth != null) {
			tileStyle.append(", Polygon Stroke Width: ").append(
					polygonStrokeWidth);
		}
		if (polygonColor != null) {
			tileStyle.append(", Polygon Color: ").append(
					colorString(polygonColor));
		}
		if (fillPolygon != null && fillPolygon) {
			tileStyle.append(", Fill Polygon");
		}
		if (polygonFillColor != null) {
			tileStyle.append(", Polygon Fill Color: ").append(
					colorString(polygonFillColor));
		}
		if (simplifyGeometries) {
			tileStyle.append(", Simplify Geometries");
		}
		if (tileStyle.length() == 0) {
			tileStyle.append(", Default Settings");
		}
		LOGGER.log(Level.INFO, "Tile Attributes" + tileStyle);

		tileGenerator.setProgress(progress);

		LOGGER.log(Level.INFO, "Generating Tiles...");

		try {
			tileGenerator.generateTiles();
		} catch (IOException | SQLException e) {
			throw new GeoPackageException("Exception while generating tiles", e);
		}

		finish();
	}
632680
public UniformTileSet loadTileSet (String imgPath, int width, int height)
    {
        return loadCachedTileSet("", imgPath, width, height);
    }
163334
public GeoPackageTile getTile(BoundingBox requestBoundingBox) {

		GeoPackageTile tile = null;

		// Transform to the projection of the tiles
		ProjectionTransform transformRequestToTiles = requestProjection
				.getTransformation(tilesProjection);
		BoundingBox tilesBoundingBox = requestBoundingBox
				.transform(transformRequestToTiles);

		List<TileMatrix> tileMatrices = getTileMatrices(tilesBoundingBox);

		for (int i = 0; tile == null && i < tileMatrices.size(); i++) {

			TileMatrix tileMatrix = tileMatrices.get(i);

			TileResultSet tileResults = retrieveTileResults(tilesBoundingBox,
					tileMatrix);
			if (tileResults != null) {

				try {

					if (tileResults.getCount() > 0) {

						BoundingBox requestProjectedBoundingBox = requestBoundingBox
								.transform(transformRequestToTiles);

						// Determine the requested tile dimensions, or use the
						// dimensions of a single tile matrix tile
						int requestedTileWidth = width != null ? width
								: (int) tileMatrix.getTileWidth();
						int requestedTileHeight = height != null ? height
								: (int) tileMatrix.getTileHeight();

						// Determine the size of the tile to initially draw
						int tileWidth = requestedTileWidth;
						int tileHeight = requestedTileHeight;
						if (!sameProjection) {
							tileWidth = (int) Math
									.round((requestProjectedBoundingBox
											.getMaxLongitude() - requestProjectedBoundingBox
											.getMinLongitude())
											/ tileMatrix.getPixelXSize());
							tileHeight = (int) Math
									.round((requestProjectedBoundingBox
											.getMaxLatitude() - requestProjectedBoundingBox
											.getMinLatitude())
											/ tileMatrix.getPixelYSize());
						}

						// Draw the resulting bitmap with the matching tiles
						GeoPackageTile geoPackageTile = drawTile(tileMatrix,
								tileResults, requestProjectedBoundingBox,
								tileWidth, tileHeight);

						// Create the tile
						if (geoPackageTile != null) {

							// Project the tile if needed
							if (!sameProjection
									&& geoPackageTile.getImage() != null) {
								BufferedImage reprojectTile = reprojectTile(
										geoPackageTile.getImage(),
										requestedTileWidth,
										requestedTileHeight,
										requestBoundingBox,
										transformRequestToTiles,
										tilesBoundingBox);
								geoPackageTile = new GeoPackageTile(
										requestedTileWidth,
										requestedTileHeight, reprojectTile);
							}

							tile = geoPackageTile;
						}

					}
				} finally {
					tileResults.close();
				}
			}
		}

		return tile;
	}
181620
@Override
    public MapReadResult readLabels(Tile tile) {
        return readMapData(tile, tile, Selector.LABELS);
    }
1080457
function(bounds, position) {
        var tile = new this.tileClass(
            this, position, bounds, null, this.tileSize, this.tileOptions
        );
        this.events.triggerEvent("addtile", {tile: tile});
        return tile;
    }
1364648
def from_geo(geo, level):
    
    pixel = TileSystem.geo_to_pixel(geo, level)
    tile = TileSystem.pixel_to_tile(pixel)
    key = TileSystem.tile_to_quadkey(tile, level)
    return QuadKey(key)
979221
protected BufferedImage getTileImage (BufferedImage img,
        FringeConfiguration.FringeTileSetRecord tsr, int baseset, int index, int hashValue,
        Map<Long, BufferedImage> masks)
        throws NoSuchTileSetException
    {
        int fringeset = tsr.fringe_tsid;
        TileSet fset = _tmgr.getTileSet(fringeset);
        if (!tsr.mask) {
            // oh good, this is easy
            Tile stamp = fset.getTile(index);
            return stampTileImage(stamp, img, stamp.getWidth(), stamp.getHeight());
        }

        // otherwise, it's a mask..
        Long maskkey = Long.valueOf((((long)baseset) << 32) + (fringeset << 16) + index);
        BufferedImage mask = masks.get(maskkey);
        if (mask == null) {
            BufferedImage fsrc = _tmgr.getTileSet(fringeset).getRawTileImage(index);
            BufferedImage bsrc = _tmgr.getTileSet(baseset).getRawTileImage(0);
            mask = ImageUtil.composeMaskedImage(_imgr, fsrc, bsrc);
            masks.put(maskkey, mask);
        }

        return stampTileImage(mask, img, mask.getWidth(null), mask.getHeight(null));
    }
804088
public RendererJob otherTile(Tile tile) {
        return new RendererJob(tile, this.rendererJob.mapDataStore, this.rendererJob.renderThemeFuture, this.rendererJob.displayModel,
                this.rendererJob.textScale, this.rendererJob.hasAlpha, this.rendererJob.labelsOnly);
    }
172906
public Tile getTile (int fqTileId)
        throws NoSuchTileSetException
    {
        return getTile(TileUtil.getTileSetId(fqTileId), TileUtil.getTileIndex(fqTileId), null);
    }
721729
public Tile getBelow() {
        int y = tileY + 1;
        if (y > getMaxTileNumber(this.zoomLevel)) {
            y = 0;
        }
        return new Tile(this.tileX, y, this.zoomLevel, this.tileSize);
    }
631707
public FeatureTileLink getLink(String featureTable, String tileTable) {
		FeatureTileLink link = null;

		if (featureTileLinksActive()) {
			FeatureTileLinkKey id = new FeatureTileLinkKey(featureTable,
					tileTable);
			try {
				link = featureTileLinkDao.queryForId(id);
			} catch (SQLException e) {
				throw new GeoPackageException(
						"Failed to get feature tile link for GeoPackage: "
								+ geoPackage.getName() + ", Feature Table: "
								+ featureTable + ", Tile Table: " + tileTable,
						e);
			}
		}

		return link;
	}
831864
public static BoundedOverlay getBoundedOverlay(TileDao tileDao, float density) {

        BoundedOverlay overlay = null;

        if (tileDao.isGoogleTiles()) {
            overlay = new GoogleAPIGeoPackageOverlay(tileDao);
        } else {
            overlay = new GeoPackageOverlay(tileDao, density);
        }

        return overlay;
    }
409074
public List<GriddedTile> query(String tableName) {
		List<GriddedTile> results = null;
		try {
			results = queryForEq(GriddedTile.COLUMN_TABLE_NAME, tableName);
		} catch (SQLException e) {
			throw new GeoPackageException(
					"Failed to query for Gridded Tile objects by Table Name: "
							+ tableName, e);
		}
		return results;
	}
103794
public List<T> getGeoPackages() {
		List<T> geoPackages = new ArrayList<>();
		for (PropertiesCoreExtension<T, ?, ?, ?> properties : propertiesMap
				.values()) {
			geoPackages.add(properties.getGeoPackage());
		}
		return geoPackages;
	}
1126250
public static void generate() {

		// If the GeoPackage does not exist create it
		if (!geoPackageFile.exists()) {
			if (!GeoPackageManager.create(geoPackageFile)) {
				throw new GeoPackageException(
						"Failed to create GeoPackage file: "
								+ geoPackageFile.getAbsolutePath());
			}
		}

		// Open the GeoPackage
		geoPackage = GeoPackageManager.open(geoPackageFile);

		// Default the EPSG
		if (epsg == null) {
			epsg = new Long(ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM);
		}

		// Set the projection and default bounding box as needed
		Projection bboxProjection = null;
		if (boundingBox != null) {
			bboxProjection = ProjectionFactory.getProjection(epsg);
		} else {
			boundingBox = new BoundingBox();
			bboxProjection = ProjectionFactory
					.getProjection(ProjectionConstants.EPSG_WORLD_GEODETIC_SYSTEM);
		}

		// Bound degree tiles to Web Mercator limits
		if (bboxProjection.isUnit(Units.DEGREES)) {
			boundingBox = TileBoundingBoxUtils
					.boundDegreesBoundingBoxWithWebMercatorLimits(boundingBox);
		}

		// Transform to the URL projection bounding box
		Projection urlProjection = ProjectionFactory.getProjection(urlEpsg);
		ProjectionTransform transform = bboxProjection
				.getTransformation(urlProjection);
		BoundingBox urlBoundingBox = boundingBox.transform(transform);

		UrlTileGenerator tileGenerator = new UrlTileGenerator(geoPackage,
				tileTable, url, minZoom, maxZoom, urlBoundingBox, urlProjection);

		if (compressFormat != null) {
			tileGenerator.setCompressFormat(compressFormat);
			if (compressQuality != null) {
				tileGenerator.setCompressQuality(compressQuality);
			}
		}

		if (googleTiles) {
			tileGenerator.setGoogleTiles(true);
		}

		if (tms) {
			tileGenerator.setTileFormat(TileFormatType.TMS);
		}

		int count = tileGenerator.getTileCount();

		LOGGER.log(
				Level.INFO,
				"GeoPackage: "
						+ geoPackage.getName()
						+ ", Tile Table: "
						+ tileTable
						+ ", URL: "
						+ url
						+ ", Min Zoom: "
						+ minZoom
						+ ", Max Zoom: "
						+ maxZoom
						+ (compressFormat != null ? ", Compress Format: "
								+ compressFormat : "")
						+ (compressQuality != null ? ", Compress Quality: "
								+ compressQuality : "")
						+ (googleTiles ? ", Google Tiles" : "")
						+ (boundingBox != null ? ", Min Lon: "
								+ boundingBox.getMinLongitude() + ", Min Lat: "
								+ boundingBox.getMinLatitude() + ", Max Lon: "
								+ boundingBox.getMaxLongitude() + ", Max Lat: "
								+ boundingBox.getMaxLatitude() : "")
						+ (epsg != null ? ", EPSG: " + epsg : "")
						+ ", URL EPSG: " + urlEpsg + ", Expected Tile Count: "
						+ count);

		tileGenerator.setProgress(progress);

		LOGGER.log(Level.INFO, "Generating Tiles...");

		try {
			tileGenerator.generateTiles();
		} catch (IOException | SQLException e) {
			throw new GeoPackageException("Exception while generating tiles", e);
		}

		finish();
	}