From e2c8a20909ac0e91d856c92f375812b18bb44cce Mon Sep 17 00:00:00 2001 From: Aang23 Date: Tue, 17 Oct 2023 18:34:35 +0200 Subject: [PATCH] Fix a stupid 2 years old bug --- src-core/common/map/map_drawer.cpp | 26 +++---------------- src-core/common/map/map_drawer.h | 2 +- .../products/processor/image_processor.cpp | 12 +++------ src-interface/viewer/image_handler.cpp | 6 ++--- .../viewer/scatterometer_handler.cpp | 6 ++--- src-interface/viewer/viewer_projection.cpp | 5 ++-- tools/proj_test/main.cpp | 3 +-- 7 files changed, 16 insertions(+), 44 deletions(-) diff --git a/src-core/common/map/map_drawer.cpp b/src-core/common/map/map_drawer.cpp index 233037b29..8ee3356e9 100644 --- a/src-core/common/map/map_drawer.cpp +++ b/src-core/common/map/map_drawer.cpp @@ -205,14 +205,14 @@ namespace map template void drawProjectedCitiesGeoJson(std::vector, image::Image &, uint16_t[3], std::function(float, float, int, int)>, int, int, int); template - void drawProjectedMapShapefile(std::vector shapeFiles, image::Image &map_image, T color[3], std::function(float, float, int, int)> projectionFunc, int maxLength) + void drawProjectedMapShapefile(std::vector shapeFiles, image::Image &map_image, T color[3], std::function(float, float, int, int)> projectionFunc) { for (std::string currentShapeFile : shapeFiles) { std::ifstream inputFile(currentShapeFile, std::ios::binary); shapefile::Shapefile shape_file(inputFile); - std::function>)> polylineDraw = [color, maxLength, &map_image, &projectionFunc](std::vector> parts) + std::function>)> polylineDraw = [color, &map_image, &projectionFunc](std::vector> parts) { for (std::vector coordinates : parts) { @@ -223,24 +223,6 @@ namespace map std::pair end = projectionFunc(coordinates[i + 1].y, coordinates[i + 1].x, map_image.height(), map_image.width()); - if (sqrt(pow(start.first - end.first, 2) + pow(start.second - end.second, 2)) >= maxLength) - continue; - - if (start.first == -1 || end.first == -1) - continue; - - map_image.draw_line(start.first, start.second, end.first, end.second, color); - } - - { - std::pair start = projectionFunc(coordinates[0].y, coordinates[0].x, - map_image.height(), map_image.width()); - std::pair end = projectionFunc(coordinates[coordinates.size() - 1].y, coordinates[coordinates.size() - 1].x, - map_image.height(), map_image.width()); - - if (sqrt(pow(start.first - end.first, 2) + pow(start.second - end.second, 2)) >= maxLength) - continue; - if (start.first == -1 || end.first == -1) continue; @@ -275,8 +257,8 @@ namespace map } } - template void drawProjectedMapShapefile(std::vector, image::Image &, uint8_t[3], std::function(float, float, int, int)>, int); - template void drawProjectedMapShapefile(std::vector, image::Image &, uint16_t[3], std::function(float, float, int, int)>, int); + template void drawProjectedMapShapefile(std::vector, image::Image &, uint8_t[3], std::function(float, float, int, int)>); + template void drawProjectedMapShapefile(std::vector, image::Image &, uint16_t[3], std::function(float, float, int, int)>); template void drawProjectedMapLatLonGrid(image::Image &image, T color[3], std::function(float, float, int, int)> projectionFunc) diff --git a/src-core/common/map/map_drawer.h b/src-core/common/map/map_drawer.h index bb2efe6e0..6d081d138 100644 --- a/src-core/common/map/map_drawer.h +++ b/src-core/common/map/map_drawer.h @@ -13,7 +13,7 @@ namespace map template void drawProjectedCitiesGeoJson(std::vector shapeFiles, image::Image &image, T color[3], std::function(float, float, int, int)> projectionFunc, int font_size = 50, int cities_type = 0, int cities_scale_rank = 10); template - void drawProjectedMapShapefile(std::vector shapeFiles, image::Image &image, T color[3], std::function(float, float, int, int)> projectionFunc, int maxLength = 2147483647); + void drawProjectedMapShapefile(std::vector shapeFiles, image::Image &image, T color[3], std::function(float, float, int, int)> projectionFunc); template void drawProjectedMapLatLonGrid(image::Image &image, T color[3], std::function(float, float, int, int)> projectionFunc); diff --git a/src-core/products/processor/image_processor.cpp b/src-core/products/processor/image_processor.cpp index 615c20d29..3acb5d833 100644 --- a/src-core/products/processor/image_processor.cpp +++ b/src-core/products/processor/image_processor.cpp @@ -167,14 +167,12 @@ namespace satdump map::drawProjectedMapShapefile({resources::getResourcePath("maps/ne_10m_admin_0_countries.shp")}, rgb_image, color, - proj_func, - 100); + proj_func); if (geo_correct) map::drawProjectedMapShapefile({resources::getResourcePath("maps/ne_10m_admin_0_countries.shp")}, rgb_image_corr, color, - corr_proj_func, - 100); + corr_proj_func); } if (shores_overlay) @@ -192,14 +190,12 @@ namespace satdump map::drawProjectedMapShapefile({resources::getResourcePath("maps/ne_10m_coastline.shp")}, rgb_image, color, - proj_func, - 100); + proj_func); if (geo_correct) map::drawProjectedMapShapefile({resources::getResourcePath("maps/ne_10m_coastline.shp")}, rgb_image_corr, color, - corr_proj_func, - 100); + corr_proj_func); } if (latlon_overlay) diff --git a/src-interface/viewer/image_handler.cpp b/src-interface/viewer/image_handler.cpp index d5cfd38f5..eba9707cd 100644 --- a/src-interface/viewer/image_handler.cpp +++ b/src-interface/viewer/image_handler.cpp @@ -189,8 +189,7 @@ namespace satdump map::drawProjectedMapShapefile({resources::getResourcePath("maps/ne_10m_admin_0_countries.shp")}, current_image, color, - proj_func, - 100); + proj_func); } if (shores_overlay) { @@ -200,8 +199,7 @@ namespace satdump map::drawProjectedMapShapefile({resources::getResourcePath("maps/ne_10m_coastline.shp")}, current_image, color, - proj_func, - 100); + proj_func); } if (cities_overlay) { diff --git a/src-interface/viewer/scatterometer_handler.cpp b/src-interface/viewer/scatterometer_handler.cpp index 039e78b20..4a2b0584b 100644 --- a/src-interface/viewer/scatterometer_handler.cpp +++ b/src-interface/viewer/scatterometer_handler.cpp @@ -78,8 +78,7 @@ namespace satdump map::drawProjectedMapShapefile({ resources::getResourcePath("maps/ne_10m_admin_0_countries.shp") }, current_img, color, - proj_func, - 100); + proj_func); } if (shores_overlay) { @@ -89,8 +88,7 @@ namespace satdump map::drawProjectedMapShapefile({ resources::getResourcePath("maps/ne_10m_coastline.shp") }, current_img, color, - proj_func, - 100); + proj_func); } if (cities_overlay) { diff --git a/src-interface/viewer/viewer_projection.cpp b/src-interface/viewer/viewer_projection.cpp index ff703a9b9..1c4941dc7 100644 --- a/src-interface/viewer/viewer_projection.cpp +++ b/src-interface/viewer/viewer_projection.cpp @@ -545,7 +545,7 @@ namespace satdump map::drawProjectedMapShapefile({resources::getResourcePath("maps/ne_10m_admin_0_countries.shp")}, projected_image_result, color, - proj_func, 200); + proj_func); } // Draw map shorelines @@ -556,8 +556,7 @@ namespace satdump map::drawProjectedMapShapefile({resources::getResourcePath("maps/ne_10m_coastline.shp")}, projected_image_result, color, - proj_func, - 200); + proj_func); } // Draw cities points diff --git a/tools/proj_test/main.cpp b/tools/proj_test/main.cpp index a470f660f..cf9e57af3 100644 --- a/tools/proj_test/main.cpp +++ b/tools/proj_test/main.cpp @@ -112,8 +112,7 @@ int main(int /*argc*/, char *argv[]) int x, y; projector_final.forward(lon, lat, x, y); return {x, y}; - }, - 200); + }); } #if 0 {