Repo created
This commit is contained in:
parent
4af19165ec
commit
68073add76
12458 changed files with 12350765 additions and 2 deletions
45
libs/ge0/url_generator.hpp
Normal file
45
libs/ge0/url_generator.hpp
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace ge0
|
||||
{
|
||||
// Max number of base64 bytes to encode a geo point.
|
||||
inline static int constexpr kMaxPointBytes = 10;
|
||||
inline static int constexpr kMaxCoordBits = kMaxPointBytes * 3;
|
||||
|
||||
// Generates a short url.
|
||||
//
|
||||
// URL format:
|
||||
//
|
||||
// +------------------ 1 byte: zoom level
|
||||
// |+-------+--------- 9 bytes: lat,lon
|
||||
// || | +--+---- Variable number of bytes: point name
|
||||
// || | | |
|
||||
// cm://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
|
||||
Loading…
Add table
Add a link
Reference in a new issue