Files
comaps/ge0/url_generator.hpp
Konstantin Pastbin e3e4a1985a Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run:
  git remote add om-historic [om-historic.git repo url]
  git fetch --tags om-historic
  git replace squashed-history historic-commits
2025-05-08 21:10:51 +07:00

46 lines
1.5 KiB
C++

#pragma once
#include <string>
namespace ge0
{
// Max number of base64 bytes to encode a geo point.
inline static int const kMaxPointBytes = 10;
inline static int const kMaxCoordBits = kMaxPointBytes * 3;
// Generates a short url.
//
// URL format:
//
// +------------------ 1 byte: zoom level
// |+-------+--------- 9 bytes: lat,lon
// || | +--+---- Variable number of bytes: point name
// || | | |
// om://ZCoordba64/Name
std::string GenerateShortShowMapUrl(double lat, double lon, double zoomLevel, std::string const & name);
// Generates a geo: uri.
//
// - https://datatracker.ietf.org/doc/html/rfc5870
// - https://developer.android.com/guide/components/intents-common#Maps
// - https://developers.google.com/maps/documentation/urls/android-intents
//
// URL format:
//
// +-------------------------------- lat
// | +-------------------- lon
// | | +---- zoom
// | | | +-- url-encoded name
// | | | |
// | | | |
// geo:54.683486138,25.289361259&z=14(Forto%20dvaras)
std::string GenerateGeoUri(double lat, double lon, double zoom, std::string const & name);
// Exposed for testing.
char Base64Char(int x);
int LatToInt(double lat, int maxValue);
double LonIn180180(double lon);
int LonToInt(double lon, int maxValue);
void LatLonToString(double lat, double lon, char * s, size_t nBytes);
} // namespace ge0