// only continue, if we have tiles that cover the requested extent
if (!renderJob.getMapExtentTileCrs().intersects((Envelope) getBounds())) {
return Collections.emptyMap();
}
ReferencedEnvelope extent = normalizeExtent(renderJob.getMapExtentTileCrs());
WMTTileFactory tileFactory = getTileFactory();
WMTZoomLevel zoomLevel = tileFactory.getZoomLevel(getZoomLevelToUse(renderJob.getZoomLevelMatcher(),
scaleFactor, recommendedZoomLevel, layerProperties), this);
long maxNumberOfTiles = zoomLevel.getMaxTileNumber();
Map<String, Tile> tileList = new HashMap<String, Tile>();
WMTPlugin.debug("[WMTSource.cutExtentIntoTiles] Zoom-Level: " + zoomLevel.getZoomLevel() + //$NON-NLS-1$
" Extent: " + extent, Trace.REQUEST); //$NON-NLS-1$
// Let's get the first tile which covers the upper-left corner
WMTTile firstTile = tileFactory.getTileFromCoordinate(
extent.getMaxY(), extent.getMinX(), zoomLevel, this);
tileList.put(firstTile.getId(), addTileToList(firstTile));
WMTTile firstTileOfRow = null;
WMTTile movingTile = firstTileOfRow = firstTile;
// Loop column
do {
// Loop row
do {
// get the next tile right of this one
WMTTile rightNeighbour = movingTile.getRightNeighbour();
// Check if the new tile is still part of the extent and
// that we don't have the first tile again
if (extent.intersects((Envelope) rightNeighbour.getExtent())
&& !firstTileOfRow.equals(rightNeighbour)) {
tileList.put(rightNeighbour.getId(), addTileToList(rightNeighbour));
WMTPlugin.debug("[WMTSource.cutExtentIntoTiles] Adding right neighbour: " + //$NON-NLS-1$
rightNeighbour.getId(), Trace.REQUEST);
movingTile = rightNeighbour;
} else {
break;
}
if (tileList.size()>tileLimitWarning) {
return Collections.emptyMap();
}
} while(tileList.size() < maxNumberOfTiles);
// get the next tile under the first one of the row
WMTTile lowerNeighbour = firstTileOfRow.getLowerNeighbour();
// Check if the new tile is still part of the extent
if (extent.intersects((Envelope) lowerNeighbour.getExtent())
&& !firstTile.equals(lowerNeighbour)) {
tileList.put(lowerNeighbour.getId(), addTileToList(lowerNeighbour));
WMTPlugin.debug("[WMTSource.cutExtentIntoTiles] Adding lower neighbour: " + //$NON-NLS-1$
lowerNeighbour.getId(), Trace.REQUEST);