18inline std::unique_ptr<db::catalog>
make_catalog(std::string_view address)
20 if (is_http_url(address))
21#if __has_include(<curl/curl.h>)
23 auto ret = std::make_unique<slippy::catalog>();
24 auto u = uri::parse(address);
25 auto os = std::ostringstream{};
26 os << u.scheme <<
"://" << u.host_spec <<
'/' << u.path;
27 for (
auto sep{
"?"}; !u.query.empty();) {
28 auto next = u.query.find(
'&');
29 auto len = (next == u.query.npos) ? u.query.size() : next;
30 auto pair = u.query.substr(0, len);
31 u.query.remove_prefix(len + (next != u.query.npos));
32 if (
auto eq = pair.find(
'='); eq != pair.npos) {
33 auto key = pair.substr(0, eq);
34 auto val = pair.substr(eq + 1);
40 ret->epsg = from_chars<int>(val.data(), val.size());
44 ret->zmax = from_chars<int>(val.data(), val.size());
48 ret->ssl = from_chars<int>(val.data(), val.size());
52 os << std::exchange(sep,
"&") << pair;
54 ret->url = std::move(os).str();
58 throw std::runtime_error(
"compiled without curl");
61 auto ret = std::make_unique<sql::catalog>();
65#if __has_include(<gdal.h>)
66 auto ret = std::make_unique<gdal::catalog>();
67 ret->dataset =
gdal::open(std::string{address}.data());
70 throw std::runtime_error(
"compiled without gdal");
std::unique_ptr< db::command > make_command(std::string_view url)
Throws if the URL scheme is unknown or its client library is unavailable.
Definition commands.hpp:39
bool supported_url(std::string_view url)
Recognizes SQL URL schemes even without the corresponding client library.
Definition commands.hpp:32