From f27ed7e51bb5cccda9f8992d77d0a05566c9daba Mon Sep 17 00:00:00 2001 From: Andrew Kirmse Date: Wed, 29 Oct 2025 12:21:17 -0700 Subject: [PATCH 1/4] Fix lat and lng near 0 for Lidar. Incorrect filenames were being generated near the equator and meridian when running in high-resolution (Lidar) mode. --- code/flt_loader.cpp | 6 ++++-- code/prominence_task.cpp | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/code/flt_loader.cpp b/code/flt_loader.cpp index 0535060..ef28c65 100644 --- a/code/flt_loader.cpp +++ b/code/flt_loader.cpp @@ -196,11 +196,13 @@ string FltLoader::getFltFilename(double minLat, double minLng, const FileFormat case FileFormat::Value::CUSTOM: { int upperLatInt = static_cast(upperLat); // Watch out for "minus 0" - snprintf(buf, sizeof(buf), "tile_%s%02dx%02d_%03dx%02d.flt", + int minLngInt = static_cast(minLng); + snprintf(buf, sizeof(buf), "tile_%s%02dx%02d_%s%03dx%02d.flt", (upperLatInt >= 0) ? "" : "-", abs(upperLatInt), fractionalDegree(upperLat), - static_cast(minLng), + (minLng >= 0) ? "" : "-", + abs(minLngInt), fractionalDegree(minLng)); break; } diff --git a/code/prominence_task.cpp b/code/prominence_task.cpp index a862d05..4363236 100644 --- a/code/prominence_task.cpp +++ b/code/prominence_task.cpp @@ -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(lat), latHundredths, - static_cast(lng), lngHundredths); + snprintf(filename, sizeof(filename), "prominence-%s%02dx%02d-%s%03dx%02d", + (lat >= 0) ? "" : "-", + static_cast(abs(lat)), latHundredths, + (lng >= 0) ? "" : "-", + static_cast(abs(lng)), lngHundredths); return mOptions.outputDir + "/" + filename; } From 8efac04a52840e0fe36fd9c84648ce04c773f215 Mon Sep 17 00:00:00 2001 From: Andrew Kirmse Date: Wed, 29 Oct 2025 12:25:57 -0700 Subject: [PATCH 2/4] Script update for tile filenames. --- scripts/run_prominence.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/run_prominence.py b/scripts/run_prominence.py index 310e4f9..9c405f9 100644 --- a/scripts/run_prominence.py +++ b/scripts/run_prominence.py @@ -57,7 +57,7 @@ def filename_for_coordinates(x, y, degrees_per_tile): # Handle "-0.1" -> "-00x10" 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}" From 0b46c03d937963bbf17e52e803835bd84972a514 Mon Sep 17 00:00:00 2001 From: Andrew Kirmse Date: Wed, 29 Oct 2025 12:27:36 -0700 Subject: [PATCH 3/4] Update comment. --- scripts/run_prominence.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/run_prominence.py b/scripts/run_prominence.py index 9c405f9..6b4cbc6 100644 --- a/scripts/run_prominence.py +++ b/scripts/run_prominence.py @@ -55,7 +55,7 @@ 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):03d}" else: From 52292feceaf06dace101835e6dde869ebf9661b3 Mon Sep 17 00:00:00 2001 From: Andrew Kirmse Date: Thu, 30 Oct 2025 09:15:33 -0700 Subject: [PATCH 4/4] Fix roundoff error at 0 coordinate crossing. --- code/tile_loading_policy.cpp | 2 +- code/util.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/tile_loading_policy.cpp b/code/tile_loading_policy.cpp index 2509ae8..2f74658 100644 --- a/code/tile_loading_policy.cpp +++ b/code/tile_loading_policy.cpp @@ -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); diff --git a/code/util.cpp b/code/util.cpp index 442a6d1..01eba77 100644 --- a/code/util.cpp +++ b/code/util.cpp @@ -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) {