Skip to content

Commit

Permalink
Read tiles to render from full GeoJSON where necessary
Browse files Browse the repository at this point in the history
Otherwise we would create images for only "new"
adjacent tiles and thus would cause invalid
empty areas when new squares/tiles are added
  • Loading branch information
centic9 committed Apr 15, 2024
1 parent 02e56d9 commit 5ceb464
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import javax.imageio.ImageIO;

import org.dstadler.commons.logging.jdk.LoggerFactory;
import org.dstadler.ctw.utils.OSMTile;

/**
* This application takes the list of covered tiles from
Expand All @@ -37,7 +36,6 @@ public class CreateAdjacentTileOverlaysFromTiles {

public static final File ADJACENT_TILES_DIR = new File("tilesTilesAdjacent");
public static final File ADJACENT_TILES_JSON = new File("js/AdjacentTiles.json");
public static final File ADJACENT_TILES_NEW_JSON = new File("js/AdjacentTilesNew.json");

public static void main(String[] args) throws IOException, InterruptedException {
LoggerFactory.initLogging();
Expand All @@ -49,14 +47,18 @@ public static void main(String[] args) throws IOException, InterruptedException

File tileDir = ADJACENT_TILES_DIR;
String tilesFile = onlyNewTiles ? ADJACENT_TILES_NEW_TXT: ADJACENT_TILES_TXT;
File jsonFile = onlyNewTiles ? ADJACENT_TILES_NEW_JSON : ADJACENT_TILES_JSON;

if (onlyNewTiles) {
log.info("Writing only new adjacent tiles to directory " + tileDir);
} else {
log.info("Writing adjacent tiles to directory " + tileDir);
}

/* we write both into the same directory, so do not remove these here
if (onlyNewTiles) {
CreateTileOverlaysHelper.cleanTiles(tileDir);
}
*/
if (!tileDir.exists() && !tileDir.mkdirs()) {
throw new IOException("Could not create directory at " + tileDir);
}
Expand All @@ -67,7 +69,8 @@ public static void main(String[] args) throws IOException, InterruptedException

AtomicInteger tilesOverall = new AtomicInteger();
// t.toCoords().equals("17/70647/45300")
CreateTileOverlaysFromTiles.generateTiles(tiles, tilesOverall, tileDir, jsonFile, t -> true, true);
CreateTileOverlaysFromTiles.generateTiles(tiles, tilesOverall,
tileDir, ADJACENT_TILES_JSON, t -> true, true);

log.info(String.format(Locale.US, "Wrote %,d files overall in %,dms",
tilesOverall.get(), System.currentTimeMillis() - start));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static void main(String[] args) throws IOException, InterruptedException

tilesOverall = new AtomicInteger();
generateTiles(CreateTileOverlaysHelper.read(VISITED_TILES_TXT, "tiles"), tilesOverall, TILES_TILES_DIR,
jsonFile, newTiles::contains, false);
VISITED_TILES_JSON, newTiles::contains, false);

log.info(String.format(Locale.US, "Wrote %,d files for changed tiles in %,dms",
tilesOverall.get(), System.currentTimeMillis() - start));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public static void main(String[] args) throws IOException, InterruptedException

tilesOverall = new AtomicInteger();
generateTiles(CreateTileOverlaysHelper.read(VISITED_SQUARES_TXT, "squares"), tilesOverall, TILES_SQUARES_DIR,
jsonFile, newTiles::contains);
VISITED_SQUARES_JSON, newTiles::contains);

log.info(String.format(Locale.US, "Wrote %,d files for changed tiles in %,dms",
tilesOverall.get(), System.currentTimeMillis() - start));
Expand Down

0 comments on commit 5ceb464

Please sign in to comment.