mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-23 00:02:38 -05:00
[sensorthings] Observation phenomenonTime can be a time instant
According to the specifications, an Observation phenomenonTime can either be a period OR a time instant. Correctly handle instants instead of returning null for the phenomenonTime
This commit is contained in:
parent
02562d7b91
commit
2ad9065bea
@ -527,7 +527,7 @@ bool QgsSensorThingsSharedData::processFeatureRequest( QString &nextPage, QgsFee
|
||||
return QVariant();
|
||||
};
|
||||
|
||||
auto getDateTimeRange = []( const basic_json<> &json, const char *tag ) -> std::pair< QVariant, QVariant >
|
||||
auto getDateTimeRange = []( const basic_json<> &json, const char *tag, bool allowInstant = false ) -> std::pair< QVariant, QVariant >
|
||||
{
|
||||
if ( !json.contains( tag ) )
|
||||
return { QVariant(), QVariant() };
|
||||
@ -545,6 +545,11 @@ bool QgsSensorThingsSharedData::processFeatureRequest( QString &nextPage, QgsFee
|
||||
QDateTime::fromString( rangeParts.at( 1 ), Qt::ISODateWithMs )
|
||||
};
|
||||
}
|
||||
else if ( allowInstant )
|
||||
{
|
||||
const QDateTime instant = QDateTime::fromString( rangeString, Qt::ISODateWithMs );
|
||||
return { instant, instant };
|
||||
}
|
||||
}
|
||||
|
||||
return { QVariant(), QVariant() };
|
||||
@ -650,7 +655,7 @@ bool QgsSensorThingsSharedData::processFeatureRequest( QString &nextPage, QgsFee
|
||||
|
||||
case Qgis::SensorThingsEntity::Observation:
|
||||
{
|
||||
std::pair< QVariant, QVariant > phenomenonTime = getDateTimeRange( featureData, "phenomenonTime" );
|
||||
std::pair< QVariant, QVariant > phenomenonTime = getDateTimeRange( featureData, "phenomenonTime", true );
|
||||
std::pair< QVariant, QVariant > validTime = getDateTimeRange( featureData, "validTime" );
|
||||
feature.setAttributes(
|
||||
QgsAttributes()
|
||||
|
Loading…
x
Reference in New Issue
Block a user