19 std::string_view address,
bool update =
false)
21 if (is_http_url(address))
22#if __has_include(<curl/curl.h>)
24 auto ret = std::make_unique<slippy::catalog>();
25 auto u = uri::parse(address);
26 auto os = std::ostringstream{};
27 os << u.scheme <<
"://" << u.host_spec <<
'/' << u.path;
28 for (
auto sep{
"?"}; !u.query.empty();) {
29 auto next = u.query.find(
'&');
30 auto len = (next == u.query.npos) ? u.query.size() : next;
31 auto pair = u.query.substr(0, len);
32 u.query.remove_prefix(len + (next != u.query.npos));
33 if (
auto eq = pair.find(
'='); eq != pair.npos) {
34 auto key = pair.substr(0, eq);
35 auto val = pair.substr(eq + 1);
41 ret->epsg = from_chars<int>(val.data(), val.size());
45 ret->zmax = from_chars<int>(val.data(), val.size());
49 ret->ssl = from_chars<int>(val.data(), val.size());
53 os << std::exchange(sep,
"&") << pair;
55 ret->url = std::move(os).str();
59 throw std::runtime_error(
"compiled without curl");
62 auto ret = std::make_unique<sql::catalog>();
66#if __has_include(<gdal.h>)
67 auto ret = std::make_unique<gdal::catalog>();
68 ret->dataset =
gdal::open(std::string{address}.data(), update);
71 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