From 9674fdb651a242c8cfa7fffc0f5e5278be17a58a Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 17 Jan 2024 01:24:05 -0700 Subject: [PATCH] Validate projection is valid (#47) * Without validation, later code may be invalid Signed-off-by: Ryan Friedman --- src/grid_map_geo.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/grid_map_geo.cpp b/src/grid_map_geo.cpp index 82f617e..6e31e2f 100644 --- a/src/grid_map_geo.cpp +++ b/src/grid_map_geo.cpp @@ -78,6 +78,13 @@ bool GridMapGeo::initializeFromGeotiff(const std::string &path, bool align_terra } const char *pszProjection = dataset->GetProjectionRef(); + + if (strlen(pszProjection) == 0) { + // https://gdal.org/user/raster_data_model.html#coordinate-system + std::cerr << std::endl << "Wkt ProjectionRef is unknown!" << std::endl; + return false; + } + std::cout << std::endl << "Wkt ProjectionRef: " << pszProjection << std::endl; // Get image metadata