Commit 6424c2b1 authored by Torsten Rahn's avatar Torsten Rahn
Browse files

Add toVariantList-function to GeoDataLineString.

parent 8957fd69
......@@ -881,6 +881,30 @@ GeoDataLineString GeoDataLineString::optimized () const
}
}
QVariantList GeoDataLineString::toVariantList() const
{
Q_D(const GeoDataLineString);
QVariantList variantList;
for( const GeoDataCoordinates & itCoords : d->m_vector ) {
QVariantMap map;
map.insert("lon", itCoords.longitude(GeoDataCoordinates::Degree));
map.insert("lat", itCoords.latitude(GeoDataCoordinates::Degree));
map.insert("alt", itCoords.altitude());
variantList << map;
}
if (isClosed()) {
QVariantMap map;
map.insert("lon", d->m_vector.first().longitude(GeoDataCoordinates::Degree));
map.insert("lat", d->m_vector.first().latitude(GeoDataCoordinates::Degree));
map.insert("alt", d->m_vector.first().altitude());
variantList << map;
}
return variantList;
}
void GeoDataLineString::pack( QDataStream& stream ) const
{
Q_D(const GeoDataLineString);
......
......@@ -384,6 +384,11 @@ class GEODATA_EXPORT GeoDataLineString : public GeoDataGeometry
*/
GeoDataLineString optimized() const;
/*!
\brief Returns a javascript-style list (that can be used e.g. with the QML GeoPolyline element).
*/
QVariantList toVariantList() const;
// Serialization
/*!
\brief Serialize the LineString to a stream.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment