Bug Summary

File:/home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/plugins/runner/pn2/Pn2Runner.cpp
Warning:line 278, column 9
Potential leak of memory pointed to by 'polygon'

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name Pn2Runner.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/gilles/devel/GIT/8.x/build.scan/core/utilities/geolocation/engine/plugins/runner/pn2 -fcoverage-compilation-dir=/home/gilles/devel/GIT/8.x/build.scan/core/utilities/geolocation/engine/plugins/runner/pn2 -resource-dir /usr/lib/llvm-18/lib/clang/18 -isystem /opt/qt6/include -isystem /opt/qt6/include/QtCore -isystem /opt/qt6/mkspecs/linux-g++ -isystem /opt/qt6/include/QtGui -isystem /opt/qt6/include/QtNetwork -isystem /opt/qt6/include/QtWidgets -isystem /opt/qt6/include/QtXml -isystem /opt/qt6/include/QtSvg -isystem /opt/qt6/include/KF6/KI18n -isystem /opt/qt6/include/QtSvgWidgets -D CMS_NO_REGISTER_KEYWORD=1 -D HAVE_FFMPEG_VERSION5 -D LIBPGF_DISABLE_OPENMP -D MAGICKCORE_HDRI_ENABLE=0 -D MAGICKCORE_QUANTUM_DEPTH=16 -D Pn2Plugin_EXPORTS -D QT_CORE_LIB -D QT_DEPRECATED_WARNINGS -D QT_DEPRECATED_WARNINGS_SINCE=0x060000 -D QT_DISABLE_DEPRECATED_BEFORE=0x050E00 -D QT_GUI_LIB -D QT_NETWORK_LIB -D QT_NO_CAST_FROM_ASCII -D QT_NO_CAST_FROM_BYTEARRAY -D QT_NO_CAST_TO_ASCII -D QT_NO_KEYWORDS -D QT_NO_NARROWING_CONVERSIONS_IN_CONNECT -D QT_NO_URL_CAST_FROM_STRING -D QT_STRICT_ITERATORS -D QT_SVGWIDGETS_LIB -D QT_SVG_LIB -D QT_USE_QSTRINGBUILDER -D QT_WIDGETS_LIB -D QT_XML_LIB -D TRANSLATION_DOMAIN="digikam" -D USE_JASPER -D USE_JPEG -D USE_JPEG8 -D _GNU_SOURCE -D _LARGEFILE64_SOURCE -I /home/gilles/devel/GIT/8.x/build.scan/core/utilities/geolocation/engine/plugins/runner/pn2 -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/plugins/runner/pn2 -I /home/gilles/devel/GIT/8.x/build.scan/core/utilities/geolocation/engine/plugins/runner/pn2/Pn2Plugin_autogen/include -I /home/gilles/devel/GIT/8.x/core/libs/video/player/qtmm -I /home/gilles/devel/GIT/8.x/core/libs/album/engine -I /home/gilles/devel/GIT/8.x/core/libs/album/manager -I /home/gilles/devel/GIT/8.x/core/libs/album/treeview -I /home/gilles/devel/GIT/8.x/core/libs/album/widgets -I /home/gilles/devel/GIT/8.x/core/libs/database/collection -I /home/gilles/devel/GIT/8.x/core/libs/database/coredb -I /home/gilles/devel/GIT/8.x/core/libs/database/dbjobs -I /home/gilles/devel/GIT/8.x/core/libs/database/engine -I /home/gilles/devel/GIT/8.x/core/libs/database/haar -I /home/gilles/devel/GIT/8.x/core/libs/database/history -I /home/gilles/devel/GIT/8.x/core/libs/database/item/containers -I /home/gilles/devel/GIT/8.x/core/libs/database/item/lister -I /home/gilles/devel/GIT/8.x/core/libs/database/item/query -I /home/gilles/devel/GIT/8.x/core/libs/database/item/scanner -I /home/gilles/devel/GIT/8.x/core/libs/database/models -I /home/gilles/devel/GIT/8.x/core/libs/database/server -I /home/gilles/devel/GIT/8.x/core/libs/database/similaritydb -I /home/gilles/devel/GIT/8.x/core/libs/database/tags -I /home/gilles/devel/GIT/8.x/core/libs/database/thumbsdb -I /home/gilles/devel/GIT/8.x/core/libs/database/utils/ifaces -I /home/gilles/devel/GIT/8.x/core/libs/database/utils/scan -I /home/gilles/devel/GIT/8.x/core/libs/database/utils/widgets -I /home/gilles/devel/GIT/8.x/core/libs/dialogs -I /home/gilles/devel/GIT/8.x/core/libs/dimg/color -I /home/gilles/devel/GIT/8.x/core/libs/dimg -I /home/gilles/devel/GIT/8.x/core/libs/dimg/filters/auto -I /home/gilles/devel/GIT/8.x/core/libs/dimg/filters/bcg -I /home/gilles/devel/GIT/8.x/core/libs/dimg/filters/bw -I /home/gilles/devel/GIT/8.x/core/libs/dimg/filters/cb -I /home/gilles/devel/GIT/8.x/core/libs/dimg/filters/curves -I /home/gilles/devel/GIT/8.x/core/libs/dimg/filters/decorate -I /home/gilles/devel/GIT/8.x/core/libs/dimg/filters -I /home/gilles/devel/GIT/8.x/core/libs/dimg/filters/film -I /home/gilles/devel/GIT/8.x/core/libs/dimg/filters/fx -I /home/gilles/devel/GIT/8.x/core/libs/dimg/filters/greycstoration/cimg -I /home/gilles/devel/GIT/8.x/core/libs/dimg/filters/greycstoration -I /home/gilles/devel/GIT/8.x/core/libs/dimg/filters/hotpixels -I /home/gilles/devel/GIT/8.x/core/libs/dimg/filters/hsl -I /home/gilles/devel/GIT/8.x/core/libs/dimg/filters/icc -I /home/gilles/devel/GIT/8.x/core/libs/dimg/filters/lc -I /home/gilles/devel/GIT/8.x/core/libs/dimg/filters/lens -I /home/gilles/devel/GIT/8.x/core/libs/dimg/filters/levels -I /home/gilles/devel/GIT/8.x/core/libs/dimg/filters/nr -I /home/gilles/devel/GIT/8.x/core/libs/dimg/filters/raw -I /home/gilles/devel/GIT/8.x/core/libs/dimg/filters/redeye -I /home/gilles/devel/GIT/8.x/core/libs/dimg/filters/sharp -I /home/gilles/devel/GIT/8.x/core/libs/dimg/filters/transform -I /home/gilles/devel/GIT/8.x/core/libs/dimg/filters/wb -I /home/gilles/devel/GIT/8.x/core/libs/dimg/history -I /home/gilles/devel/GIT/8.x/core/libs/dimg/loaders -I /home/gilles/devel/GIT/8.x/core/libs/dngwriter -I /home/gilles/devel/GIT/8.x/core/libs/dplugins/core -I /home/gilles/devel/GIT/8.x/core/libs/dplugins/iface -I /home/gilles/devel/GIT/8.x/core/libs/dplugins/setup -I /home/gilles/devel/GIT/8.x/core/libs/dplugins/webservices -I /home/gilles/devel/GIT/8.x/core/libs/dplugins/widgets -I /home/gilles/devel/GIT/8.x/core/libs/dragdrop -I /home/gilles/devel/GIT/8.x/core/libs/dtrash -I /home/gilles/devel/GIT/8.x/core/libs/facesengine/common -I /home/gilles/devel/GIT/8.x/core/libs/facesengine/detection -I /home/gilles/devel/GIT/8.x/core/libs/facesengine/detection/opencv-dnn -I /home/gilles/devel/GIT/8.x/core/libs/facesengine/facedb -I /home/gilles/devel/GIT/8.x/core/libs/facesengine/preprocessing -I /home/gilles/devel/GIT/8.x/core/libs/facesengine/preprocessing/recognition -I /home/gilles/devel/GIT/8.x/core/libs/facesengine/preprocessing/shape-predictor -I /home/gilles/devel/GIT/8.x/core/libs/facesengine/recognition -I /home/gilles/devel/GIT/8.x/core/libs/facesengine/recognition/opencv-dnn -I /home/gilles/devel/GIT/8.x/core/libs/fileactionmanager -I /home/gilles/devel/GIT/8.x/core/libs/filters -I /home/gilles/devel/GIT/8.x/core/libs/imgqsort/detectors -I /home/gilles/devel/GIT/8.x/core/libs/imgqsort -I /home/gilles/devel/GIT/8.x/core/libs/iojobs -I /home/gilles/devel/GIT/8.x/core/libs/jpegutils -I /home/gilles/devel/GIT/8.x/core/libs/metadataengine/containers -I /home/gilles/devel/GIT/8.x/core/libs/metadataengine/dmetadata -I /home/gilles/devel/GIT/8.x/core/libs/metadataengine/engine -I /home/gilles/devel/GIT/8.x/core/libs/metadataengine/exiftool -I /home/gilles/devel/GIT/8.x/core/libs/metadataengine/focuspoint -I /home/gilles/devel/GIT/8.x/core/libs/models -I /home/gilles/devel/GIT/8.x/core/libs/networkmanager -I /home/gilles/devel/GIT/8.x/core/libs/notificationmanager -I /home/gilles/devel/GIT/8.x/core/libs/onlineversion -I /home/gilles/devel/GIT/8.x/core/libs/pgfutils -I /home/gilles/devel/GIT/8.x/core/libs/progressmanager -I /home/gilles/devel/GIT/8.x/core/libs/properties/captions -I /home/gilles/devel/GIT/8.x/core/libs/properties/geolocation -I /home/gilles/devel/GIT/8.x/core/libs/properties/history -I /home/gilles/devel/GIT/8.x/core/libs/properties/import -I /home/gilles/devel/GIT/8.x/core/libs/properties -I /home/gilles/devel/GIT/8.x/core/libs/rawengine -I /home/gilles/devel/GIT/8.x/core/libs/settings -I /home/gilles/devel/GIT/8.x/core/libs/tags/autoassignment -I /home/gilles/devel/GIT/8.x/core/libs/tags/autoassignment/model -I /home/gilles/devel/GIT/8.x/core/libs/tags/engine -I /home/gilles/devel/GIT/8.x/core/libs/tags/manager/models -I /home/gilles/devel/GIT/8.x/core/libs/tags/manager -I /home/gilles/devel/GIT/8.x/core/libs/tags/widgets -I /home/gilles/devel/GIT/8.x/core/libs/template -I /home/gilles/devel/GIT/8.x/core/libs/threadimageio/engine -I /home/gilles/devel/GIT/8.x/core/libs/threadimageio/fileio -I /home/gilles/devel/GIT/8.x/core/libs/threadimageio/preview -I /home/gilles/devel/GIT/8.x/core/libs/threadimageio/thumb -I /home/gilles/devel/GIT/8.x/core/libs/threadimageio/video -I /home/gilles/devel/GIT/8.x/core/libs/threads -I /home/gilles/devel/GIT/8.x/core/libs/timeadjust -I /home/gilles/devel/GIT/8.x/core/libs/transitionmngr -I /home/gilles/devel/GIT/8.x/core/libs/versionmanager -I /home/gilles/devel/GIT/8.x/core/libs/video -I /home/gilles/devel/GIT/8.x/core/libs/video/manager -I /home/gilles/devel/GIT/8.x/core/libs/video/osd -I /home/gilles/devel/GIT/8.x/core/libs/video/player -I /home/gilles/devel/GIT/8.x/core/libs/widgets/colors -I /home/gilles/devel/GIT/8.x/core/libs/widgets/combo -I /home/gilles/devel/GIT/8.x/core/libs/widgets/files -I /home/gilles/devel/GIT/8.x/core/libs/widgets/fonts -I /home/gilles/devel/GIT/8.x/core/libs/widgets/graphicsview -I /home/gilles/devel/GIT/8.x/core/libs/widgets/history -I /home/gilles/devel/GIT/8.x/core/libs/widgets/iccprofiles -I /home/gilles/devel/GIT/8.x/core/libs/widgets/itemview -I /home/gilles/devel/GIT/8.x/core/libs/widgets/layout -I /home/gilles/devel/GIT/8.x/core/libs/widgets/mainview -I /home/gilles/devel/GIT/8.x/core/libs/widgets/metadata/config -I /home/gilles/devel/GIT/8.x/core/libs/widgets/metadata/exiftool -I /home/gilles/devel/GIT/8.x/core/libs/widgets/metadata/exiv2 -I /home/gilles/devel/GIT/8.x/core/libs/widgets/metadata/labels -I /home/gilles/devel/GIT/8.x/core/libs/widgets/metadata/utils -I /home/gilles/devel/GIT/8.x/core/libs/widgets/range -I /home/gilles/devel/GIT/8.x/core/libs/widgets/text -I /home/gilles/devel/GIT/8.x/core/libs/jpegutils/libjpeg/84 -I /home/gilles/devel/GIT/8.x/core/app/utils -I /home/gilles/devel/GIT/8.x/build.scan/core/app/utils -I /home/gilles/devel/GIT/8.x/core/utilities/advancedrename -I /home/gilles/devel/GIT/8.x/core/utilities/advancedrename/common -I /home/gilles/devel/GIT/8.x/core/utilities/advancedrename/parser -I /home/gilles/devel/GIT/8.x/core/utilities/advancedrename/parser/modifiers -I /home/gilles/devel/GIT/8.x/core/utilities/advancedrename/parser/options -I /home/gilles/devel/GIT/8.x/core/utilities/advancedrename/parser/options/database -I /home/gilles/devel/GIT/8.x/core/utilities/advancedrename/parser/options/database/keys -I /home/gilles/devel/GIT/8.x/core/utilities/extrasupport/addressbook -I /home/gilles/devel/GIT/8.x/core/utilities/extrasupport/filesindexer -I /home/gilles/devel/GIT/8.x/core/utilities/facemanagement/bench -I /home/gilles/devel/GIT/8.x/core/utilities/facemanagement/database -I /home/gilles/devel/GIT/8.x/core/utilities/facemanagement/items -I /home/gilles/devel/GIT/8.x/core/utilities/facemanagement/threads -I /home/gilles/devel/GIT/8.x/core/utilities/facemanagement/widgets -I /home/gilles/devel/GIT/8.x/core/utilities/facemanagement/workers -I /home/gilles/devel/GIT/8.x/core/utilities/firstrun -I /home/gilles/devel/GIT/8.x/core/utilities/focuspointmanagement -I /home/gilles/devel/GIT/8.x/core/utilities/fuzzysearch -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/astro -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/blendings -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/core -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/geodata/data -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/geodata/graphicsitem -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/geodata/handlers/dgml -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/geodata/handlers/kml -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/geodata/parser -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/geodata/scene -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/geodata/writer -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/geodata/writers/dgml -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/geodata/writers/kml -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/graphicsview -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/layers -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/models -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/osm -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/plugins -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/plugins/render/atmosphere -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/plugins/render/compass -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/plugins/render/crosshairs -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/plugins/render/graticule -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/plugins/render/mapscale -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/plugins/render/measure -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/plugins/render/navigation -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/plugins/render/overviewmap -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/plugins/render/progress -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/plugins/runner/cache -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/plugins/runner/gpsbabel -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/plugins/runner/gpx -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/plugins/runner/gpx/handlers -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/plugins/runner/json -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/plugins/runner/kml -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/plugins/runner/nominatim-reversegeocoding -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/plugins/runner/osm -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/plugins/runner/osm/o5mreader -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/plugins/runner/osm/translators -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/plugins/runner/osm/writers -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/plugins/runner/pnt -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/projections -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/runners -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/settings -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/storage -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/tile -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/geoiface/backends -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/geoiface/bookmark -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/geoiface/core -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/geoiface/correlator -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/geoiface/dragdrop -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/geoiface/items -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/geoiface/lookup -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/geoiface/reversegeocoding -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/geoiface/tiles -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/geoiface/tracks -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/geoiface/widgets -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/geomapwrapper -I /home/gilles/devel/GIT/8.x/core/utilities/geolocation/mapsearches -I /home/gilles/devel/GIT/8.x/core/utilities/imageeditor/core -I /home/gilles/devel/GIT/8.x/core/utilities/imageeditor/dialogs -I /home/gilles/devel/GIT/8.x/core/utilities/imageeditor/editor -I /home/gilles/devel/GIT/8.x/core/utilities/imageeditor/main -I /home/gilles/devel/GIT/8.x/core/utilities/imageeditor/widgets -I /home/gilles/devel/GIT/8.x/core/utilities/import/backend -I /home/gilles/devel/GIT/8.x/core/utilities/import/dialogs -I /home/gilles/devel/GIT/8.x/core/utilities/import/items -I /home/gilles/devel/GIT/8.x/core/utilities/import/main -I /home/gilles/devel/GIT/8.x/core/utilities/import/models -I /home/gilles/devel/GIT/8.x/core/utilities/import/views -I /home/gilles/devel/GIT/8.x/core/utilities/import/widgets -I /home/gilles/devel/GIT/8.x/core/utilities/lighttable -I /home/gilles/devel/GIT/8.x/core/utilities/maintenance/main -I /home/gilles/devel/GIT/8.x/core/utilities/maintenance/manager -I /home/gilles/devel/GIT/8.x/core/utilities/maintenance/tools/autotags -I /home/gilles/devel/GIT/8.x/core/utilities/maintenance/tools/dbcleaner -I /home/gilles/devel/GIT/8.x/core/utilities/maintenance/tools/dbscan -I /home/gilles/devel/GIT/8.x/core/utilities/maintenance/tools/duplicates -I /home/gilles/devel/GIT/8.x/core/utilities/maintenance/tools/facesmanagement -I /home/gilles/devel/GIT/8.x/core/utilities/maintenance/tools/fingerprints -I /home/gilles/devel/GIT/8.x/core/utilities/maintenance/tools/imgqsort -I /home/gilles/devel/GIT/8.x/core/utilities/maintenance/tools/metaremover -I /home/gilles/devel/GIT/8.x/core/utilities/maintenance/tools/metasync -I /home/gilles/devel/GIT/8.x/core/utilities/maintenance/tools/thumbs -I /home/gilles/devel/GIT/8.x/core/utilities/maintenance/utils -I /home/gilles/devel/GIT/8.x/core/utilities/queuemanager/dplugins -I /home/gilles/devel/GIT/8.x/core/utilities/queuemanager/main -I /home/gilles/devel/GIT/8.x/core/utilities/queuemanager/manager -I /home/gilles/devel/GIT/8.x/core/utilities/queuemanager/views -I /home/gilles/devel/GIT/8.x/core/utilities/searchwindow -I /home/gilles/devel/GIT/8.x/core/utilities/setup/album -I /home/gilles/devel/GIT/8.x/core/utilities/setup/camera -I /home/gilles/devel/GIT/8.x/core/utilities/setup/collections -I /home/gilles/devel/GIT/8.x/core/utilities/setup/downloader -I /home/gilles/devel/GIT/8.x/core/utilities/setup/editor -I /home/gilles/devel/GIT/8.x/core/utilities/setup/metadata -I /home/gilles/devel/GIT/8.x/core/utilities/setup/misc -I /home/gilles/devel/GIT/8.x/core/utilities/setup -I /home/gilles/devel/GIT/8.x/core/app/main -I /home/gilles/devel/GIT/8.x/core/app/date -I /home/gilles/devel/GIT/8.x/core/app/dragdrop -I /home/gilles/devel/GIT/8.x/core/app/views/stack -I /home/gilles/devel/GIT/8.x/core/app/views/utils -I /home/gilles/devel/GIT/8.x/core/app/views/sidebar -I /home/gilles/devel/GIT/8.x/core/app/items/utils -I /home/gilles/devel/GIT/8.x/core/app/items/overlays -I /home/gilles/devel/GIT/8.x/core/app/items/views -I /home/gilles/devel/GIT/8.x/core/app/items/thumbbar -I /home/gilles/devel/GIT/8.x/core/app/views/preview -I /home/gilles/devel/GIT/8.x/build.scan/core/app -I /home/gilles/devel/GIT/8.x/core/app -I /usr/include/opencv4 -I /usr/include/ImageMagick-6 -I /usr/include/x86_64-linux-gnu/ImageMagick-6 -I /opt/qt6/include/QtMultimedia -I /opt/qt6/include/QtMultimediaWidgets -I /opt/qt6/include/QtConcurrent -I /opt/qt6/include/KF6/KConfig -I /opt/qt6/include/KF6/KConfigCore -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/x86_64-linux-gnu/c++/13 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/backward -internal-isystem /usr/lib/llvm-18/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/13/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-long-long -Wno-deprecated-copy -std=c++20 -fdeprecated-macro -ferror-limit 19 -fvisibility=hidden -fvisibility-inlines-hidden -fno-operator-names -fopenmp -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /mnt/data2/devel/GIT/8.x/project/reports/report.scan/2024-07-24-085343-476556-1 -x c++ /home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/plugins/runner/pn2/Pn2Runner.cpp
1/* ============================================================
2 *
3 * This file is a part of digiKam project
4 * https://www.digikam.org
5 *
6 * Date : 2023-05-15
7 * Description : geolocation engine based on Marble.
8 * (c) 2007-2022 Marble Team
9 * https://invent.kde.org/education/marble/-/raw/master/data/credits_authors.html
10 *
11 * SPDX-FileCopyrightText: 2023-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
12 *
13 * SPDX-License-Identifier: LGPL-2.1-or-later
14 *
15 * ============================================================ */
16
17#include "Pn2Runner.h"
18
19// Qt includes
20
21#include <QFile>
22#include <QFileInfo>
23
24// Local includes
25
26#include "GeoDataDocument.h"
27#include "GeoDataPlacemark.h"
28#include "GeoDataStyle.h"
29#include "GeoDataPolyStyle.h"
30#include "GeoDataLinearRing.h"
31#include "GeoDataPolygon.h"
32#include "GeoDataMultiGeometry.h"
33#include "digikam_debug.h"
34
35namespace Marble
36{
37
38// Polygon header flags, representing the type of polygon
39
40enum polygonFlagType
41{
42 LINESTRING = 0,
43 LINEARRING = 1,
44 OUTERBOUNDARY = 2,
45 INNERBOUNDARY = 3,
46 MULTIGEOMETRY = 4
47};
48
49/**
50 * For the Natural Earth Layer providing the Default data set at 0.5 arcminute resolution should be enough.
51 * This fileformat allows for even better packed data than the PNT format. For detailed polygons at arcminute
52 * scale on average it should use only 33% of the amount used by PNT.
53 *
54 * Description of the file format
55 *
56 * In the fileformat initially a file header is provided that provides the file format version and the number
57 * of polygons stored inside the file. A Polygon starts with the Polygon Header which provides the feature id
58 * and the number of so called "absolute nodes" that are about to follow. Absolute nodes always contain
59 * absolute geodetic coordinates. The Polygon Header also provides a flag that allows to specify whether the
60 * polygon is supposed to represent a line string ("0") or a linear ring ("1"). Each absolute node can be followed
61 * by relative nodes: These relative nodes are always nodes that follow in correct order inside the polygon after
62 * "their" absolute node. Each absolute node specifies the number of relative nodes which contain relative
63 * coordinates in reference to their absolute node. So an absolute node provides the absolute reference for
64 * relative nodes across a theoretical area of 2x2 squaredegree-area (which in practice frequently might rather
65 * amount to 1x1 square degrees).
66 *
67 * So much of the compression works by just referencing lat/lon diffs to special "absolute nodes". Hence the
68 * compression will especially work well for polygons with many nodes with a high node density.
69 *
70 * The parser has to convert these relative coordinates to absolute coordinates.
71 */
72Pn2Runner::Pn2Runner(QObject* parent)
73 : ParsingRunner(parent)
74{
75}
76
77Pn2Runner::~Pn2Runner()
78{
79}
80
81bool Pn2Runner::errorCheckLat(qint16 lat)
82{
83 return !(lat >= -10800 && lat <= +10800);
84}
85
86bool Pn2Runner::errorCheckLon(qint16 lon)
87{
88 return !(lon >= -21600 && lon <= +21600);
89}
90
91bool Pn2Runner::importPolygon(QDataStream& stream, GeoDataLineString* linestring, quint32 nrAbsoluteNodes)
92{
93 qint16 lat, lon, nrRelativeNodes;
94 qint8 relativeLat, relativeLon;
95 bool error = false;
96
97
98 for (quint32 absoluteNode = 1; absoluteNode <= nrAbsoluteNodes; absoluteNode++)
99 {
100 stream >> lat >> lon >> nrRelativeNodes;
101
102 error = error | errorCheckLat(lat) | errorCheckLon(lon);
103
104 qreal degLat = (1.0 * lat / 120.0);
105 qreal degLon = (1.0 * lon / 120.0);
106
107 GeoDataCoordinates coord(degLon / 180 * M_PI3.14159265358979323846, degLat / 180 * M_PI3.14159265358979323846);
108 linestring->append(coord);
109
110 for (qint16 relativeNode = 1; relativeNode <= nrRelativeNodes; ++relativeNode)
111 {
112 stream >> relativeLat >> relativeLon;
113
114 qint16 currLat = relativeLat + lat;
115 qint16 currLon = relativeLon + lon;
116
117
118 error = error | errorCheckLat(currLat) | errorCheckLon(currLon);
119
120 qreal currDegLat = (1.0 * currLat / 120.0);
121 qreal currDegLon = (1.0 * currLon / 120.0);
122
123
124 GeoDataCoordinates currCoord(currDegLon / 180 * M_PI3.14159265358979323846, currDegLat / 180 * M_PI3.14159265358979323846);
125 linestring->append(currCoord);
126 }
127 }
128
129 *linestring = linestring->optimized();
130
131 return error;
132}
133
134GeoDataDocument* Pn2Runner::parseFile(const QString& fileName, DocumentRole role, QString& error)
135{
136 QFileInfo fileinfo(fileName);
137
138 if (fileinfo.suffix().compare(QLatin1String("pn2"), Qt::CaseInsensitive) != 0)
1
Assuming the condition is false
2
Taking false branch
139 {
140 error = QStringLiteral("File %1 does not have a pn2 suffix")(QString(QtPrivate::qMakeStringPrivate(u"" "File %1 does not have a pn2 suffix"
)))
.arg(fileName);
141 qCDebug(DIGIKAM_MARBLE_LOG)for (QLoggingCategoryMacroHolder<QtDebugMsg> qt_category
((DIGIKAM_MARBLE_LOG)()); qt_category; qt_category.control = false
) QMessageLogger(static_cast<const char *>("/home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/plugins/runner/pn2/Pn2Runner.cpp"
), 141, static_cast<const char *>(__PRETTY_FUNCTION__),
qt_category.name()).debug()
<< error;
142 return nullptr;
143 }
144
145 QFile file(fileName);
146
147 if (!file.exists())
3
Assuming the condition is false
4
Taking false branch
148 {
149 error = QStringLiteral("File %1 does not exist")(QString(QtPrivate::qMakeStringPrivate(u"" "File %1 does not exist"
)))
.arg(fileName);
150 qCDebug(DIGIKAM_MARBLE_LOG)for (QLoggingCategoryMacroHolder<QtDebugMsg> qt_category
((DIGIKAM_MARBLE_LOG)()); qt_category; qt_category.control = false
) QMessageLogger(static_cast<const char *>("/home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/plugins/runner/pn2/Pn2Runner.cpp"
), 150, static_cast<const char *>(__PRETTY_FUNCTION__),
qt_category.name()).debug()
<< error;
151 return nullptr;
152 }
153
154 file.open(QIODevice::ReadOnly);
155 m_stream.setDevice(&file); // read the data serialized from the file
156
157 m_stream >> m_fileHeaderVersion >> m_fileHeaderPolygons >> m_isMapColorField;
158
159 switch (m_fileHeaderVersion)
5
Control jumps to 'case 1:' at line 161
160 {
161 case 1:
162 return parseForVersion1(fileName, role);
6
Calling 'Pn2Runner::parseForVersion1'
163
164 case 2:
165 return parseForVersion2(fileName, role);
166
167 default:
168 qCDebug(DIGIKAM_MARBLE_LOG)for (QLoggingCategoryMacroHolder<QtDebugMsg> qt_category
((DIGIKAM_MARBLE_LOG)()); qt_category; qt_category.control = false
) QMessageLogger(static_cast<const char *>("/home/gilles/devel/GIT/8.x/core/utilities/geolocation/engine/plugins/runner/pn2/Pn2Runner.cpp"
), 168, static_cast<const char *>(__PRETTY_FUNCTION__),
qt_category.name()).debug()
<< "File can't be parsed. We don't have parser for file header version:" << m_fileHeaderVersion;
169 break;
170 }
171
172 return nullptr;
173}
174
175GeoDataDocument* Pn2Runner::parseForVersion1(const QString& fileName, DocumentRole role)
176{
177 GeoDataDocument* document = new GeoDataDocument();
178 document->setDocumentRole(role);
179
180 bool error = false;
181
182 quint32 ID, nrAbsoluteNodes;
183 quint8 flag, prevFlag = -1;
184
185 GeoDataStyle::Ptr style;
186 GeoDataPolygon* polygon = new GeoDataPolygon;
7
Memory is allocated
187
188 for (quint32 currentPoly = 1; (currentPoly <= m_fileHeaderPolygons) && (!error) && (!m_stream.atEnd()); currentPoly++)
8
Assuming 'currentPoly' is > field 'm_fileHeaderPolygons'
189 {
190
191 m_stream >> ID >> nrAbsoluteNodes >> flag;
192
193 if (flag != INNERBOUNDARY && (prevFlag == INNERBOUNDARY || prevFlag == OUTERBOUNDARY))
194 {
195
196 GeoDataPlacemark* placemark = new GeoDataPlacemark;
197 placemark->setGeometry(polygon);
198
199 if (m_isMapColorField)
200 {
201 if (style)
202 {
203 placemark->setStyle(style);
204 }
205 }
206
207 document->append(placemark);
208 }
209
210 if (flag == LINESTRING)
211 {
212 GeoDataLineString* linestring = new GeoDataLineString;
213 error = error | importPolygon(m_stream, linestring, nrAbsoluteNodes);
214
215 GeoDataPlacemark* placemark = new GeoDataPlacemark;
216 placemark->setGeometry(linestring);
217 document->append(placemark);
218 }
219
220 if ((flag == LINEARRING) || (flag == OUTERBOUNDARY) || (flag == INNERBOUNDARY))
221 {
222 if (flag == OUTERBOUNDARY && m_isMapColorField)
223 {
224 quint8 colorIndex;
225 m_stream >> colorIndex;
226 style = GeoDataStyle::Ptr(new GeoDataStyle);
227 GeoDataPolyStyle polyStyle;
228 polyStyle.setColorIndex(colorIndex);
229 style->setPolyStyle(polyStyle);
230 }
231
232 GeoDataLinearRing* linearring = new GeoDataLinearRing;
233 error = error | importPolygon(m_stream, linearring, nrAbsoluteNodes);
234
235 if (flag == LINEARRING)
236 {
237 GeoDataPlacemark* placemark = new GeoDataPlacemark;
238 placemark->setGeometry(linearring);
239 document->append(placemark);
240 }
241
242 if (flag == OUTERBOUNDARY)
243 {
244 polygon = new GeoDataPolygon;
245 polygon->setOuterBoundary(*linearring);
246 }
247
248 if (flag == INNERBOUNDARY)
249 {
250 polygon->appendInnerBoundary(*linearring);
251 }
252 }
253
254 if (flag == MULTIGEOMETRY)
255 {
256 // not implemented yet, for now elements inside a multigeometry are separated as individual geometries
257 }
258
259 prevFlag = flag;
260 }
261
262 if (prevFlag
8.1
'prevFlag' is not equal to INNERBOUNDARY
== INNERBOUNDARY || prevFlag
8.2
'prevFlag' is not equal to OUTERBOUNDARY
== OUTERBOUNDARY)
9
Taking false branch
263 {
264 GeoDataPlacemark* placemark = new GeoDataPlacemark;
265
266 if (m_isMapColorField)
267 {
268 if (style)
269 {
270 placemark->setStyle(style);
271 }
272 }
273
274 placemark->setGeometry(polygon);
275 document->append(placemark);
276 }
277
278 if (error)
10
Potential leak of memory pointed to by 'polygon'
279 {
280 delete document;
281 document = nullptr;
282 return nullptr;
283 }
284
285 document->setFileName(fileName);
286 return document;
287}
288
289GeoDataDocument* Pn2Runner::parseForVersion2(const QString& fileName, DocumentRole role)
290{
291 GeoDataDocument* document = new GeoDataDocument();
292 document->setDocumentRole(role);
293
294 bool error = false;
295
296 quint32 nrAbsoluteNodes;
297 quint32 placemarkCurrentID = 1;
298 quint32 placemarkPrevID = 0;
299 quint8 flag, prevFlag = -1;
300
301 GeoDataPolygon* polygon = new GeoDataPolygon;
302 GeoDataStyle::Ptr style;
303 GeoDataPlacemark* placemark = nullptr; // new GeoDataPlacemark;
304
305 quint32 currentPoly;
306
307 for (currentPoly = 1; (currentPoly <= m_fileHeaderPolygons) && (!error) && (!m_stream.atEnd()); currentPoly++)
308 {
309 m_stream >> flag >> placemarkCurrentID;
310
311 if (flag == MULTIGEOMETRY && (prevFlag == INNERBOUNDARY || prevFlag == OUTERBOUNDARY))
312 {
313 if (placemark)
314 {
315 placemark->setGeometry(polygon);
316 }
317 }
318
319 if (flag != MULTIGEOMETRY && flag != INNERBOUNDARY && (prevFlag == INNERBOUNDARY || prevFlag == OUTERBOUNDARY))
320 {
321 if (placemark)
322 {
323 placemark->setGeometry(polygon);
324 }
325 }
326
327 /**
328 * If the parsed placemark id @p placemarkCurrentID is different
329 * from the id of previous placemark @p placemarkPrevID, it means
330 * we have encountered a new placemark. So, prepare a style @p style
331 * if file has color indices
332 */
333 if (placemarkCurrentID != placemarkPrevID)
334 {
335 placemark = new GeoDataPlacemark;
336
337 // Handle the color index
338 if (m_isMapColorField)
339 {
340 quint8 colorIndex;
341 m_stream >> colorIndex;
342 style = GeoDataStyle::Ptr(new GeoDataStyle);
343 GeoDataPolyStyle polyStyle;
344 polyStyle.setColorIndex(colorIndex);
345 polyStyle.setFill(true);
346 style->setPolyStyle(polyStyle);
347 placemark->setStyle(style);
348 }
349
350 document->append(placemark);
351 }
352
353 placemarkPrevID = placemarkCurrentID;
354
355 if (flag != MULTIGEOMETRY)
356 {
357 m_stream >> nrAbsoluteNodes;
358
359 if (flag == LINESTRING)
360 {
361 GeoDataLineString* linestring = new GeoDataLineString;
362 error = error | importPolygon(m_stream, linestring, nrAbsoluteNodes);
363
364 if (placemark)
365 {
366 placemark->setGeometry(linestring);
367 }
368 }
369
370 if ((flag == LINEARRING) || (flag == OUTERBOUNDARY) || (flag == INNERBOUNDARY))
371 {
372 GeoDataLinearRing* linearring = new GeoDataLinearRing;
373 error = error || importPolygon(m_stream, linearring, nrAbsoluteNodes);
374
375 if (flag == LINEARRING)
376 {
377 if (placemark)
378 {
379 placemark->setGeometry(linearring);
380 }
381 }
382
383 else
384 {
385 if (flag == OUTERBOUNDARY)
386 {
387 polygon = new GeoDataPolygon;
388 polygon->setOuterBoundary(*linearring);
389 }
390
391 if (flag == INNERBOUNDARY)
392 {
393 polygon->appendInnerBoundary(*linearring);
394 }
395
396 delete linearring;
397 }
398 }
399
400 prevFlag = flag;
401 }
402
403 else
404 {
405 quint32 placemarkCurrentIDInMulti;
406 quint8 flagInMulti;
407 quint8 prevFlagInMulti = -1;
408 quint8 multiSize = 0;
409
410 m_stream >> multiSize;
411
412 GeoDataMultiGeometry* multigeom = new GeoDataMultiGeometry;
413
414 /**
415 * Read @p multiSize GeoDataGeometry objects
416 */
417 for (int iter = 0; iter < multiSize; ++iter)
418 {
419 m_stream >> flagInMulti >> placemarkCurrentIDInMulti >> nrAbsoluteNodes;
420
421 if (flagInMulti != INNERBOUNDARY && (prevFlagInMulti == INNERBOUNDARY || prevFlagInMulti == OUTERBOUNDARY))
422 {
423 multigeom->append(polygon);
424 }
425
426 if (flagInMulti == LINESTRING)
427 {
428 GeoDataLineString* linestring = new GeoDataLineString;
429 error = error || importPolygon(m_stream, linestring, nrAbsoluteNodes);
430 multigeom->append(linestring);
431 }
432
433 if ((flagInMulti == LINEARRING) || (flagInMulti == OUTERBOUNDARY) || (flagInMulti == INNERBOUNDARY))
434 {
435 GeoDataLinearRing* linearring = new GeoDataLinearRing;
436 error = error | importPolygon(m_stream, linearring, nrAbsoluteNodes);
437
438 if (flagInMulti == LINEARRING)
439 {
440 multigeom->append(linearring);
441 }
442
443 else
444 {
445 if (flagInMulti == OUTERBOUNDARY)
446 {
447 polygon = new GeoDataPolygon;
448 polygon->setOuterBoundary(*linearring);
449 }
450
451 if (flagInMulti == INNERBOUNDARY)
452 {
453 polygon->appendInnerBoundary(*linearring);
454 }
455
456 delete linearring;
457 }
458 }
459
460 prevFlagInMulti = flagInMulti;
461 }
462
463 if (prevFlagInMulti == INNERBOUNDARY || prevFlagInMulti == OUTERBOUNDARY)
464 {
465 multigeom->append(polygon);
466 }
467
468 if (placemark)
469 {
470 placemark->setGeometry(multigeom);
471 }
472
473 prevFlag = MULTIGEOMETRY;
474 }
475 }
476
477 if (
478 placemark &&
479 (prevFlag == INNERBOUNDARY || prevFlag == OUTERBOUNDARY) &&
480 (prevFlag != MULTIGEOMETRY)
481 )
482 {
483 placemark->setGeometry(polygon);
484 }
485
486 if (error)
487 {
488 delete document;
489 document = nullptr;
490 return nullptr;
491 }
492
493 document->setFileName(fileName);
494 return document;
495}
496
497} // namespace Marble
498
499#include "moc_Pn2Runner.cpp"