From 0644bb72a0af60583f4b440502d2dd89711226ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Mon, 2 Nov 2020 20:16:02 +0100 Subject: [PATCH] Broken subdivs are more common than one would expect... --- src/map/IMG/trefile.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/map/IMG/trefile.cpp b/src/map/IMG/trefile.cpp index 2efdd532..a6956e51 100644 --- a/src/map/IMG/trefile.cpp +++ b/src/map/IMG/trefile.cpp @@ -202,22 +202,18 @@ bool TREFile::load(int idx) double min[2], max[2]; RectC bounds(Coordinates(LB(lon - width), toWGS24(lat + height)), Coordinates(RB(lon + width), toWGS24(lat - height))); - if (!bounds.isValid()) { - qWarning("%s: invalid subdiv bounds (level %d; pos %f,%f; size %fx%f)", - qPrintable(fileName()), level.level, toWGS24(lon), toWGS24(lat), - toWGS24(width), toWGS24(height)); - /* mkgmap produces invalid (zero width or/and zero height) subdiv - bounds in some cases. Allow such bounds as they should not break - things. */ - if (!(!width || !height)) - goto error; - } min[0] = bounds.left(); min[1] = bounds.bottom(); max[0] = bounds.right(); max[1] = bounds.top(); + /* both mkgmap and cGPSmapper generate all kinds of broken subdiv bounds + (zero lat/lon, zero width/height, ...) so we check only that the + subdiv item does not break the rtree, not for full bounds validity. */ + if (!(min[0] <= max[0] && min[1] <= max[1])) + goto error; + tree->Insert(min, max, s); }