data_location.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #pragma once
  8. namespace Data {
  9. struct FileOrigin;
  10. class LocationPoint {
  11. public:
  12. LocationPoint() = default;
  13. explicit LocationPoint(const MTPDgeoPoint &point);
  14. enum IgnoreAccessHash {
  15. NoAccessHash,
  16. };
  17. LocationPoint(float64 lat, float64 lon, IgnoreAccessHash);
  18. [[nodiscard]] QString latAsString() const;
  19. [[nodiscard]] QString lonAsString() const;
  20. [[nodiscard]] MTPGeoPoint toMTP() const;
  21. [[nodiscard]] float64 lat() const;
  22. [[nodiscard]] float64 lon() const;
  23. [[nodiscard]] uint64 accessHash() const;
  24. [[nodiscard]] size_t hash() const;
  25. friend inline bool operator==(
  26. const LocationPoint &a,
  27. const LocationPoint &b) {
  28. return (a._lat == b._lat) && (a._lon == b._lon);
  29. }
  30. friend inline bool operator<(
  31. const LocationPoint &a,
  32. const LocationPoint &b) {
  33. return (a._lat < b._lat) || ((a._lat == b._lat) && (a._lon < b._lon));
  34. }
  35. private:
  36. float64 _lat = 0;
  37. float64 _lon = 0;
  38. uint64 _access = 0;
  39. };
  40. struct InputVenue {
  41. float64 lat = 0.;
  42. float64 lon = 0.;
  43. QString title;
  44. QString address;
  45. QString provider;
  46. QString id;
  47. QString venueType;
  48. [[nodiscard]] bool justLocation() const {
  49. return id.isEmpty();
  50. }
  51. friend inline bool operator==(
  52. const InputVenue &,
  53. const InputVenue &) = default;
  54. };
  55. [[nodiscard]] GeoPointLocation ComputeLocation(const LocationPoint &point);
  56. } // namespace Data
  57. namespace std {
  58. template <>
  59. struct hash<Data::LocationPoint> {
  60. size_t operator()(const Data::LocationPoint &value) const {
  61. return value.hash();
  62. }
  63. };
  64. } // namespace std