Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
44b635f9
Commit
44b635f9
authored
Jan 29, 2021
by
Valentin Platzgummer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
error removed: max_tiles yielded wrong error messages
parent
558239cf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
52 deletions
+51
-52
MeasurementArea.cc
src/MeasurementComplexItem/geometry/MeasurementArea.cc
+50
-33
MeasurementArea.h
src/MeasurementComplexItem/geometry/MeasurementArea.h
+1
-19
No files found.
src/MeasurementComplexItem/geometry/MeasurementArea.cc
View file @
44b635f9
...
...
@@ -41,6 +41,7 @@ const char *tileWidthName = "TileWidth";
const
char
*
minTileAreaKey
=
"MinTileAreaPercent"
;
const
char
*
showTilesKey
=
"ShowTiles"
;
const
char
*
tileKey
=
"Tiles"
;
const
char
*
toManyTilesKey
=
"ToManyTiles"
;
const
char
*
MeasurementArea
::
nameString
=
"Measurement Area"
;
MeasurementArea
::
MeasurementArea
(
QObject
*
parent
)
...
...
@@ -57,7 +58,8 @@ MeasurementArea::MeasurementArea(QObject *parent)
this
/* QObject parent */
)),
_showTiles
(
SettingsFact
(
settingsGroup
,
_metaDataMap
[
showTilesKey
],
this
/* QObject parent */
)),
_tiles
(
new
QmlObjectListModel
()),
_state
(
STATE
::
IDLE
)
{
_toManyTiles
(
false
),
_tiles
(
new
QmlObjectListModel
()),
_state
(
STATE
::
IDLE
)
{
init
();
}
...
...
@@ -75,7 +77,8 @@ MeasurementArea::MeasurementArea(const MeasurementArea &other, QObject *parent)
this
/* QObject parent */
)),
_showTiles
(
SettingsFact
(
settingsGroup
,
_metaDataMap
[
showTilesKey
],
this
/* QObject parent */
)),
_tiles
(
new
QmlObjectListModel
()),
_state
(
STATE
::
IDLE
)
{
_toManyTiles
(
other
.
_toManyTiles
),
_tiles
(
new
QmlObjectListModel
()),
_state
(
STATE
::
IDLE
)
{
init
();
disableUpdate
();
...
...
@@ -115,6 +118,7 @@ MeasurementArea &MeasurementArea::operator=(const MeasurementArea &other) {
->
clone
(
_tiles
.
get
()));
}
_indexMap
=
other
.
_indexMap
;
_toManyTiles
=
other
.
_toManyTiles
;
enableUpdate
();
}
else
{
enableUpdate
();
...
...
@@ -178,6 +182,7 @@ bool MeasurementArea::saveToJson(QJsonObject &json) {
json
[
minTileAreaKey
]
=
_minTileAreaPercent
.
rawValue
().
toDouble
();
json
[
showTilesKey
]
=
_showTiles
.
rawValue
().
toBool
();
json
[
areaTypeKey
]
=
nameString
;
json
[
toManyTilesKey
]
=
_toManyTiles
;
// save tiles
QJsonArray
jsonTileArray
;
...
...
@@ -253,40 +258,46 @@ bool MeasurementArea::loadFromJson(const QJsonObject &json,
break
;
}
}
}
if
(
!
tileError
)
{
this
->
_indexMap
.
clear
();
for
(
int
i
=
0
;
i
<
_tiles
->
count
();
++
i
)
{
auto
tile
=
qobject_cast
<
MeasurementTile
*>
(
_tiles
->
get
(
i
));
auto
it
=
_indexMap
.
find
(
tile
->
id
());
// find unique id
if
(
it
!=
_indexMap
.
end
())
{
auto
newId
=
MeasurementTile
::
randomId
();
constexpr
long
counterMax
=
1e6
;
unsigned
long
counter
=
0
;
for
(;
counter
<=
counterMax
;
++
counter
)
{
it
=
_indexMap
.
find
(
newId
);
if
(
it
==
_indexMap
.
end
())
{
break
;
}
else
{
newId
=
MeasurementTile
::
randomId
();
}
}
if
(
json
.
contains
(
toManyTilesKey
)
&&
json
[
toManyTilesKey
].
isBool
())
{
_toManyTiles
=
json
[
toManyTilesKey
].
toBool
();
}
else
{
tileError
=
true
;
}
if
(
!
tileError
)
{
this
->
_indexMap
.
clear
();
for
(
int
i
=
0
;
i
<
_tiles
->
count
();
++
i
)
{
if
(
counter
!=
counterMax
)
{
tile
->
setId
(
newId
);
tile
->
setProgress
(
0.0
);
auto
tile
=
qobject_cast
<
MeasurementTile
*>
(
_tiles
->
get
(
i
));
auto
it
=
_indexMap
.
find
(
tile
->
id
());
// find unique id
if
(
it
!=
_indexMap
.
end
())
{
auto
newId
=
MeasurementTile
::
randomId
();
constexpr
long
counterMax
=
1e6
;
unsigned
long
counter
=
0
;
for
(;
counter
<=
counterMax
;
++
counter
)
{
it
=
_indexMap
.
find
(
newId
);
if
(
it
==
_indexMap
.
end
())
{
break
;
}
else
{
qCritical
()
<<
"MeasurementArea::storeTiles(): not able to find "
"unique id!"
;
continue
;
newId
=
MeasurementTile
::
randomId
();
}
}
_indexMap
.
insert
(
std
::
make_pair
(
tile
->
id
(),
i
));
if
(
counter
!=
counterMax
)
{
tile
->
setId
(
newId
);
tile
->
setProgress
(
0.0
);
}
else
{
qCritical
()
<<
"MeasurementArea::storeTiles(): not able to find "
"unique id!"
;
continue
;
}
}
_indexMap
.
insert
(
std
::
make_pair
(
tile
->
id
(),
i
));
}
}
else
{
qCWarning
(
MeasurementAreaLog
)
...
...
@@ -314,11 +325,15 @@ bool MeasurementArea::isCorrect() {
if
(
GeoArea
::
isCorrect
())
{
if
(
ready
())
{
return
true
;
}
else
{
}
else
if
(
_toManyTiles
)
{
setErrorString
(
tr
(
"Calculation would yield to many tiles, please adjust the tile "
"parameters to reduce the number of tiles."
));
}
else
setErrorString
(
tr
(
"Measurement Area tile calculation in progess. Please wait."
));
}
}
return
false
;
}
...
...
@@ -406,8 +421,10 @@ void MeasurementArea::doUpdate() {
const
auto
totalArea
=
this
->
area
()
*
si
::
meter
*
si
::
meter
;
const
auto
estNumTiles
=
totalArea
/
tileArea
;
// Check some conditions.
if
(
long
(
std
::
ceil
(
estNumTiles
.
value
()))
<=
MAX_TILES
&&
this
->
GeoArea
::
isCorrect
())
{
if
(
long
(
std
::
ceil
(
estNumTiles
.
value
()))
>=
MAX_TILES
)
{
_toManyTiles
=
true
;
}
else
if
(
this
->
GeoArea
::
isCorrect
())
{
_toManyTiles
=
false
;
setState
(
STATE
::
UPDATEING
);
auto
polygon
=
this
->
coordinateList
();
...
...
src/MeasurementComplexItem/geometry/MeasurementArea.h
View file @
44b635f9
...
...
@@ -12,25 +12,6 @@
#include "SettingsFact.h"
class
TileData
:
public
QObject
{
public:
TileData
();
~
TileData
();
TileData
&
operator
=
(
const
TileData
&
other
);
bool
operator
==
(
const
TileData
&
other
)
const
;
bool
operator
!=
(
const
TileData
&
other
)
const
;
void
saveToJson
(
QJsonObject
&
json
);
bool
loadFromJson
(
const
QJsonObject
&
json
,
QString
&
errorString
);
void
clear
();
std
::
size_t
size
()
const
;
QmlObjectListModel
tiles
;
QVariantList
tileCenterPoints
;
};
class
MeasurementArea
:
public
GeoArea
{
Q_OBJECT
enum
class
STATE
{
IDLE
,
DEFERED
,
UPDATEING
,
RESTARTING
,
STOP
};
...
...
@@ -106,6 +87,7 @@ private:
SettingsFact
_showTiles
;
// Tile stuff.
bool
_toManyTiles
;
TilePtr
_tiles
;
std
::
map
<
QString
/*id*/
,
int
>
_indexMap
;
QTimer
_timer
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment