From 857d04deae0b398ddfc2ac63bbcae2f1c2fb7da9 Mon Sep 17 00:00:00 2001 From: Matthias Kuehlewein Date: Mon, 29 Jul 2024 17:35:33 +0200 Subject: [PATCH 1/3] ImportExport: Avoid duplicate warnings In addition to 'addWarning()' 'addWarningOnce()' only adds a warning to the list of warnings if the warning is not yet in the list. --- src/fileformats/file_import_export.cpp | 10 +++++++++- src/fileformats/file_import_export.h | 9 ++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/fileformats/file_import_export.cpp b/src/fileformats/file_import_export.cpp index 8583ea3c85..d0dec615d3 100644 --- a/src/fileformats/file_import_export.cpp +++ b/src/fileformats/file_import_export.cpp @@ -1,7 +1,7 @@ /* * Copyright 2012, 2013 Pete Curtis * Copyright 2013, 2014 Thomas Schöps - * Copyright 2013-2020 Kai Pastor + * Copyright 2013-2020, 2024 Kai Pastor * * This file is part of OpenOrienteering. * @@ -21,6 +21,7 @@ #include "file_import_export.h" +#include #include #include #include @@ -84,6 +85,13 @@ void ImportExport::setOption(const QString& name, const QVariant& value) } +void ImportExport::addWarningOnce(const QString& str) +{ + if (std::find(warnings_.begin(), warnings_.end(), str) == warnings_.end()) + warnings_.emplace_back(str); +} + + // ### Importer ### Importer::~Importer() = default; diff --git a/src/fileformats/file_import_export.h b/src/fileformats/file_import_export.h index 6097f8fa76..9dc388c8d8 100644 --- a/src/fileformats/file_import_export.h +++ b/src/fileformats/file_import_export.h @@ -1,6 +1,6 @@ /* * Copyright 2012, 2013 Pete Curtis - * Copyright 2018 Kai Pastor + * Copyright 2018, 2024 Kai Pastor * * This file is part of OpenOrienteering. * @@ -112,6 +112,13 @@ class ImportExport */ void addWarning(const QString& str) { warnings_.emplace_back(str); } + /** + * Adds a string to the current list of warnings if not yet in the list. + * + * The provided message should be translated. + */ + void addWarningOnce(const QString& str); + /** * Returns the current list of warnings collected by this object. */ From 089d008ad918100cecaf4ca8741f650dd07ff1da Mon Sep 17 00:00:00 2001 From: Matthias Kuehlewein Date: Mon, 29 Jul 2024 17:36:33 +0200 Subject: [PATCH 2/3] OcdFileImport: Warn about unsupported virtual gaps Line objects in .ocd files can contain virtual gaps, i.e., gaps that interrupt the line but keep the object as a single object. Mapper does not yet support virtual gaps and thus ignores them when importing .ocd files. Issue a warning that virtual gaps in line objects are not supported. --- src/fileformats/ocd_file_import.cpp | 5 +++++ src/fileformats/ocd_types.h | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/fileformats/ocd_file_import.cpp b/src/fileformats/ocd_file_import.cpp index 0fac5b1c25..11cde4613b 100644 --- a/src/fileformats/ocd_file_import.cpp +++ b/src/fileformats/ocd_file_import.cpp @@ -2163,6 +2163,11 @@ void OcdFileImport::fillPathCoords(OcdImportedPathObject *object, bool is_area, { object->coords[i] = convertOcdPoint(ocd_points[i]); setPointFlags(object, i, is_area, ocd_points[i]); + if (ocd_points[i].x & Ocd::OcdPoint32::FlagGap) + { + // Virtual gaps are not supported + addWarningOnce(tr("Virtual gaps in line objects are not supported.")); + } } // For path objects, create closed parts where the position of the last point is equal to that of the first point diff --git a/src/fileformats/ocd_types.h b/src/fileformats/ocd_types.h index f872e9a39e..b3da02e412 100644 --- a/src/fileformats/ocd_types.h +++ b/src/fileformats/ocd_types.h @@ -1,5 +1,5 @@ /* - * Copyright 2013, 2015-2019 Kai Pastor + * Copyright 2013, 2015-2019, 2024 Kai Pastor * * This file is part of OpenOrienteering. * @@ -231,7 +231,8 @@ namespace Ocd { FlagCtl1 = 0x01, FlagCtl2 = 0x02, - FlagLeft = 0x04 + FlagLeft = 0x04, + FlagGap = 0x08 }; // Flags in Y coordinate From 8ce527f078d2a83c0656a9a60c6fb591e21a9a30 Mon Sep 17 00:00:00 2001 From: Matthias Kuehlewein Date: Tue, 30 Jul 2024 15:37:37 +0200 Subject: [PATCH 3/3] OcdFileImport: Warn about unsupported double line gaps Double line objects use symbols with boundary lines (e.g., Wide road symbol). In .ocd files these objects may have gaps in any of the boundary lines. Mapper does not support those kind of gaps and thus ignores them when importing .ocd files. Issue a warning that gaps in double line objects are not supported. --- src/fileformats/ocd_file_import.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/fileformats/ocd_file_import.cpp b/src/fileformats/ocd_file_import.cpp index 11cde4613b..788d56b0f2 100644 --- a/src/fileformats/ocd_file_import.cpp +++ b/src/fileformats/ocd_file_import.cpp @@ -2168,6 +2168,11 @@ void OcdFileImport::fillPathCoords(OcdImportedPathObject *object, bool is_area, // Virtual gaps are not supported addWarningOnce(tr("Virtual gaps in line objects are not supported.")); } + if (ocd_points[i].x & Ocd::OcdPoint32::FlagLeft || ocd_points[i].y & Ocd::OcdPoint32::FlagRight) + { + // Double line gaps are not supported + addWarningOnce(tr("Gaps in double line objects are not supported.")); + } } // For path objects, create closed parts where the position of the last point is equal to that of the first point