diff --git a/bin/offline.cpp b/bin/offline.cpp index 502561d0a..ec2fb0909 100644 --- a/bin/offline.cpp +++ b/bin/offline.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include diff --git a/bin/render.cpp b/bin/render.cpp index d4090cfa9..0af933475 100644 --- a/bin/render.cpp +++ b/bin/render.cpp @@ -1,14 +1,12 @@ #include #include #include -#include #include #include #include #include #include -#include #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunknown-pragmas" @@ -21,6 +19,7 @@ namespace po = boost::program_options; #include #include +#include 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(); }); diff --git a/cmake/offline.cmake b/cmake/offline.cmake index 23824e6bd..d0124e661 100644 --- a/cmake/offline.cmake +++ b/cmake/offline.cmake @@ -12,8 +12,6 @@ target_compile_options(mbgl-offline ) target_include_directories(mbgl-offline - PRIVATE include - PRIVATE src # TODO: eliminate PRIVATE platform/default ) diff --git a/cmake/render.cmake b/cmake/render.cmake index 395a10664..023b3c21e 100644 --- a/cmake/render.cmake +++ b/cmake/render.cmake @@ -7,8 +7,6 @@ target_compile_options(mbgl-render ) target_include_directories(mbgl-render - PRIVATE include - PRIVATE src # TODO: eliminate PRIVATE platform/default ) diff --git a/src/mbgl/util/url.cpp b/src/mbgl/util/url.cpp index 3f36bc676..1f6dab963 100644 --- a/src/mbgl/util/url.cpp +++ b/src/mbgl/util/url.cpp @@ -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('#'); diff --git a/src/mbgl/util/url.hpp b/src/mbgl/util/url.hpp index e361b07a7..70fdfd8a3 100644 --- a/src/mbgl/util/url.hpp +++ b/src/mbgl/util/url.hpp @@ -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 { diff --git a/test/util/url.test.cpp b/test/util/url.test.cpp index ca24a5949..55d8af281 100644 --- a/test/util/url.test.cpp +++ b/test/util/url.test.cpp @@ -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);