Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions code/flt_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,13 @@ string FltLoader::getFltFilename(double minLat, double minLng, const FileFormat

case FileFormat::Value::CUSTOM: {
int upperLatInt = static_cast<int>(upperLat); // Watch out for "minus 0"
snprintf(buf, sizeof(buf), "tile_%s%02dx%02d_%03dx%02d.flt",
int minLngInt = static_cast<int>(minLng);
snprintf(buf, sizeof(buf), "tile_%s%02dx%02d_%s%03dx%02d.flt",
(upperLatInt >= 0) ? "" : "-",
abs(upperLatInt),
fractionalDegree(upperLat),
static_cast<int>(minLng),
(minLng >= 0) ? "" : "-",
abs(minLngInt),
fractionalDegree(minLng));
break;
}
Expand Down
8 changes: 5 additions & 3 deletions code/prominence_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,11 @@ string ProminenceTask::getFilenamePrefix() const {

int latHundredths = fractionalDegree(lat);
int lngHundredths = fractionalDegree(lng);
snprintf(filename, sizeof(filename), "prominence-%02dx%02d-%03dx%02d",
static_cast<int>(lat), latHundredths,
static_cast<int>(lng), lngHundredths);
snprintf(filename, sizeof(filename), "prominence-%s%02dx%02d-%s%03dx%02d",
(lat >= 0) ? "" : "-",
static_cast<int>(abs(lat)), latHundredths,
(lng >= 0) ? "" : "-",
static_cast<int>(abs(lng)), lngHundredths);
return mOptions.outputDir + "/" + filename;
}

Expand Down
2 changes: 1 addition & 1 deletion code/tile_loading_policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Tile *BasicTileLoadingPolicy::loadInternal(double minLat, double minLng) const {

// If the lat/lng can't be represented exactly in floating point,
// there's sometimes roundoff error when converting to integers for
// tile filenames. Adding a little slop prevents truncation.
// tile filenames. Adding a little slop prevents truncation.
minLat = adjustCoordinate(minLat);
minLng = adjustCoordinate(minLng);

Expand Down
2 changes: 1 addition & 1 deletion code/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ double adjustCoordinate(double coordinate) {
// A tile is not going to be smaller than 0.1 degrees or so, so this
// amount should be safe.
const double epsilon = 0.001;
return coordinate + ((coordinate >= 0) ? epsilon : -epsilon);
return coordinate + ((coordinate >= -1e-8) ? epsilon : -epsilon);
}

string trim(const string &s) {
Expand Down
4 changes: 2 additions & 2 deletions scripts/run_prominence.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ def filename_for_coordinates(x, y, degrees_per_tile):
x_fraction = abs(xpart) % 100
y_fraction = abs(ypart) % 100

# Handle "-0.1" -> "-00x10"
# Handle "-0.1" -> "-000x10"
if xpart < 0:
x_string = f"-{abs(x_int):02d}"
x_string = f"-{abs(x_int):03d}"
else:
x_string = f"{x_int:03d}"
x_string += f"x{x_fraction:02d}"
Expand Down