Skip to content

Commit

Permalink
Add LineString as a Feature if it is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
rinigus committed Oct 30, 2022
1 parent 21e647e commit d779691
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/qquickitemmapboxgl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,17 @@ void QQuickItemMapboxGL::updateSourceLine(const QString &sourceID, const QVarian
{
QVariantList coor;

// Mapbox geojson-hpp requires at least 2 points for a line. As a result, source addition or update
// will fail unless it is imported as an empty feature - done by the point import.
// Related issue: https://github.com/rinigus/pure-maps/issues/639
if (coordinates.size() < 2)
{
QVariantList names;
for (int i=0; i < coordinates.size(); ++i) names.append(name);
updateSourcePoints(sourceID, coordinates, names);
return;
}

for (int i = 0; i < coordinates.size(); ++i)
{
QGeoCoordinate c = coordinates[i].value<QGeoCoordinate>();
Expand Down

0 comments on commit d779691

Please sign in to comment.