Commit b98f08d7 authored by Beat Küng's avatar Beat Küng
Browse files

AirMapManager: handle multi_polygon

parent 44a05ab6
...@@ -162,36 +162,21 @@ void AirMapRestrictionManager::setROI(const QGeoCoordinate& center, double radiu ...@@ -162,36 +162,21 @@ void AirMapRestrictionManager::setROI(const QGeoCoordinate& center, double radiu
if (result) { if (result) {
const std::vector<Airspace>& airspaces = result.value(); const std::vector<Airspace>& airspaces = result.value();
qCDebug(AirMapManagerLog)<<"Successful search: " << airspaces.size(); qCDebug(AirMapManagerLog)<<"Successful search. Items:" << airspaces.size();
for (const auto& airspace : airspaces) { for (const auto& airspace : airspaces) {
const Geometry& geometry = airspace.geometry(); const Geometry& geometry = airspace.geometry();
switch(geometry.type()) { switch(geometry.type()) {
case Geometry::Type::polygon: { case Geometry::Type::polygon: {
const Geometry::Polygon& polygon = geometry.details_for_polygon(); const Geometry::Polygon& polygon = geometry.details_for_polygon();
QVariantList polygonArray; _addPolygonToList(polygon, _polygonList);
if (polygon.size() == 1) {
for (const auto& vertex : polygon[0].coordinates) {
QGeoCoordinate coord;
if (vertex.altitude) {
coord = QGeoCoordinate(vertex.latitude, vertex.longitude, vertex.altitude.get());
} else {
coord = QGeoCoordinate(vertex.latitude, vertex.longitude);
}
polygonArray.append(QVariant::fromValue(coord));
}
_polygonList.append(new PolygonAirspaceRestriction(polygonArray));
} else {
// TODO: support that?
qWarning() << "Empty polygon, or Polygon with holes. Size: "<<polygon.size();
}
} }
break; break;
case Geometry::Type::multi_polygon: { case Geometry::Type::multi_polygon: {
const Geometry::MultiPolygon& multiPolygon = geometry.details_for_multi_polygon(); const Geometry::MultiPolygon& multiPolygon = geometry.details_for_multi_polygon();
qWarning() << "multi polygon "<<multiPolygon.size(); for (const auto& polygon : multiPolygon) {
// TODO _addPolygonToList(polygon, _polygonList);
}
} }
break; break;
case Geometry::Type::point: { case Geometry::Type::point: {
...@@ -220,6 +205,27 @@ void AirMapRestrictionManager::setROI(const QGeoCoordinate& center, double radiu ...@@ -220,6 +205,27 @@ void AirMapRestrictionManager::setROI(const QGeoCoordinate& center, double radiu
}); });
} }
void AirMapRestrictionManager::_addPolygonToList(const airmap::Geometry::Polygon& polygon, QList<PolygonAirspaceRestriction*>& list)
{
QVariantList polygonArray;
if (polygon.size() == 1) {
for (const auto& vertex : polygon[0].coordinates) {
QGeoCoordinate coord;
if (vertex.altitude) {
coord = QGeoCoordinate(vertex.latitude, vertex.longitude, vertex.altitude.get());
} else {
coord = QGeoCoordinate(vertex.latitude, vertex.longitude);
}
polygonArray.append(QVariant::fromValue(coord));
}
list.append(new PolygonAirspaceRestriction(polygonArray));
} else {
// TODO: support that?
qWarning() << "Empty polygon, or Polygon with holes. Size: "<<polygon.size();
}
}
AirMapFlightManager::AirMapFlightManager(AirMapSharedState& shared) AirMapFlightManager::AirMapFlightManager(AirMapSharedState& shared)
: _shared(shared) : _shared(shared)
{ {
......
...@@ -109,6 +109,8 @@ signals: ...@@ -109,6 +109,8 @@ signals:
private: private:
static void _addPolygonToList(const airmap::Geometry::Polygon& polygon, QList<PolygonAirspaceRestriction*>& list);
enum class State { enum class State {
Idle, Idle,
RetrieveItems, RetrieveItems,
......
Supports Markdown
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