[core] Remove private header includes from CLI utilities
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
#include <mbgl/util/default_styles.hpp>
|
||||
#include <mbgl/util/run_loop.hpp>
|
||||
#include <mbgl/util/string.hpp>
|
||||
#include <mbgl/util/io.hpp>
|
||||
|
||||
#include <mbgl/storage/default_file_source.hpp>
|
||||
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
#include <mbgl/map/map.hpp>
|
||||
#include <mbgl/map/backend_scope.hpp>
|
||||
#include <mbgl/util/image.hpp>
|
||||
#include <mbgl/util/io.hpp>
|
||||
#include <mbgl/util/run_loop.hpp>
|
||||
|
||||
#include <mbgl/gl/headless_backend.hpp>
|
||||
#include <mbgl/gl/offscreen_view.hpp>
|
||||
#include <mbgl/util/default_thread_pool.hpp>
|
||||
#include <mbgl/storage/default_file_source.hpp>
|
||||
#include <mbgl/util/url.hpp>
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
|
||||
@@ -21,6 +19,7 @@ namespace po = boost::program_options;
|
||||
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
std::string style_path;
|
||||
@@ -91,12 +90,12 @@ int main(int argc, char *argv[]) {
|
||||
ThreadPool threadPool(4);
|
||||
Map map(backend, mbgl::Size { width, height }, pixelRatio, fileSource, threadPool, MapMode::Still);
|
||||
|
||||
if (util::isURL(style_path)) {
|
||||
map.setStyleURL(style_path);
|
||||
} else {
|
||||
map.setStyleJSON(mbgl::util::read_file(style_path));
|
||||
if (style_path.find("://") == std::string::npos) {
|
||||
style_path = std::string("file://") + style_path;
|
||||
}
|
||||
|
||||
map.setStyleURL(style_path);
|
||||
|
||||
map.setClasses(classes);
|
||||
|
||||
map.setLatLngZoom({ lat, lon }, zoom);
|
||||
@@ -117,7 +116,9 @@ int main(int argc, char *argv[]) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
util::write_file(output, encodePNG(view.readStillImage()));
|
||||
std::ofstream out(output, std::ios::binary);
|
||||
out << encodePNG(view.readStillImage());
|
||||
out.close();
|
||||
loop.stop();
|
||||
});
|
||||
|
||||
|
||||
@@ -12,8 +12,6 @@ target_compile_options(mbgl-offline
|
||||
)
|
||||
|
||||
target_include_directories(mbgl-offline
|
||||
PRIVATE include
|
||||
PRIVATE src # TODO: eliminate
|
||||
PRIVATE platform/default
|
||||
)
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@ target_compile_options(mbgl-render
|
||||
)
|
||||
|
||||
target_include_directories(mbgl-render
|
||||
PRIVATE include
|
||||
PRIVATE src # TODO: eliminate
|
||||
PRIVATE platform/default
|
||||
)
|
||||
|
||||
|
||||
@@ -66,19 +66,6 @@ std::string percentDecode(const std::string& input) {
|
||||
return decoded;
|
||||
}
|
||||
|
||||
// Checks whether the input string contains ://, and the part before it is all alphanumeric ASCII.
|
||||
bool isURL(const std::string& input) {
|
||||
auto it = input.begin();
|
||||
// First character has to be alphabetic
|
||||
if (it == input.end() || !isAlphaCharacter(*it++)) return false;
|
||||
// The remaining characters of the scheme can be alphanumeric, or be one of +.-
|
||||
while (it != input.end() && isSchemeCharacter(*it)) ++it;
|
||||
// Check that :// follows
|
||||
return (it != input.end() && *it++ == ':') &&
|
||||
(it != input.end() && *it++ == '/') &&
|
||||
(it != input.end() && *it++ == '/');
|
||||
}
|
||||
|
||||
URL::URL(const std::string& str)
|
||||
: query([&]() -> Segment {
|
||||
const auto hashPos = str.find('#');
|
||||
|
||||
@@ -8,7 +8,6 @@ namespace util {
|
||||
|
||||
std::string percentEncode(const std::string&);
|
||||
std::string percentDecode(const std::string&);
|
||||
bool isURL(const std::string&);
|
||||
|
||||
// Class that holds position + lenth pairs for scheme, domain, path + query string of a URL.
|
||||
class URL {
|
||||
|
||||
@@ -6,24 +6,6 @@
|
||||
|
||||
using namespace mbgl::util;
|
||||
|
||||
TEST(URL, isURL) {
|
||||
EXPECT_TRUE(isURL("mapbox://foo"));
|
||||
EXPECT_TRUE(isURL("mapbox://"));
|
||||
EXPECT_TRUE(isURL("mapbox-test-scheme://foo"));
|
||||
EXPECT_TRUE(isURL("mapbox+style://foo"));
|
||||
EXPECT_TRUE(isURL("mapbox-2.0://foo"));
|
||||
EXPECT_TRUE(isURL("mapbox99://foo"));
|
||||
|
||||
EXPECT_FALSE(isURL("mapbox:/"));
|
||||
EXPECT_FALSE(isURL(" mapbox://"));
|
||||
EXPECT_FALSE(isURL("://"));
|
||||
EXPECT_FALSE(isURL("mapbox"));
|
||||
EXPECT_FALSE(isURL("mapbox:foo"));
|
||||
EXPECT_FALSE(isURL("mapbox:/foo"));
|
||||
EXPECT_FALSE(isURL("test/mapbox://foo"));
|
||||
EXPECT_FALSE(isURL("123://foo"));
|
||||
}
|
||||
|
||||
TEST(URL, Scheme) {
|
||||
EXPECT_EQ(URL::Segment({ 0, 4 }), URL("http://example.com/test?query=foo").scheme);
|
||||
EXPECT_EQ(URL::Segment({ 0, 4 }), URL("http://127.0.0.1:8080/test?query=foo").scheme);
|
||||
|
||||
Reference in New Issue
Block a user