File tree Expand file tree Collapse file tree 2 files changed +24
-11
lines changed Expand file tree Collapse file tree 2 files changed +24
-11
lines changed Original file line number Diff line number Diff line change
1
+ #include " sensesp/types/position.h"
2
+
3
+ #include < ArduinoJson.h>
4
+
5
+ namespace sensesp {
6
+
7
+ void convertFromJson (JsonVariantConst src, Position &dst) {
8
+ dst.longitude = src[" longitude" ].as <double >();
9
+ dst.latitude = src[" latitude" ].as <double >();
10
+
11
+ if (src.containsKey (" altitude" )) {
12
+ dst.altitude = src[" altitude" ].as <float >();
13
+ }
14
+ }
15
+
16
+ bool canConvertFromJson (JsonVariantConst src, const Position &) {
17
+ return src.containsKey (" latitude" ) && src.containsKey (" longitude" );
18
+ }
19
+
20
+
21
+ } // namespace sensesp
Original file line number Diff line number Diff line change 1
1
#ifndef SENSESP_TYPES_POSITION_H_
2
2
#define SENSESP_TYPES_POSITION_H_
3
3
4
+ #include < ArduinoJson.h>
4
5
#include < limits>
5
6
6
7
namespace sensesp {
@@ -46,14 +47,7 @@ struct ENUVector {
46
47
* @param src The JSON document containing the position data
47
48
* @param dst The address to a Position struct to write the data to
48
49
*/
49
- void convertFromJson (JsonVariantConst src, Position &dst) {
50
- dst.longitude = src[" longitude" ].as <double >();
51
- dst.latitude = src[" latitude" ].as <double >();
52
-
53
- if (src.containsKey (" altitude" )) {
54
- dst.altitude = src[" altitude" ].as <float >();
55
- }
56
- }
50
+ void convertFromJson (JsonVariantConst src, Position &dst);
57
51
58
52
/* *
59
53
* @brief Tells ArduinoJson whether the given JSON is a Position or not
@@ -66,9 +60,7 @@ void convertFromJson(JsonVariantConst src, Position &dst) {
66
60
* @return false if the given JSON doesn't contain "latitude" or "longitude"
67
61
* keys
68
62
*/
69
- bool canConvertFromJson (JsonVariantConst src, const Position &) {
70
- return src.containsKey (" latitude" ) && src.containsKey (" longitude" );
71
- }
63
+ bool canConvertFromJson (JsonVariantConst src, const Position &);
72
64
73
65
} // namespace sensesp
74
66
You can’t perform that action at this time.
0 commit comments