Files
comaps/ge0/parser.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

50 lines
1.3 KiB
C++

#pragma once
#include <array>
#include <cstddef>
#include <cstdint>
#include <string>
namespace ge0
{
class Ge0Parser
{
public:
// Used by map/mwm_url.cpp.
static constexpr std::array<std::string_view, 6> kGe0Prefixes = {{
"https://omaps.app/", "om://", "http://omaps.app/",
"ge0://", "http://ge0.me/", "https://ge0.me/"
}};
struct Result
{
double m_zoomLevel = 0.0;
double m_lat = 0.0;
double m_lon = 0.0;
std::string m_name;
};
Ge0Parser();
bool Parse(std::string const & url, Result & result);
bool ParseAfterPrefix(std::string const & url, size_t from, Result & result);
protected:
uint8_t DecodeBase64Char(char const c);
static double DecodeZoom(uint8_t const zoomByte);
bool DecodeLatLon(std::string const & s, double & lat, double & lon);
bool DecodeLatLonToInt(std::string const & s, int & lat, int & lon);
double DecodeLatFromInt(int const lat, int const maxValue);
double DecodeLonFromInt(int const lon, int const maxValue);
std::string DecodeName(std::string name);
void SpacesToUnderscore(std::string & name);
void ValidateName(std::string & name);
static bool IsHexChar(char const a);
private:
uint8_t m_base64ReverseCharTable[256];
};
std::string DebugPrint(Ge0Parser::Result const & r);
} // namespace ge0