diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-07-10 14:54:43 -0700 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-07-10 14:54:43 -0700 |
commit | a8e71bcb7b03ed9c95b65d312821e577a796a48d (patch) | |
tree | 82af5a95f126f19a6ff50fe286566983d6d62fad | |
parent | a8963fcbe428663000b4b0fcc2e4de76b99a2fe0 (diff) | |
download | qtlocation-mapboxgl-a8e71bcb7b03ed9c95b65d312821e577a796a48d.tar.gz |
change line width and add line-width test
-rw-r--r-- | bin/style.js | 1 | ||||
-rw-r--r-- | src/map/transform_state.cpp | 2 | ||||
-rw-r--r-- | src/style/style_layer.cpp | 5 | ||||
-rw-r--r-- | src/style/style_parser.cpp | 4 | ||||
-rw-r--r-- | test/fixtures/styles/road-width.expected.png | bin | 0 -> 110023 bytes | |||
-rw-r--r-- | test/fixtures/styles/road-width.info.json | 8 | ||||
-rw-r--r-- | test/fixtures/styles/road-width.style.json | 32 | ||||
-rw-r--r-- | test/fixtures/tiles/14-8802-5374.vector.pbf | bin | 0 -> 399937 bytes | |||
-rw-r--r-- | test/fixtures/tiles/14-8802-5375.vector.pbf | bin | 0 -> 325249 bytes | |||
-rw-r--r-- | test/fixtures/tiles/14-8803-5374.vector.pbf | bin | 0 -> 347363 bytes | |||
-rw-r--r-- | test/fixtures/tiles/14-8803-5375.vector.pbf | bin | 0 -> 448599 bytes | |||
-rw-r--r-- | test/headless.cpp | 42 |
12 files changed, 73 insertions, 21 deletions
diff --git a/bin/style.js b/bin/style.js index e760ea102a..789478d9bf 100644 --- a/bin/style.js +++ b/bin/style.js @@ -8,7 +8,6 @@ module.exports = { "mapbox": { "type": "vector", "url": "mapbox://mapbox.mapbox-terrain-v1,mapbox.mapbox-streets-v5", - "tileSize": 512, "maxZoom": 14 } }, diff --git a/src/map/transform_state.cpp b/src/map/transform_state.cpp index cb0a3b6e76..2bc8e71a47 100644 --- a/src/map/transform_state.cpp +++ b/src/map/transform_state.cpp @@ -92,7 +92,7 @@ float TransformState::getPixelRatio() const { #pragma mark - Zoom float TransformState::getNormalizedZoom() const { - return std::log(scale * util::tileSize / 256.0f) / M_LN2; + return std::log(scale * util::tileSize / 512.0f) / M_LN2; } int32_t TransformState::getIntegerZoom() const { diff --git a/src/style/style_layer.cpp b/src/style/style_layer.cpp index 0c62872727..4bbf1812d5 100644 --- a/src/style/style_layer.cpp +++ b/src/style/style_layer.cpp @@ -250,11 +250,6 @@ void StyleLayer::updateProperties(float z, const timestamp now) { layers->updateProperties(z, now); } - // Accomodate for different tile size. - if (bucket && bucket->source) { - z += std::log(bucket->source->tile_size / 256.0f) / M_LN2; - } - cleanupAppliedStyleProperties(now); switch (type) { diff --git a/src/style/style_parser.cpp b/src/style/style_parser.cpp index 9952a22868..e0b85381bc 100644 --- a/src/style/style_parser.cpp +++ b/src/style/style_parser.cpp @@ -170,7 +170,9 @@ void StyleParser::parseSources(JSVal value) { parseRenderProperty(itr->value, type, "type", parseSourceType); parseRenderProperty(itr->value, url, "url"); - parseRenderProperty(itr->value, tile_size, "tileSize"); + if (type == SourceType::Raster) { + parseRenderProperty(itr->value, tile_size, "tileSize"); + } parseRenderProperty(itr->value, min_zoom, "minZoom"); parseRenderProperty(itr->value, max_zoom, "maxZoom"); diff --git a/test/fixtures/styles/road-width.expected.png b/test/fixtures/styles/road-width.expected.png Binary files differnew file mode 100644 index 0000000000..0c8205ad91 --- /dev/null +++ b/test/fixtures/styles/road-width.expected.png diff --git a/test/fixtures/styles/road-width.info.json b/test/fixtures/styles/road-width.info.json new file mode 100644 index 0000000000..85808bb804 --- /dev/null +++ b/test/fixtures/styles/road-width.info.json @@ -0,0 +1,8 @@ +{ + "zoom": 14, + "latitude": 52.499167, + "longitude": 13.418056, + "angle": 0, + "width": 512, + "height": 512 +} diff --git a/test/fixtures/styles/road-width.style.json b/test/fixtures/styles/road-width.style.json new file mode 100644 index 0000000000..469a376bca --- /dev/null +++ b/test/fixtures/styles/road-width.style.json @@ -0,0 +1,32 @@ +{ + "version": 3, + "sources": { + "mapbox": { + "type": "vector", + "url": "tiles/{z}-{x}-{y}.vector.pbf", + "tileSize": 512, + "maxZoom": 14 + } + }, + "layers": [ + { + "id": "background", + "type": "background", + "style": { + "background-color": "white" + } + }, + { + "id": "road", + "source": "mapbox", + "source-layer": "road", + "type": "line", + "style": { + "line-width": { + "fn": "stops", + "stops": [[13, 0], [13.999, 0], [14, 4], [14.1, 100]] + } + } + } + ] +} diff --git a/test/fixtures/tiles/14-8802-5374.vector.pbf b/test/fixtures/tiles/14-8802-5374.vector.pbf Binary files differnew file mode 100644 index 0000000000..a2277ea1ff --- /dev/null +++ b/test/fixtures/tiles/14-8802-5374.vector.pbf diff --git a/test/fixtures/tiles/14-8802-5375.vector.pbf b/test/fixtures/tiles/14-8802-5375.vector.pbf Binary files differnew file mode 100644 index 0000000000..0804e8736c --- /dev/null +++ b/test/fixtures/tiles/14-8802-5375.vector.pbf diff --git a/test/fixtures/tiles/14-8803-5374.vector.pbf b/test/fixtures/tiles/14-8803-5374.vector.pbf Binary files differnew file mode 100644 index 0000000000..4e66bead09 --- /dev/null +++ b/test/fixtures/tiles/14-8803-5374.vector.pbf diff --git a/test/fixtures/tiles/14-8803-5375.vector.pbf b/test/fixtures/tiles/14-8803-5375.vector.pbf Binary files differnew file mode 100644 index 0000000000..f940be5992 --- /dev/null +++ b/test/fixtures/tiles/14-8803-5375.vector.pbf diff --git a/test/headless.cpp b/test/headless.cpp index 6f02191376..11b8f2b027 100644 --- a/test/headless.cpp +++ b/test/headless.cpp @@ -9,21 +9,23 @@ #include "../common/headless_view.hpp" +#include <dirent.h> + const std::string base_directory = []{ std::string fn = __FILE__; fn.erase(fn.find_last_of("/")); - return fn; + return fn + "/fixtures/styles"; }(); -class HeadlessTest : public ::testing::TestWithParam<const char *> {}; +class HeadlessTest : public ::testing::TestWithParam<std::string> {}; TEST_P(HeadlessTest, render) { - const char *base = GetParam(); + const std::string &base = GetParam(); - const std::string style = llmr::util::read_file(base_directory + "/fixtures/styles/" + base + ".style.json"); - const std::string info = llmr::util::read_file(base_directory + "/fixtures/styles/" + base + ".info.json"); - const std::string expected_image = base_directory + "/fixtures/styles/" + base + ".expected.png"; - const std::string actual_image = base_directory + "/fixtures/styles/" + base + ".actual.png"; + const std::string style = llmr::util::read_file(base_directory + "/" + base + ".style.json"); + const std::string info = llmr::util::read_file(base_directory + "/" + base + ".info.json"); + const std::string expected_image = base_directory + "/" + base + ".expected.png"; + const std::string actual_image = base_directory + "/" + base + ".actual.png"; // Parse settings. rapidjson::Document doc; @@ -58,12 +60,26 @@ TEST_P(HeadlessTest, render) { const std::string image = llmr::util::compress_png(width, height, pixels.get(), true); llmr::util::write_file(actual_image, image); - - const std::string expected_image_data(llmr::util::read_file(expected_image)); - const llmr::util::Image expected(expected_image_data, true); - ASSERT_EQ(width, expected.getWidth()); - ASSERT_EQ(height, expected.getHeight()); } INSTANTIATE_TEST_CASE_P(Headless, HeadlessTest, - ::testing::Values("0", "1")); + ::testing::ValuesIn([]{ + std::vector<std::string> names; + + const std::string ending = ".info.json"; + + DIR *dir = opendir(base_directory.c_str()); + if (dir == nullptr) return names; + + for (dirent *dp = nullptr; (dp = readdir(dir)) != nullptr;) { + const std::string name = dp->d_name; + if (name.length() >= ending.length() && name.compare(name.length() - ending.length(), ending.length(), ending) == 0) { + names.push_back(name.substr(0, name.length() - ending.length())); + } + } + + closedir(dir); + + + return names; + }())); |