tgbotxx 1.1.6.9
Telegram Bot C++ Library
Loading...
Searching...
No Matches
Location.hpp
Go to the documentation of this file.
1#pragma once
3
4namespace tgbotxx {
7 struct Location {
8 Location() = default;
9 explicit Location(const nl::json& json) {
10 fromJson(json);
11 }
12
14 float longitude{};
15
17 float latitude{};
18
21
24 std::int32_t livePeriod{};
25
28 std::int32_t heading{};
29
30
33 std::int32_t proximityAlertRadius{};
34
37 nl::json toJson() const {
38 nl::json json = nl::json::object();
39 OBJECT_SERIALIZE_FIELD(json, "longitude", longitude);
40 OBJECT_SERIALIZE_FIELD(json, "latitude", latitude);
41 OBJECT_SERIALIZE_FIELD(json, "horizontal_accuracy", horizontalAccuracy);
42 OBJECT_SERIALIZE_FIELD(json, "live_period", livePeriod);
43 OBJECT_SERIALIZE_FIELD(json, "heading", heading);
44 OBJECT_SERIALIZE_FIELD(json, "proximity_alert_radius", proximityAlertRadius);
45 return json;
46 }
47
49 void fromJson(const nl::json& json) {
50 OBJECT_DESERIALIZE_FIELD(json, "longitude", longitude, 0.0f, false);
51 OBJECT_DESERIALIZE_FIELD(json, "latitude", latitude, 0.0f, false);
52 OBJECT_DESERIALIZE_FIELD(json, "horizontal_accuracy", horizontalAccuracy, 0.0f, true);
53 OBJECT_DESERIALIZE_FIELD(json, "live_period", livePeriod, 0, true);
54 OBJECT_DESERIALIZE_FIELD(json, "heading", heading, 0, true);
55 OBJECT_DESERIALIZE_FIELD(json, "proximity_alert_radius", proximityAlertRadius, 0, true);
56 }
57 };
58}
#define OBJECT_SERIALIZE_FIELD(json, json_field, field)
Available objects: https://core.telegram.org/bots/api#available-types.
Definition Object.hpp:19
#define OBJECT_DESERIALIZE_FIELD(json, json_field, field, default_value, optional)
Deserialize.
Definition Object.hpp:44
This object represents a point on the map. https://core.telegram.org/bots/api#location.
Definition Location.hpp:7
std::int32_t livePeriod
Optional. Time relative to the message sending date, during which the location can be updated,...
Definition Location.hpp:24
std::int32_t heading
Optional. The direction in which user is moving, in degrees; 1-360. For active live locations only.
Definition Location.hpp:28
Location()=default
float horizontalAccuracy
Optional. The radius of uncertainty for the location, measured in meters; 0-1500.
Definition Location.hpp:20
Location(const nl::json &json)
Definition Location.hpp:9
float latitude
Latitude as defined by sender.
Definition Location.hpp:17
std::int32_t proximityAlertRadius
Optional. Maximum distance for proximity alerts about approaching another chat member,...
Definition Location.hpp:33
void fromJson(const nl::json &json)
Deserializes this object from JSON.
Definition Location.hpp:49
nl::json toJson() const
Serializes this object to JSON.
Definition Location.hpp:37
float longitude
Longitude as defined by sender.
Definition Location.hpp:14