Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
Add unit tests for distance expression
Browse files Browse the repository at this point in the history
  • Loading branch information
zmiao committed Apr 20, 2020
1 parent 09d31d6 commit 8a655e3
Show file tree
Hide file tree
Showing 10 changed files with 1,211 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/mbgl/style/expression/distance.cpp
Expand Up @@ -21,8 +21,8 @@
namespace mbgl {
namespace {

const std::size_t MinPointsSize = 500;
const std::size_t MinLinePointsSize = 200;
const std::size_t MinPointsSize = 100;
const std::size_t MinLinePointsSize = 50;

using BBox = std::array<double, 4>;
const BBox DefaultBBox = BBox{std::numeric_limits<double>::infinity(),
Expand Down Expand Up @@ -414,9 +414,9 @@ optional<Arguments> parseValue(const style::conversion::Convertible& value, styl
} else if (*input == "NauticalMiles") {
unit = mapbox::cheap_ruler::CheapRuler::Unit::NauticalMiles;
} else if (*input == "Yards") {
unit = mapbox::cheap_ruler::CheapRuler::Unit::Kilometers;
unit = mapbox::cheap_ruler::CheapRuler::Unit::Yards;
} else if (*input == "Feet") {
unit = mapbox::cheap_ruler::CheapRuler::Unit::Miles;
unit = mapbox::cheap_ruler::CheapRuler::Unit::Feet;
} else if (*input == "Inches") {
unit = mapbox::cheap_ruler::CheapRuler::Unit::Inches;
} else {
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/expression_equality/distance.a.json
@@ -0,0 +1,5 @@
["distance", {
"type": "LineString",
"coordinates": [[0, 0], [0, 5], [5, 5], [5, 0]]
}, "Meters"
]
5 changes: 5 additions & 0 deletions test/fixtures/expression_equality/distance.b.json
@@ -0,0 +1,5 @@
["distance", {
"type": "LineString",
"coordinates": [[0, 0], [0, 6], [5, 5], [5, 0]]
}, "Meters"
]
259 changes: 259 additions & 0 deletions test/fixtures/geometry_data/line_string_1.geojson
@@ -0,0 +1,259 @@
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates":
[
[
24.919674396514893,
60.16455037398201
],
[
24.921332001686096,
60.16460108220136
],
[
24.92250680923462,
60.164705167248556
],
[
24.92311298847198,
60.16476254732591
],
[
24.923794269561768,
60.16481192080062
],
[
24.924674034118652,
60.16487063510643
],
[
24.92523193359375,
60.1648919857371
],
[
24.925435781478882,
60.164910667527536
],
[
24.92561012506485,
60.16495069989984
],
[
24.925816655158997,
60.165010748366896
],
[
24.926661550998688,
60.165288304299814
],
[
24.92731064558029,
60.1655044760466
],
[
24.927439391613003,
60.165561854728224
],
[
24.928563237190247,
60.16595149335769
],
[
24.929917752742767,
60.16642652598447
],
[
24.930156469345093,
60.16644253820056
],
[
24.930403232574463,
60.166394501528906
],
[
24.93046224117279,
60.16634913349672
],
[
24.930633902549744,
60.166365145750525
],
[
24.93071973323822,
60.16642385728104
],
[
24.93074119091034,
60.166511924380124
],
[
24.930797517299652,
60.16665069629966
],
[
24.931159615516663,
60.16733387258923
],
[
24.93122398853302,
60.1673819078876
],
[
24.93122935295105,
60.167383242200444
],
[
24.931269586086273,
60.16739658532588
],
[
24.93135541677475,
60.167392582388814
],
[
24.93148148059845,
60.16739525101357
],
[
24.931594133377075,
60.167403256886566
],
[
24.931905269622803,
60.167397919638134
],
[
24.932076930999752,
60.167405925510465
],
[
24.932237863540646,
60.16741660000386
],
[
24.93250608444214,
60.1674673038002
],
[
24.933310747146603,
60.167734164596524
],
[
24.934450685977936,
60.168130448879936
],
[
24.934933483600616,
60.16830123659222
],
[
24.934713542461395,
60.16847068914809
],
[
24.934949576854706,
60.16855474796568
],
[
24.935268759727478,
60.16866682605459
],
[
24.936030507087704,
60.16894701960423
],
[
24.93632823228836,
60.16903107720314
],
[
24.93696391582489,
60.16926456940512
],
[
24.938240647315975,
60.16974755943638
],
[
24.938401579856873,
60.16979692542083
],
[
24.938731491565704,
60.16987297557607
],
[
24.939565658569332,
60.17019985581767
],
[
24.939801692962643,
60.17026389727989
],
[
24.939911663532257,
60.17027590504016
],
[
24.941115975379944,
60.170305257324564
],
[
24.94418442249298,
60.170386643066905
],
[
24.94469404220581,
60.17047469954465
],
[
24.945133924484253,
60.17062412817889
],
[
24.94567573070526,
60.17080023962529
],
[
24.946464300155636,
60.17102971676008
],
[
24.94716167449951,
60.17129921692988
],
[
24.94742453098297,
60.17141929055101
],
[
24.947537183761593,
60.17157405145976
],
[
24.9476820230484,
60.171819532785136
],
[
24.948642253875732,
60.17268670756399
],
[
24.949076771736145,
60.17306558905074
],
[
24.949543476104736,
60.1734391299005
]
]
}
}
]
}

0 comments on commit 8a655e3

Please sign in to comment.