Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
e27ab01d
Commit
e27ab01d
authored
Feb 23, 2016
by
Don Gagne
Browse files
Better coordinate validation
parent
802ffa2a
Changes
1
Show whitespace changes
Inline
Side-by-side
src/JsonHelper.cc
View file @
e27ab01d
...
...
@@ -58,10 +58,17 @@ bool JsonHelper::toQGeoCoordinate(const QJsonValue& jsonValue, QGeoCoordinate& c
QJsonArray
coordinateArray
=
jsonValue
.
toArray
();
int
requiredCount
=
altitudeRequired
?
3
:
2
;
if
(
coordinateArray
.
count
()
!=
requiredCount
)
{
errorString
=
QString
(
"
Json
array must contain
s
%1 values"
).
arg
(
requiredCount
);
errorString
=
QString
(
"
Coordinate
array must contain %1 values"
).
arg
(
requiredCount
);
return
false
;
}
foreach
(
const
QJsonValue
&
jsonValue
,
coordinateArray
)
{
if
(
jsonValue
.
type
()
!=
QJsonValue
::
Double
)
{
errorString
=
QString
(
"Coordinate array may only contain double values, found: %1"
).
arg
(
jsonValue
.
type
());
return
false
;
}
}
coordinate
=
QGeoCoordinate
(
coordinateArray
[
0
].
toDouble
(),
coordinateArray
[
1
].
toDouble
());
if
(
altitudeRequired
)
{
coordinate
.
setAltitude
(
coordinateArray
[
2
].
toDouble
());
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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