From 95c9e14357857797c4f4997d40c9df7965e9af5d Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Thu, 28 Oct 2021 11:58:38 +0200 Subject: Fix QGeoJson import/export The qgeojson test was actually failing. The following fixes to the class were done: - Improved check for invalid QVariant when importing 'bbox' object - Handle the fact that 'id' field is optional in the 'Feature' object Task-number: QTBUG-97769 Task-number: QTBUG-96795 Change-Id: I99696fc90b02f5deb5c438cf7ae93fcefd08882e Reviewed-by: Alex Blasche --- src/location/labs/qgeojson.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/location/labs/qgeojson.cpp b/src/location/labs/qgeojson.cpp index 7d609a75..163a140f 100644 --- a/src/location/labs/qgeojson.cpp +++ b/src/location/labs/qgeojson.cpp @@ -931,7 +931,8 @@ static QJsonObject exportFeature(const QVariantMap &featureMap) exportedFeature.insert(QStringLiteral("type"), QJsonValue(QStringLiteral("Feature"))); exportedFeature.insert(QStringLiteral("geometry"), geometryNodeValue); exportedFeature.insert(QStringLiteral("properties"), propertiesNodeValue); - exportedFeature.insert(QStringLiteral("id"), idNodeValue); + if (!idNodeValue.isNull()) // this value is optional + exportedFeature.insert(QStringLiteral("id"), idNodeValue); return exportedFeature; } @@ -1071,7 +1072,7 @@ QVariantList QGeoJson::importGeoJson(const QJsonDocument &geoJson) break; } QVariant bboxNodeValue = rootGeoJsonObject.value(QStringLiteral("bbox")); - if (bboxNodeValue != QVariant::Invalid) { + if (bboxNodeValue.isValid()) { parsedGeoJsonMap.insert(QStringLiteral("bbox"), bboxNodeValue); } returnedList.append(parsedGeoJsonMap); -- cgit v1.2.3