Commit a0c951cb authored by Valentin Platzgummer's avatar Valentin Platzgummer

234

parent 0510d157
This diff is collapsed.
This diff is collapsed.
#pragma once
#include "QScopedPointer"
#include <QObject>
#include <QTimer>
#include "WimaArea.h"
......@@ -14,14 +14,25 @@ public:
WimaMeasurementArea(const WimaMeasurementArea &other,
QObject *parent = nullptr);
WimaMeasurementArea &operator=(const WimaMeasurementArea &other);
~WimaMeasurementArea();
Q_PROPERTY(Fact *borderPolygonOffset READ borderPolygonOffsetFact CONSTANT)
Q_PROPERTY(Fact *tileHeight READ tileHeight CONSTANT)
Q_PROPERTY(Fact *tileWidth READ tileWidth CONSTANT)
Q_PROPERTY(Fact *minTileArea READ minTileArea CONSTANT)
Q_PROPERTY(Fact *transectDistance READ transectDistance CONSTANT)
Q_PROPERTY(Fact *minTransectLength READ minTransectLength CONSTANT)
Q_PROPERTY(Fact *showTiles READ showTiles CONSTANT)
// Overrides from WimaPolygon
QString mapVisualQML(void) const {
return "WimaMeasurementAreaMapVisual.qml";
}
QString editorQML(void) const { return "WimaMeasurementAreaEditor.qml"; }
QString mapVisualQML(void) const;
QString editorQML(void) const;
Fact *tileHeight();
Fact *tileWidth();
Fact *minTileArea();
Fact *transectDistance();
Fact *minTransectLength();
Fact *showTiles();
// Member Methodes
void saveToJson(QJsonObject &json);
......@@ -36,14 +47,19 @@ public:
static const char *tileHeightName;
static const char *tileWidthName;
static const char *minTileAreaName;
static const char *transcetDistanceName;
static const char *minTransectLength;
static const char *transectDistanceName;
static const char *minTransectLengthName;
static const char *showTilesName;
static const char *WimaMeasurementAreaName;
signals:
public slots:
private slots:
void doUpdate();
void deferUpdate();
private:
// Member Methodes
void init();
......@@ -51,9 +67,15 @@ private:
// Members
QMap<QString, FactMetaData *> _metaDataMap;
SettingsFact _tileWidth;
SettingsFact _tileHeight;
SettingsFact _tileWidth;
SettingsFact _minTileArea;
SettingsFact _transectDistance;
SettingsFact _minTransectLength;
SettingsFact _showTiles;
// Tile stuff.
QTimer _timer;
std::atomic_bool _calculating;
QmlObjectListModel _tiles;
};
[
{
"name": "BottomLayerAltitude",
"shortDescription": "The distance between the terrain and the first layer of the measurement path.",
"name": "TileHeight",
"shortDescription": "The height of a tile",
"type": "double",
"units": "m",
"min": 1,
"min": 0.3,
"decimalPlaces": 2,
"defaultValue": 5
},
{
"name": "NumberOfLayers",
"shortDescription": "The number of layers.",
"type": "uint32",
"name": "TileWidth",
"shortDescription": "The height of a tile",
"type": "double",
"units": "m",
"min": 1,
"decimalPlaces": 0,
"defaultValue": 1
"min": 0.3,
"decimalPlaces": 2,
"defaultValue": 5
},
{
"name": "LayerDistance",
"shortDescription": "Specify the time between each photo",
"name": "MinTileArea",
"shortDescription": "The minimal allowed area of a tile",
"type": "double",
"units": "m^2",
"min": 0,
"decimalPlaces": 2,
"defaultValue": 5
},
{
"name": "TransectDistance",
"shortDescription": "The transect distance",
"type": "double",
"units": "m",
"min": 0.3,
"decimalPlaces": 2,
"defaultValue": 2
},
{
"name": "MinTransectLength",
"shortDescription": "The minimal transect length",
"type": "double",
"units": "m",
"min": 0,
"decimalPlaces": 2,
"defaultValue": 1
},
{
"name": "ShowTiles",
"shortDescription": "Show tiles",
"type": "bool",
"defaultValue": true
},
{
"name": "BorderPolygonOffset",
"shortDescription": "The distance between the measurement area and it's enclosing polygon",
......
This diff is collapsed.
#include "SnakeTile.h"
SnakeTile::SnakeTile() : WimaAreaData() {}
SnakeTile::SnakeTile(QObject *parent) : WimaAreaData(parent) {}
SnakeTile::SnakeTile(const SnakeTile &other, QObject *parent)
: WimaAreaData(parent) {
......
......@@ -4,7 +4,7 @@
class SnakeTile : public WimaAreaData {
public:
SnakeTile();
SnakeTile(QObject *parent = nullptr);
SnakeTile(const SnakeTile &other, QObject *parent = nullptr);
QString type() const { return "Tile"; }
......
This diff is collapsed.
......@@ -103,6 +103,7 @@ void toENU(const GeoPoint &origin, const GeoPoint &in, BoostPoint &out) {
out.set<1>(y);
(void)z;
}
template <class GeoPoint>
void fromENU(const GeoPoint &origin, const BoostPoint &in, GeoPoint &out) {
GeographicLib::Geocentric earth(GeographicLib::Constants::WGS84_a(),
......@@ -117,88 +118,6 @@ void fromENU(const GeoPoint &origin, const BoostPoint &in, GeoPoint &out) {
out.setAltitude(alt);
}
void polygonCenter(const BoostPolygon &polygon, BoostPoint &center);
bool minimalBoundingBox(const BoostPolygon &polygon, BoundingBox &minBBox);
void offsetPolygon(const BoostPolygon &polygon, BoostPolygon &polygonOffset,
double offset);
void graphFromPolygon(const BoostPolygon &polygon,
const BoostLineString &vertices, Matrix<double> &graph);
void toDistanceMatrix(Matrix<double> &graph);
bool dijkstraAlgorithm(
const size_t numElements, size_t startIndex, size_t endIndex,
std::vector<size_t> &elementPath,
std::function<double(const size_t, const size_t)> distanceDij);
void shortestPathFromGraph(const Matrix<double> &graph, size_t startIndex,
size_t endIndex, std::vector<size_t> &pathIdx);
//=========================================================================
// Scenario.
//=========================================================================
typedef bu::quantity<bu::si::length> Length;
typedef bu::quantity<bu::si::area> Area;
typedef bu::quantity<bu::si::plane_angle> Angle;
class Scenario {
public:
Scenario();
void setMeasurementArea(const BoostPolygon &area);
void setServiceArea(const BoostPolygon &area);
void setCorridor(const BoostPolygon &area);
const BoundingBox &mAreaBoundingBox() const;
const BoostPolygon &measurementArea() const;
const BoostPolygon &serviceArea() const;
const BoostPolygon &corridor() const;
BoostPolygon &measurementArea();
BoostPolygon &serviceArea();
BoostPolygon &corridor();
Length tileWidth() const;
void setTileWidth(Length tileWidth);
Length tileHeight() const;
void setTileHeight(Length tileHeight);
Area minTileArea() const;
void setMinTileArea(Area minTileArea);
const BoostPolygon &joinedArea() const;
const vector<BoostPolygon> &tiles() const;
const BoostLineString &tileCenterPoints() const;
const BoundingBox &measurementAreaBBox() const;
const BoostPoint &homePositon() const;
bool update();
mutable string errorString;
private:
bool _calculateBoundingBox() const;
bool _calculateTiles() const;
bool _calculateJoinedArea() const;
Length _tileWidth;
Length _tileHeight;
Area _minTileArea;
mutable bool _needsUpdate;
BoostPolygon _mArea;
BoostPolygon _sArea;
BoostPolygon _corridor;
mutable BoostPolygon _jArea;
mutable BoundingBox _mAreaBoundingBox;
mutable vector<BoostPolygon> _tiles;
mutable BoostLineString _tileCenterPoints;
mutable BoostPoint _homePosition;
};
template <class GeoPoint, template <class, class...> class Container>
void areaToEnu(const GeoPoint &origin, const Container<GeoPoint> &in,
BoostPolygon &out) {
......@@ -220,25 +139,43 @@ void areaFromEnu(const GeoPoint &origin, BoostPolygon &in,
}
}
bool joinAreas(const std::vector<BoostPolygon> &areas,
BoostPolygon &joinedArea);
void polygonCenter(const BoostPolygon &polygon, BoostPoint &center);
bool minimalBoundingBox(const BoostPolygon &polygon, BoundingBox &minBBox);
void offsetPolygon(const BoostPolygon &polygon, BoostPolygon &polygonOffset,
double offset);
void graphFromPolygon(const BoostPolygon &polygon,
const BoostLineString &vertices, Matrix<double> &graph);
void toDistanceMatrix(Matrix<double> &graph);
bool dijkstraAlgorithm(
const size_t numElements, size_t startIndex, size_t endIndex,
std::vector<size_t> &elementPath,
std::function<double(const size_t, const size_t)> distanceDij);
void shortestPathFromGraph(const Matrix<double> &graph, size_t startIndex,
size_t endIndex, std::vector<size_t> &pathIdx);
//========================================================================================
// flight_plan
//========================================================================================
typedef bu::quantity<bu::si::length> Length;
typedef bu::quantity<bu::si::area> Area;
typedef bu::quantity<bu::si::plane_angle> Angle;
namespace flight_plan {
bool joinedArea(const std::vector<BoostPolygon *> &areas, BoostPolygon &jArea);
bool joinedArea(const BoostPolygon &mArea, const BoostPolygon &sArea,
const BoostPolygon &corridor, BoostPolygon &jArea,
std::string &errorString);
bool tiles(const BoostPolygon &area, Length tileHeight, Length tileWidth,
Area minTileArea, std::vector<BoostPolygon> &tiles,
BoundingBox &bbox, std::string &errorString);
using Transects = vector<BoostLineString>;
using Progress = vector<int>;
using Route = vector<BoostPoint>;
bool transectsFromScenario(Length distance, Length minLength, Angle angle,
const Scenario &scenario, const Progress &p,
Transects &t, string &errorString);
const BoostPolygon &mArea,
const std::vector<BoostPolygon> &tiles,
const Progress &p, Transects &t,
string &errorString);
bool route(const BoostPolygon &area, const Transects &transects,
Transects &transectsRouted, Route &route, string &errorString);
} // namespace flight_plan
namespace detail {
const double offsetConstant =
......
......@@ -43,7 +43,7 @@ Rectangle {
SectionHeader {
id: settingsHeader
text: qsTr("Settings")
text: qsTr("General")
}
Column {
......@@ -79,12 +79,18 @@ Rectangle {
}
} // Column - Settings
SectionHeader {
id: snakeHeader
text: qsTr("Snake")
id: tilesHeader
text: qsTr("Tiles")
}
Column {
anchors.left: parent.left
anchors.right: parent.right
spacing: _margin
visible: tilesHeader.checked
GridLayout {
anchors.left: parent.left
anchors.right: parent.right
......@@ -92,44 +98,69 @@ Rectangle {
rowSpacing: _margin
columns: 2
QGCLabel { text: qsTr("Tile Height") }
QGCLabel { text: qsTr("Height") }
FactTextField {
//fact: areaItem.borderPolygonOffset
fact: areaItem.tileHeight
Layout.fillWidth: true
}
QGCLabel { text: qsTr("Tile Width") }
QGCLabel { text: qsTr("Width") }
FactTextField {
//fact: areaItem.borderPolygonOffset
fact: areaItem.tileWidth
Layout.fillWidth: true
}
QGCLabel { text: qsTr("Min. Tile Area") }
QGCLabel { text: qsTr("Min. Area") }
FactTextField {
//fact: areaItem.borderPolygonOffset
fact: areaItem.minTileArea
Layout.fillWidth: true
}
QGCLabel { text: qsTr("Transect Distance") }
FactCheckBox {
text: qsTr("Show Tiles")
fact: areaItem.showTiles
}
} // Tile GridLayout
} // Tile Column
SectionHeader {
id: transectsHeader
text: qsTr("Transects")
}
Column {
anchors.left: parent.left
anchors.right: parent.right
spacing: _margin
visible: transectsHeader.checked
GridLayout {
anchors.left: parent.left
anchors.right: parent.right
columnSpacing: _margin
rowSpacing: _margin
columns: 2
QGCLabel { text: qsTr("Distance") }
FactTextField {
//fact: areaItem.borderPolygonOffset
fact: areaItem.transectDistance
Layout.fillWidth: true
}
QGCLabel { text: qsTr("Min. Transect Length") }
QGCLabel { text: qsTr("Min. Length") }
FactTextField {
//fact: areaItem.borderPolygonOffset
fact: areaItem.minTransectLength
Layout.fillWidth: true
}
}
} // Transects GridLayout
} // Transects Column
} // Snake
SectionHeader {
id: statsHeader
......
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