summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2021-10-28 11:58:38 +0200
committerIvan Solovev <ivan.solovev@qt.io>2021-11-09 10:28:28 +0100
commit95c9e14357857797c4f4997d40c9df7965e9af5d (patch)
tree57225b32b9b248670c997324e0e5cc42b46b9600
parent63d7300e48f86ee01651bbea6d86b1f129258fdc (diff)
downloadqtlocation-95c9e14357857797c4f4997d40c9df7965e9af5d.tar.gz
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 <alexander.blasche@qt.io>
-rw-r--r--src/location/labs/qgeojson.cpp5
1 files 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);