diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2018-11-27 14:20:03 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2019-01-14 10:45:48 -0400 |
commit | cead70717cec1e7e74136cf1c2a1a3dc9d52c896 (patch) | |
tree | 8ac690b6c850cd796cfb8d6d4a6764d4ac8325a2 | |
parent | 12295ef3355170d1877da5ef183eecfe7ad982be (diff) | |
download | qtlocation-mapboxgl-cead70717cec1e7e74136cf1c2a1a3dc9d52c896.tar.gz |
[build] StubGeometryTileFeature -> DefaultTileFeature
-rw-r--r-- | benchmark/benchmark-files.json | 4 | ||||
-rw-r--r-- | benchmark/function/composite_function.benchmark.cpp | 4 | ||||
-rw-r--r-- | benchmark/function/source_function.benchmark.cpp | 4 | ||||
-rw-r--r-- | benchmark/parse/filter.benchmark.cpp | 4 | ||||
-rw-r--r-- | benchmark/src/mbgl/benchmark/stub_geometry_tile_feature.hpp | 41 | ||||
-rw-r--r-- | platform/default/mbgl/tile/default_tile_feature.hpp (renamed from test/src/mbgl/test/stub_geometry_tile_feature.hpp) | 6 | ||||
-rw-r--r-- | test/gl/bucket.test.cpp | 12 | ||||
-rw-r--r-- | test/style/filter.test.cpp | 10 | ||||
-rw-r--r-- | test/style/property_expression.test.cpp | 14 | ||||
-rw-r--r-- | test/test-files.json | 1 | ||||
-rw-r--r-- | test/util/merge_lines.test.cpp | 16 |
11 files changed, 36 insertions, 80 deletions
diff --git a/benchmark/benchmark-files.json b/benchmark/benchmark-files.json index e3ad80072b..8f1abb24d1 100644 --- a/benchmark/benchmark-files.json +++ b/benchmark/benchmark-files.json @@ -16,7 +16,5 @@ "public_headers": { "mbgl/benchmark.hpp": "benchmark/include/mbgl/benchmark.hpp" }, - "private_headers": { - "mbgl/benchmark/stub_geometry_tile_feature.hpp": "benchmark/src/mbgl/benchmark/stub_geometry_tile_feature.hpp" - } + "private_headers": {} } diff --git a/benchmark/function/composite_function.benchmark.cpp b/benchmark/function/composite_function.benchmark.cpp index 8064d548fa..2f205588fc 100644 --- a/benchmark/function/composite_function.benchmark.cpp +++ b/benchmark/function/composite_function.benchmark.cpp @@ -1,6 +1,6 @@ #include <benchmark/benchmark.h> -#include <mbgl/benchmark/stub_geometry_tile_feature.hpp> +#include <mbgl/tile/default_tile_feature.hpp> #include <mbgl/style/conversion/json.hpp> #include <mbgl/style/conversion/function.hpp> @@ -52,7 +52,7 @@ static void Evaluate_CompositeFunction(benchmark::State& state) { while(state.KeepRunning()) { float z = 24.0f * static_cast<float>(rand() % 100) / 100; - function->asExpression().evaluate(z, StubGeometryTileFeature(PropertyMap { { "x", static_cast<int64_t>(rand() % 100) } }), -1.0f); + function->asExpression().evaluate(z, DefaultTileFeature(PropertyMap { { "x", static_cast<int64_t>(rand() % 100) } }), -1.0f); } state.SetLabel(std::to_string(stopCount).c_str()); diff --git a/benchmark/function/source_function.benchmark.cpp b/benchmark/function/source_function.benchmark.cpp index b75cc143d2..90967602d3 100644 --- a/benchmark/function/source_function.benchmark.cpp +++ b/benchmark/function/source_function.benchmark.cpp @@ -1,6 +1,6 @@ #include <benchmark/benchmark.h> -#include <mbgl/benchmark/stub_geometry_tile_feature.hpp> +#include <mbgl/tile/default_tile_feature.hpp> #include <mbgl/style/conversion/json.hpp> #include <mbgl/style/conversion/property_value.hpp> @@ -46,7 +46,7 @@ static void Evaluate_SourceFunction(benchmark::State& state) { } while(state.KeepRunning()) { - function->asExpression().evaluate(StubGeometryTileFeature(PropertyMap { { "x", static_cast<int64_t>(rand() % 100) } }), -1.0f); + function->asExpression().evaluate(DefaultTileFeature(PropertyMap { { "x", static_cast<int64_t>(rand() % 100) } }), -1.0f); } state.SetLabel(std::to_string(stopCount).c_str()); diff --git a/benchmark/parse/filter.benchmark.cpp b/benchmark/parse/filter.benchmark.cpp index 1ae2b0f2bc..35013057ae 100644 --- a/benchmark/parse/filter.benchmark.cpp +++ b/benchmark/parse/filter.benchmark.cpp @@ -5,7 +5,7 @@ #include <mbgl/style/conversion/filter.hpp> #include <mbgl/style/conversion_impl.hpp> #include <mbgl/tile/geometry_tile_data.hpp> -#include <mbgl/benchmark/stub_geometry_tile_feature.hpp> +#include <mbgl/tile/default_tile_feature.hpp> using namespace mbgl; @@ -22,7 +22,7 @@ static void Parse_Filter(benchmark::State& state) { static void Parse_EvaluateFilter(benchmark::State& state) { const style::Filter filter = parse(R"FILTER(["==", "foo", "bar"])FILTER"); - const StubGeometryTileFeature feature = { {}, FeatureType::Unknown , {}, {{ "foo", std::string("bar") }} }; + const DefaultTileFeature feature = { {}, FeatureType::Unknown , {}, {{ "foo", std::string("bar") }} }; const style::expression::EvaluationContext context = { &feature }; while (state.KeepRunning()) { diff --git a/benchmark/src/mbgl/benchmark/stub_geometry_tile_feature.hpp b/benchmark/src/mbgl/benchmark/stub_geometry_tile_feature.hpp deleted file mode 100644 index bff1a23ba8..0000000000 --- a/benchmark/src/mbgl/benchmark/stub_geometry_tile_feature.hpp +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once - -#include <mbgl/tile/geometry_tile_data.hpp> -#include <mbgl/util/feature.hpp> - -using namespace mbgl; - -class StubGeometryTileFeature : public GeometryTileFeature { -public: - StubGeometryTileFeature(PropertyMap properties_) - : properties(std::move(properties_)) { - } - - StubGeometryTileFeature(FeatureIdentifier id_, FeatureType type_, GeometryCollection geometry_, PropertyMap properties_) - : properties(std::move(properties_)), - id(std::move(id_)), - type(type_), - geometry(std::move(geometry_)) { - } - - PropertyMap properties; - FeatureIdentifier id; - FeatureType type = FeatureType::Point; - GeometryCollection geometry; - - FeatureType getType() const override { - return type; - } - - FeatureIdentifier getID() const override { - return id; - } - - optional<Value> getValue(const std::string& key) const override { - return properties.count(key) ? properties.at(key) : optional<Value>(); - } - - GeometryCollection getGeometries() const override { - return geometry; - } -}; diff --git a/test/src/mbgl/test/stub_geometry_tile_feature.hpp b/platform/default/mbgl/tile/default_tile_feature.hpp index ef21f8e937..9183fd583a 100644 --- a/test/src/mbgl/test/stub_geometry_tile_feature.hpp +++ b/platform/default/mbgl/tile/default_tile_feature.hpp @@ -3,13 +3,13 @@ namespace mbgl { -class StubGeometryTileFeature : public GeometryTileFeature { +class DefaultTileFeature : public GeometryTileFeature { public: - StubGeometryTileFeature(PropertyMap properties_) + DefaultTileFeature(PropertyMap properties_) : properties(std::move(properties_)) { } - StubGeometryTileFeature(FeatureIdentifier id_, FeatureType type_, GeometryCollection geometry_, PropertyMap properties_) + DefaultTileFeature(FeatureIdentifier id_, FeatureType type_, GeometryCollection geometry_, PropertyMap properties_) : properties(std::move(properties_)), id(std::move(id_)), type(type_), diff --git a/test/gl/bucket.test.cpp b/test/gl/bucket.test.cpp index 04e6447ad8..be431db6b4 100644 --- a/test/gl/bucket.test.cpp +++ b/test/gl/bucket.test.cpp @@ -1,5 +1,5 @@ #include <mbgl/test/util.hpp> -#include <mbgl/test/stub_geometry_tile_feature.hpp> +#include <mbgl/tile/default_tile_feature.hpp> #include <mbgl/renderer/backend_scope.hpp> #include <mbgl/renderer/buckets/circle_bucket.hpp> @@ -52,7 +52,7 @@ TEST(Buckets, CircleBucket) { ASSERT_FALSE(bucket.needsUpload()); GeometryCollection point { { { 0, 0 } } }; - bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::Point, point, properties }, point, {}, PatternLayerMap()); + bucket.addFeature(DefaultTileFeature { {}, FeatureType::Point, point, properties }, point, {}, PatternLayerMap()); ASSERT_TRUE(bucket.hasData()); ASSERT_TRUE(bucket.needsUpload()); @@ -72,7 +72,7 @@ TEST(Buckets, FillBucket) { ASSERT_FALSE(bucket.needsUpload()); GeometryCollection polygon { { { 0, 0 }, { 0, 1 }, { 1, 1 } } }; - bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::Polygon, polygon, properties }, polygon, {}, PatternLayerMap()); + bucket.addFeature(DefaultTileFeature { {}, FeatureType::Polygon, polygon, properties }, polygon, {}, PatternLayerMap()); ASSERT_TRUE(bucket.hasData()); ASSERT_TRUE(bucket.needsUpload()); @@ -92,11 +92,11 @@ TEST(Buckets, LineBucket) { // Ignore invalid feature type. GeometryCollection point { { { 0, 0 } } }; - bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::Point, point, properties }, point, {}, PatternLayerMap()); + bucket.addFeature(DefaultTileFeature { {}, FeatureType::Point, point, properties }, point, {}, PatternLayerMap()); ASSERT_FALSE(bucket.hasData()); GeometryCollection line { { { 0, 0 }, { 1, 1 } } }; - bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::LineString, line, properties }, line, {}, PatternLayerMap()); + bucket.addFeature(DefaultTileFeature { {}, FeatureType::LineString, line, properties }, line, {}, PatternLayerMap()); ASSERT_TRUE(bucket.hasData()); ASSERT_TRUE(bucket.needsUpload()); @@ -125,7 +125,7 @@ TEST(Buckets, SymbolBucket) { // SymbolBucket::addFeature() is a no-op. GeometryCollection point { { { 0, 0 } } }; - bucket.addFeature(StubGeometryTileFeature { {}, FeatureType::Point, point, properties }, point, {}, PatternLayerMap()); + bucket.addFeature(DefaultTileFeature { {}, FeatureType::Point, point, properties }, point, {}, PatternLayerMap()); ASSERT_FALSE(bucket.hasData()); ASSERT_FALSE(bucket.needsUpload()); diff --git a/test/style/filter.test.cpp b/test/style/filter.test.cpp index ef38a1a789..141480da3a 100644 --- a/test/style/filter.test.cpp +++ b/test/style/filter.test.cpp @@ -1,7 +1,7 @@ #include <mbgl/test/util.hpp> #include <mbgl/util/feature.hpp> #include <mbgl/util/geometry.hpp> -#include <mbgl/test/stub_geometry_tile_feature.hpp> +#include <mbgl/tile/default_tile_feature.hpp> #include <mbgl/util/rapidjson.hpp> #include <rapidjson/writer.h> @@ -29,10 +29,10 @@ bool filter(const char * json, optional<Filter> filter = conversion::convertJSON<Filter>(json, error); EXPECT_TRUE(bool(filter)); EXPECT_EQ(error.message, ""); - - StubGeometryTileFeature feature { featureId, featureType, featureGeometry, featureProperties }; + + DefaultTileFeature feature { featureId, featureType, featureGeometry, featureProperties }; expression::EvaluationContext context = { zoom, &feature }; - + return (*filter)(context); } @@ -224,7 +224,7 @@ TEST(Filter, LegacyProperty) { TEST(Filter, Serialize) { std::string json = R"(["any",["==","foo",0],["==","foo",1]])"; EXPECT_EQ(stringifyFilter(json.c_str()), std::string(json)); - + json = R"(["<=","two",2])"; EXPECT_EQ(stringifyFilter(json.c_str()), std::string(json)); diff --git a/test/style/property_expression.test.cpp b/test/style/property_expression.test.cpp index e4ee5f115f..73e975623b 100644 --- a/test/style/property_expression.test.cpp +++ b/test/style/property_expression.test.cpp @@ -1,5 +1,5 @@ #include <mbgl/test/util.hpp> -#include <mbgl/test/stub_geometry_tile_feature.hpp> +#include <mbgl/tile/default_tile_feature.hpp> #include <mbgl/style/property_expression.hpp> #include <mbgl/renderer/property_evaluator.hpp> @@ -12,15 +12,15 @@ using namespace mbgl::style::expression::dsl; using namespace std::string_literals; -static StubGeometryTileFeature oneInteger { +static DefaultTileFeature oneInteger { PropertyMap {{ "property", uint64_t(1) }} }; -static StubGeometryTileFeature oneDouble { +static DefaultTileFeature oneDouble { PropertyMap {{ "property", 1.0 }} }; -static StubGeometryTileFeature oneString { +static DefaultTileFeature oneString { PropertyMap {{ "property", "1"s }} }; @@ -65,14 +65,14 @@ TEST(PropertyExpression, ZoomInterpolation) { 3.0, interpolate(linear(), number(get("property")), 1.0, literal(48.0)) ), 0.0f) .evaluate(2.0f, oneInteger, -1.0f)) << "Should interpolate between stops"; - + EXPECT_EQ(33.0, PropertyExpression<float>( interpolate(linear(), zoom(), 5.0, interpolate(linear(), number(get("property")), 1.0, literal(33.0)), 10.0, interpolate(linear(), number(get("property")), 1.0, literal(66.0)) ), 0.0f) .evaluate(0.0f, oneInteger, -1.0f)) << "Use first stop output for input values from -inf to first stop"; - + EXPECT_EQ(66.0, PropertyExpression<float>( interpolate(linear(), zoom(), 0.0, interpolate(linear(), number(get("property")), 1.0, literal(33.0)), @@ -86,7 +86,7 @@ TEST(PropertyExpression, ZoomInterpolation) { 10.0, interpolate(linear(), number(get("property")), 1.0, literal(66.0)) ), 0.0f) .evaluate(10.0f, oneInteger, -1.0f)) << "Should interpolate TO the last stop."; - + EXPECT_EQ(33.0f, PropertyExpression<float>( interpolate(linear(), zoom(), 0.0, interpolate(linear(), number(get("property")), 1.0, literal(33.0)), diff --git a/test/test-files.json b/test/test-files.json index 5c863b82fd..820378443c 100644 --- a/test/test-files.json +++ b/test/test-files.json @@ -116,7 +116,6 @@ "mbgl/test/mock.hpp": "test/src/mbgl/test/mock.hpp", "mbgl/test/sqlite3_test_fs.hpp": "test/src/mbgl/test/sqlite3_test_fs.hpp", "mbgl/test/stub_file_source.hpp": "test/src/mbgl/test/stub_file_source.hpp", - "mbgl/test/stub_geometry_tile_feature.hpp": "test/src/mbgl/test/stub_geometry_tile_feature.hpp", "mbgl/test/stub_layer_observer.hpp": "test/src/mbgl/test/stub_layer_observer.hpp", "mbgl/test/stub_map_observer.hpp": "test/src/mbgl/test/stub_map_observer.hpp", "mbgl/test/stub_render_source_observer.hpp": "test/src/mbgl/test/stub_render_source_observer.hpp", diff --git a/test/util/merge_lines.test.cpp b/test/util/merge_lines.test.cpp index f76a1ea72a..6db6c9dac8 100644 --- a/test/util/merge_lines.test.cpp +++ b/test/util/merge_lines.test.cpp @@ -1,5 +1,5 @@ #include <mbgl/test/util.hpp> -#include <mbgl/test/stub_geometry_tile_feature.hpp> +#include <mbgl/tile/default_tile_feature.hpp> #include <mbgl/layout/merge_lines.hpp> #include <mbgl/layout/symbol_feature.hpp> @@ -22,7 +22,7 @@ public: SymbolFeatureStub(FeatureIdentifier id_, FeatureType type_, GeometryCollection geometry_, PropertyMap properties_, optional<std::u16string> text_, optional<std::string> icon_, std::size_t index_) : - SymbolFeature(std::make_unique<StubGeometryTileFeature>(std::move(id_), type_, std::move(geometry_), std::move(properties_))) + SymbolFeature(std::make_unique<DefaultTileFeature>(std::move(id_), type_, std::move(geometry_), std::move(properties_))) { if (text_) { formattedText = TaggedString(*text_, SectionOptions(1.0, 0)); @@ -42,7 +42,7 @@ TEST(MergeLines, SameText) { input1.push_back(SymbolFeatureStub({}, FeatureType::LineString, {{{6, 0}, {7, 0}, {8, 0}}}, properties, aaa, {}, 0)); input1.push_back(SymbolFeatureStub({}, FeatureType::LineString, {{{5, 0}, {6, 0}}}, properties, aaa, {}, 0)); - const std::vector<StubGeometryTileFeature> expected1 = { + const std::vector<DefaultTileFeature> expected1 = { { {}, FeatureType::LineString, {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}}}, properties }, { {}, FeatureType::LineString, {{{4, 0}, {5, 0}, {6, 0}}}, properties }, { {}, FeatureType::LineString, {{{5, 0}, {6, 0}, {7, 0}, {8, 0}, {9, 0}}}, properties }, @@ -50,7 +50,7 @@ TEST(MergeLines, SameText) { { {}, FeatureType::LineString, { emptyLine }, properties }, { {}, FeatureType::LineString, { emptyLine }, properties } }; - + mbgl::util::mergeLines(input1); for (int i = 0; i < 6; i++) { @@ -65,7 +65,7 @@ TEST(MergeLines, BothEnds) { input2.push_back(SymbolFeatureStub { {}, FeatureType::LineString, {{{4, 0}, {5, 0}, {6, 0}}}, properties, aaa, {}, 0 }); input2.push_back(SymbolFeatureStub { {}, FeatureType::LineString, {{{2, 0}, {3, 0}, {4, 0}}}, properties, aaa, {}, 0 }); - const std::vector<StubGeometryTileFeature> expected2 = { + const std::vector<DefaultTileFeature> expected2 = { { {}, FeatureType::LineString, {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}}}, properties }, { {}, FeatureType::LineString, { emptyLine }, properties }, { {}, FeatureType::LineString, { emptyLine }, properties } @@ -85,7 +85,7 @@ TEST(MergeLines, CircularLines) { input3.push_back(SymbolFeatureStub { {}, FeatureType::LineString, {{{2, 0}, {3, 0}, {4, 0}}}, properties, aaa, {}, 0 }); input3.push_back(SymbolFeatureStub { {}, FeatureType::LineString, {{{4, 0}, {0, 0}}}, properties, aaa, {}, 0 }); - const std::vector<StubGeometryTileFeature> expected3 = { + const std::vector<DefaultTileFeature> expected3 = { { {}, FeatureType::LineString, {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {0, 0}}}, properties }, { {}, FeatureType::LineString, { emptyLine }, properties }, { {}, FeatureType::LineString, { emptyLine }, properties } @@ -102,7 +102,7 @@ TEST(MergeLines, EmptyOuterGeometry) { std::vector<mbgl::SymbolFeature> input; input.push_back(SymbolFeatureStub { {}, FeatureType::LineString, {}, properties, aaa, {}, 0 }); - const std::vector<StubGeometryTileFeature> expected = { { {}, FeatureType::LineString, {}, properties } }; + const std::vector<DefaultTileFeature> expected = { { {}, FeatureType::LineString, {}, properties } }; mbgl::util::mergeLines(input); @@ -113,7 +113,7 @@ TEST(MergeLines, EmptyInnerGeometry) { std::vector<mbgl::SymbolFeature> input; input.push_back(SymbolFeatureStub { {}, FeatureType::LineString, {}, properties, aaa, {}, 0 }); - const std::vector<StubGeometryTileFeature> expected = { { {}, FeatureType::LineString, {}, properties } }; + const std::vector<DefaultTileFeature> expected = { { {}, FeatureType::LineString, {}, properties } }; mbgl::util::mergeLines(input); |