2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-23 10:47:11 +00:00
tdesktop/Telegram/SourceFiles/data/data_location.h

85 lines
1.7 KiB
C
Raw Permalink Normal View History

2019-06-21 14:27:46 +02:00
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
namespace Data {
struct FileOrigin;
class LocationPoint {
public:
LocationPoint() = default;
explicit LocationPoint(const MTPDgeoPoint &point);
2019-06-21 14:27:46 +02:00
enum IgnoreAccessHash {
NoAccessHash,
};
LocationPoint(float64 lat, float64 lon, IgnoreAccessHash);
[[nodiscard]] QString latAsString() const;
[[nodiscard]] QString lonAsString() const;
[[nodiscard]] MTPGeoPoint toMTP() const;
2019-06-21 14:27:46 +02:00
[[nodiscard]] float64 lat() const;
[[nodiscard]] float64 lon() const;
[[nodiscard]] uint64 accessHash() const;
2019-06-21 14:27:46 +02:00
[[nodiscard]] size_t hash() const;
2019-06-21 14:27:46 +02:00
friend inline bool operator==(
const LocationPoint &a,
const LocationPoint &b) {
2019-06-21 14:27:46 +02:00
return (a._lat == b._lat) && (a._lon == b._lon);
}
friend inline bool operator<(
const LocationPoint &a,
const LocationPoint &b) {
2019-06-21 14:27:46 +02:00
return (a._lat < b._lat) || ((a._lat == b._lat) && (a._lon < b._lon));
}
2024-02-22 22:00:11 +04:00
private:
2019-06-21 14:27:46 +02:00
float64 _lat = 0;
float64 _lon = 0;
uint64 _access = 0;
};
2024-07-04 12:18:30 +04:00
struct InputVenue {
float64 lat = 0.;
float64 lon = 0.;
QString title;
QString address;
QString provider;
QString id;
QString venueType;
2024-07-07 21:01:26 +04:00
2024-07-12 12:23:47 +02:00
[[nodiscard]] bool justLocation() const {
return id.isEmpty();
2024-07-12 12:23:47 +02:00
}
2024-07-07 21:01:26 +04:00
friend inline bool operator==(
const InputVenue &,
const InputVenue &) = default;
2024-07-04 12:18:30 +04:00
};
[[nodiscard]] GeoPointLocation ComputeLocation(const LocationPoint &point);
2019-06-21 14:27:46 +02:00
} // namespace Data
namespace std {
template <>
struct hash<Data::LocationPoint> {
size_t operator()(const Data::LocationPoint &value) const {
return value.hash();
}
};
} // namespace std