From 1de8aeed31226f167c528bfdcfae97d12c5d67ca Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Fri, 16 Jun 2017 10:16:11 -0700 Subject: [PATCH 1/8] [core] Fix composite function approximation for non-integer stops --- .../style/function/composite_function.hpp | 75 +++++++++++++------ src/mbgl/renderer/paint_property_binder.hpp | 10 +-- .../function/composite_function.test.cpp | 25 +++++++ 3 files changed, 83 insertions(+), 27 deletions(-) diff --git a/include/mbgl/style/function/composite_function.hpp b/include/mbgl/style/function/composite_function.hpp index 9275ccdf8f5..b82e63bc374 100644 --- a/include/mbgl/style/function/composite_function.hpp +++ b/include/mbgl/style/function/composite_function.hpp @@ -49,8 +49,16 @@ class CompositeFunction { defaultValue(std::move(defaultValue_)) { } - std::tuple, Range> - coveringRanges(float zoom) const { + struct CoveringRanges { + float zoom; + Range coveringZoomRange; + Range coveringStopsRange; + }; + + // Return the relevant stop zoom values and inner stops that bracket a given zoom level. This + // is the first step toward evaluating the function, and is used for in the course of both partial + // evaluation of data-driven paint properties, and full evaluation of data-driven layout properties. + CoveringRanges coveringRanges(float zoom) const { return stops.match( [&] (const auto& s) { assert(!s.stops.empty()); @@ -63,7 +71,8 @@ class CompositeFunction { minIt--; } - return std::make_tuple( + return CoveringRanges { + zoom, Range { minIt == s.stops.end() ? s.stops.rbegin()->first : minIt->first, maxIt == s.stops.end() ? s.stops.rbegin()->first : maxIt->first @@ -72,38 +81,49 @@ class CompositeFunction { s.innerStops(minIt == s.stops.end() ? s.stops.rbegin()->second : minIt->second), s.innerStops(maxIt == s.stops.end() ? s.stops.rbegin()->second : maxIt->second) } - ); + }; } ); } + // Given a range of zoom values (typically two adjacent integer zoom levels, e.g. 5.0 and 6.0), + // return the covering ranges for both. This is used in the course of partial evaluation for + // data-driven paint properties. + Range rangeOfCoveringRanges(Range zoomRange) { + return Range { + coveringRanges(zoomRange.min), + coveringRanges(zoomRange.max) + }; + } + + // Given the covering ranges for range of zoom values (typically two adjacent integer zoom levels, + // e.g. 5.0 and 6.0), and a feature, return the results of fully evaluating the function for that + // feature at each of the two zoom levels. These two results are what go into the paint vertex buffers + // for vertices associated with this feature. The shader will interpolate between them at render time. template - Range evaluate(Range coveringStops, - const Feature& feature, - T finalDefaultValue) const { - optional v = feature.getValue(property); - if (!v) { - return { + Range evaluate(const Range& ranges, const Feature& feature, T finalDefaultValue) { + optional value = feature.getValue(property); + if (!value) { + return Range { defaultValue.value_or(finalDefaultValue), defaultValue.value_or(finalDefaultValue) }; } - auto eval = [&] (const auto& s) { - return s.evaluate(*v).value_or(defaultValue.value_or(finalDefaultValue)); - }; return Range { - coveringStops.min.match(eval), - coveringStops.max.match(eval) + evaluateFinal(ranges.min, *value, finalDefaultValue), + evaluateFinal(ranges.max, *value, finalDefaultValue) }; } - T evaluate(float zoom, const GeometryTileFeature& feature, T finalDefaultValue) const { - std::tuple, Range> ranges = coveringRanges(zoom); - Range resultRange = evaluate(std::get<1>(ranges), feature, finalDefaultValue); - return util::interpolate( - resultRange.min, - resultRange.max, - util::interpolationFactor(1.0f, std::get<0>(ranges), zoom)); + // Fully evaluate the function for a zoom value and feature. This is used when evaluating data-driven + // layout properties. + template + T evaluate(float zoom, const Feature& feature, T finalDefaultValue) const { + optional value = feature.getValue(property); + if (!value) { + return defaultValue.value_or(finalDefaultValue); + } + return evaluateFinal(coveringRanges(zoom), *value, finalDefaultValue); } friend bool operator==(const CompositeFunction& lhs, @@ -115,6 +135,17 @@ class CompositeFunction { std::string property; Stops stops; optional defaultValue; + +private: + T evaluateFinal(const CoveringRanges& ranges, const Value& value, T finalDefaultValue) const { + auto eval = [&] (const auto& s) { + return s.evaluate(value).value_or(defaultValue.value_or(finalDefaultValue)); + }; + return util::interpolate( + ranges.coveringStopsRange.min.match(eval), + ranges.coveringStopsRange.max.match(eval), + util::interpolationFactor(1.0f, ranges.coveringZoomRange, ranges.zoom)); + } }; } // namespace style diff --git a/src/mbgl/renderer/paint_property_binder.hpp b/src/mbgl/renderer/paint_property_binder.hpp index 062b77888e1..bcbc7c287dc 100644 --- a/src/mbgl/renderer/paint_property_binder.hpp +++ b/src/mbgl/renderer/paint_property_binder.hpp @@ -194,11 +194,11 @@ class CompositeFunctionPaintPropertyBinder : public PaintPropertyBinder { CompositeFunctionPaintPropertyBinder(style::CompositeFunction function_, float zoom, T defaultValue_) : function(std::move(function_)), defaultValue(std::move(defaultValue_)), - coveringRanges(function.coveringRanges(zoom)) { + rangeOfCoveringRanges(function.rangeOfCoveringRanges({zoom, zoom + 1})) { } void populateVertexVector(const GeometryTileFeature& feature, std::size_t length) override { - Range range = function.evaluate(std::get<1>(coveringRanges), feature, defaultValue); + Range range = function.evaluate(rangeOfCoveringRanges, feature, defaultValue); this->statistics.add(range.min); this->statistics.add(range.max); AttributeValue value = zoomInterpolatedAttributeValue( @@ -225,7 +225,7 @@ class CompositeFunctionPaintPropertyBinder : public PaintPropertyBinder { } float interpolationFactor(float currentZoom) const override { - return util::interpolationFactor(1.0f, std::get<0>(coveringRanges), currentZoom); + return util::interpolationFactor(1.0f, { rangeOfCoveringRanges.min.zoom, rangeOfCoveringRanges.max.zoom }, currentZoom); } T uniformValue(const PossiblyEvaluatedPropertyValue& currentValue) const override { @@ -238,10 +238,10 @@ class CompositeFunctionPaintPropertyBinder : public PaintPropertyBinder { } private: - using InnerStops = typename style::CompositeFunction::InnerStops; style::CompositeFunction function; T defaultValue; - std::tuple, Range> coveringRanges; + using CoveringRanges = typename style::CompositeFunction::CoveringRanges; + Range rangeOfCoveringRanges; gl::VertexVector vertexVector; optional> vertexBuffer; }; diff --git a/test/style/function/composite_function.test.cpp b/test/style/function/composite_function.test.cpp index e0804d4b279..09b79a8b8f0 100644 --- a/test/style/function/composite_function.test.cpp +++ b/test/style/function/composite_function.test.cpp @@ -44,3 +44,28 @@ TEST(CompositeFunction, ZoomInterpolation) { }), 0.0f) .evaluate(0.0f, oneInteger, -1.0f)) << "Should interpolate TO the first stop"; } + +TEST(CompositeFunction, Issue8460) { + CompositeFunction fn1("property", CompositeExponentialStops({ + {15.0f, {{uint64_t(1), 0.0f}}}, + {15.2f, {{uint64_t(1), 600.0f}}}, + }), 0.0f); + + EXPECT_NEAR( 0.0f, fn1.evaluate(15.0f, oneInteger, -1.0f), 0.00); + EXPECT_NEAR(300.0f, fn1.evaluate(15.1f, oneInteger, -1.0f), 0.01); + EXPECT_NEAR(600.0f, fn1.evaluate(15.2f, oneInteger, -1.0f), 0.00); + EXPECT_NEAR(600.0f, fn1.evaluate(16.0f, oneInteger, -1.0f), 0.00); + + CompositeFunction fn2("property", CompositeExponentialStops({ + {15.0f, {{uint64_t(1), 0.0f}}}, + {15.2f, {{uint64_t(1), 300.0f}}}, + {18.0f, {{uint64_t(1), 600.0f}}}, + }), 0.0f); + + EXPECT_NEAR( 0.0f, fn2.evaluate(15.0f, oneInteger, -1.0f), 0.00); + EXPECT_NEAR(150.0f, fn2.evaluate(15.1f, oneInteger, -1.0f), 0.01); + EXPECT_NEAR(300.0f, fn2.evaluate(15.2f, oneInteger, -1.0f), 0.00); + EXPECT_NEAR(385.71f, fn2.evaluate(16.0f, oneInteger, -1.0f), 0.01); + EXPECT_NEAR(600.0f, fn2.evaluate(18.0f, oneInteger, -1.0f), 0.00); + EXPECT_NEAR(600.0f, fn2.evaluate(19.0f, oneInteger, -1.0f), 0.00); +} From 505999a52df625c21791eae352342ae25e9c48af Mon Sep 17 00:00:00 2001 From: Jesse Bounds Date: Mon, 19 Jun 2017 09:34:44 -1000 Subject: [PATCH 2/8] [ios] Update telemetry cert pinning (#9292) --- platform/ios/ios.xcodeproj/project.pbxproj | 36 ++++-- ...t.der => api_mapbox_com-digicert_2016.der} | Bin .../api_mapbox_com-digicert_2017.der | Bin 0 -> 2030 bytes ...t.der => api_mapbox_com-geotrust_2016.der} | Bin .../api_mapbox_com-geotrust_2017.der | Bin 0 -> 1758 bytes platform/ios/src/MGLAPIClient.m | 114 ++++++++---------- 6 files changed, 73 insertions(+), 77 deletions(-) rename platform/ios/resources/{api_mapbox_com-digicert.der => api_mapbox_com-digicert_2016.der} (100%) create mode 100644 platform/ios/resources/api_mapbox_com-digicert_2017.der rename platform/ios/resources/{api_mapbox_com-geotrust.der => api_mapbox_com-geotrust_2016.der} (100%) create mode 100644 platform/ios/resources/api_mapbox_com-geotrust_2017.der diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj index b6d422d0fc0..5120d63f20a 100644 --- a/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/ios.xcodeproj/project.pbxproj @@ -163,12 +163,12 @@ 404C26E71D89C55D000AA13D /* MGLTileSource_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 404C26E61D89C515000AA13D /* MGLTileSource_Private.h */; }; 404C26E81D89C55D000AA13D /* MGLTileSource_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 404C26E61D89C515000AA13D /* MGLTileSource_Private.h */; }; 40599F0C1DEE1B7600182B5D /* api_mapbox_staging.der in Resources */ = {isa = PBXBuildFile; fileRef = 40599F001DEE1B2400182B5D /* api_mapbox_staging.der */; }; - 40599F0D1DEE1B7A00182B5D /* api_mapbox_com-digicert.der in Resources */ = {isa = PBXBuildFile; fileRef = 40599F011DEE1B2400182B5D /* api_mapbox_com-digicert.der */; }; - 40599F0E1DEE1B7E00182B5D /* api_mapbox_com-geotrust.der in Resources */ = {isa = PBXBuildFile; fileRef = 40599F021DEE1B2400182B5D /* api_mapbox_com-geotrust.der */; }; + 40599F0D1DEE1B7A00182B5D /* api_mapbox_com-digicert_2016.der in Resources */ = {isa = PBXBuildFile; fileRef = 40599F011DEE1B2400182B5D /* api_mapbox_com-digicert_2016.der */; }; + 40599F0E1DEE1B7E00182B5D /* api_mapbox_com-geotrust_2016.der in Resources */ = {isa = PBXBuildFile; fileRef = 40599F021DEE1B2400182B5D /* api_mapbox_com-geotrust_2016.der */; }; 4085AF091D933DEA00F11B22 /* MGLTileSetTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4085AF081D933DEA00F11B22 /* MGLTileSetTests.mm */; }; 408982E91DEE208200754016 /* api_mapbox_staging.der in Resources */ = {isa = PBXBuildFile; fileRef = 40599F001DEE1B2400182B5D /* api_mapbox_staging.der */; }; - 408982EA1DEE208B00754016 /* api_mapbox_com-digicert.der in Resources */ = {isa = PBXBuildFile; fileRef = 40599F011DEE1B2400182B5D /* api_mapbox_com-digicert.der */; }; - 408982EB1DEE209100754016 /* api_mapbox_com-geotrust.der in Resources */ = {isa = PBXBuildFile; fileRef = 40599F021DEE1B2400182B5D /* api_mapbox_com-geotrust.der */; }; + 408982EA1DEE208B00754016 /* api_mapbox_com-digicert_2016.der in Resources */ = {isa = PBXBuildFile; fileRef = 40599F011DEE1B2400182B5D /* api_mapbox_com-digicert_2016.der */; }; + 408982EB1DEE209100754016 /* api_mapbox_com-geotrust_2016.der in Resources */ = {isa = PBXBuildFile; fileRef = 40599F021DEE1B2400182B5D /* api_mapbox_com-geotrust_2016.der */; }; 408AA8571DAEDA1700022900 /* NSDictionary+MGLAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 408AA8551DAEDA0800022900 /* NSDictionary+MGLAdditions.h */; }; 408AA8581DAEDA1E00022900 /* NSDictionary+MGLAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 408AA8561DAEDA0800022900 /* NSDictionary+MGLAdditions.mm */; }; 408AA8591DAEDA1E00022900 /* NSDictionary+MGLAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 408AA8561DAEDA0800022900 /* NSDictionary+MGLAdditions.mm */; }; @@ -176,6 +176,10 @@ 409F43FD1E9E781C0048729D /* MGLMapViewDelegateIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 409F43FC1E9E781C0048729D /* MGLMapViewDelegateIntegrationTests.swift */; }; 40CF6DBB1DAC3C6600A4D18B /* MGLShape_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 40CF6DBA1DAC3C1800A4D18B /* MGLShape_Private.h */; }; 40CFA6511D7875BB008103BD /* MGLShapeSourceTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 40CFA6501D787579008103BD /* MGLShapeSourceTests.mm */; }; + 40EA6BC11EF4599600FCCDA2 /* api_mapbox_com-digicert_2017.der in Resources */ = {isa = PBXBuildFile; fileRef = 40EA6BBD1EF4598900FCCDA2 /* api_mapbox_com-digicert_2017.der */; }; + 40EA6BC21EF4599700FCCDA2 /* api_mapbox_com-digicert_2017.der in Resources */ = {isa = PBXBuildFile; fileRef = 40EA6BBD1EF4598900FCCDA2 /* api_mapbox_com-digicert_2017.der */; }; + 40EA6BC31EF4599D00FCCDA2 /* api_mapbox_com-geotrust_2017.der in Resources */ = {isa = PBXBuildFile; fileRef = 40EA6BBE1EF4598900FCCDA2 /* api_mapbox_com-geotrust_2017.der */; }; + 40EA6BC41EF4599D00FCCDA2 /* api_mapbox_com-geotrust_2017.der in Resources */ = {isa = PBXBuildFile; fileRef = 40EA6BBE1EF4598900FCCDA2 /* api_mapbox_com-geotrust_2017.der */; }; 40EDA1C01CFE0E0200D9EA68 /* MGLAnnotationContainerView.h in Headers */ = {isa = PBXBuildFile; fileRef = 40EDA1BD1CFE0D4A00D9EA68 /* MGLAnnotationContainerView.h */; }; 40EDA1C11CFE0E0500D9EA68 /* MGLAnnotationContainerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 40EDA1BE1CFE0D4A00D9EA68 /* MGLAnnotationContainerView.m */; }; 40EDA1C21CFE0E0500D9EA68 /* MGLAnnotationContainerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 40EDA1BE1CFE0D4A00D9EA68 /* MGLAnnotationContainerView.m */; }; @@ -635,8 +639,8 @@ 404C26E11D89B877000AA13D /* MGLTileSource.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLTileSource.mm; sourceTree = ""; }; 404C26E61D89C515000AA13D /* MGLTileSource_Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLTileSource_Private.h; sourceTree = ""; }; 40599F001DEE1B2400182B5D /* api_mapbox_staging.der */ = {isa = PBXFileReference; lastKnownFileType = file; path = api_mapbox_staging.der; sourceTree = ""; }; - 40599F011DEE1B2400182B5D /* api_mapbox_com-digicert.der */ = {isa = PBXFileReference; lastKnownFileType = file; path = "api_mapbox_com-digicert.der"; sourceTree = ""; }; - 40599F021DEE1B2400182B5D /* api_mapbox_com-geotrust.der */ = {isa = PBXFileReference; lastKnownFileType = file; path = "api_mapbox_com-geotrust.der"; sourceTree = ""; }; + 40599F011DEE1B2400182B5D /* api_mapbox_com-digicert_2016.der */ = {isa = PBXFileReference; lastKnownFileType = file; path = "api_mapbox_com-digicert_2016.der"; sourceTree = ""; }; + 40599F021DEE1B2400182B5D /* api_mapbox_com-geotrust_2016.der */ = {isa = PBXFileReference; lastKnownFileType = file; path = "api_mapbox_com-geotrust_2016.der"; sourceTree = ""; }; 4085AF081D933DEA00F11B22 /* MGLTileSetTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLTileSetTests.mm; path = ../../darwin/test/MGLTileSetTests.mm; sourceTree = ""; }; 408AA8551DAEDA0800022900 /* NSDictionary+MGLAdditions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+MGLAdditions.h"; sourceTree = ""; }; 408AA8561DAEDA0800022900 /* NSDictionary+MGLAdditions.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSDictionary+MGLAdditions.mm"; sourceTree = ""; }; @@ -644,6 +648,8 @@ 409F43FC1E9E781C0048729D /* MGLMapViewDelegateIntegrationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MGLMapViewDelegateIntegrationTests.swift; sourceTree = ""; }; 40CF6DBA1DAC3C1800A4D18B /* MGLShape_Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLShape_Private.h; sourceTree = ""; }; 40CFA6501D787579008103BD /* MGLShapeSourceTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLShapeSourceTests.mm; path = ../../darwin/test/MGLShapeSourceTests.mm; sourceTree = ""; }; + 40EA6BBD1EF4598900FCCDA2 /* api_mapbox_com-digicert_2017.der */ = {isa = PBXFileReference; lastKnownFileType = file; path = "api_mapbox_com-digicert_2017.der"; sourceTree = ""; }; + 40EA6BBE1EF4598900FCCDA2 /* api_mapbox_com-geotrust_2017.der */ = {isa = PBXFileReference; lastKnownFileType = file; path = "api_mapbox_com-geotrust_2017.der"; sourceTree = ""; }; 40EDA1BD1CFE0D4A00D9EA68 /* MGLAnnotationContainerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLAnnotationContainerView.h; sourceTree = ""; }; 40EDA1BE1CFE0D4A00D9EA68 /* MGLAnnotationContainerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLAnnotationContainerView.m; sourceTree = ""; }; 40F8876F1D7A1DB8008ECB67 /* MGLShapeSource_Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLShapeSource_Private.h; sourceTree = ""; }; @@ -1347,8 +1353,10 @@ DAC49C5F1CD02BC9009E1AA3 /* Localizable.stringsdict */, DA8933EF1CCD387900E68420 /* strip-frameworks.sh */, 40599F001DEE1B2400182B5D /* api_mapbox_staging.der */, - 40599F011DEE1B2400182B5D /* api_mapbox_com-digicert.der */, - 40599F021DEE1B2400182B5D /* api_mapbox_com-geotrust.der */, + 40599F011DEE1B2400182B5D /* api_mapbox_com-digicert_2016.der */, + 40599F021DEE1B2400182B5D /* api_mapbox_com-geotrust_2016.der */, + 40EA6BBD1EF4598900FCCDA2 /* api_mapbox_com-digicert_2017.der */, + 40EA6BBE1EF4598900FCCDA2 /* api_mapbox_com-geotrust_2017.der */, ); name = "Kit Resources"; path = resources; @@ -2069,9 +2077,11 @@ DA8933F01CCD387900E68420 /* strip-frameworks.sh in Resources */, DAC49C5C1CD02BC9009E1AA3 /* Localizable.stringsdict in Resources */, DA8933BF1CCD2CAD00E68420 /* Foundation.stringsdict in Resources */, + 40EA6BC11EF4599600FCCDA2 /* api_mapbox_com-digicert_2017.der in Resources */, 408982E91DEE208200754016 /* api_mapbox_staging.der in Resources */, - 408982EA1DEE208B00754016 /* api_mapbox_com-digicert.der in Resources */, - 408982EB1DEE209100754016 /* api_mapbox_com-geotrust.der in Resources */, + 408982EA1DEE208B00754016 /* api_mapbox_com-digicert_2016.der in Resources */, + 40EA6BC31EF4599D00FCCDA2 /* api_mapbox_com-geotrust_2017.der in Resources */, + 408982EB1DEE209100754016 /* api_mapbox_com-geotrust_2016.der in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -2083,10 +2093,12 @@ DA8933DB1CCD31D400E68420 /* Foundation.strings in Resources */, 960D0C371ECF5AAF008E151F /* Images.xcassets in Resources */, DA8933DC1CCD31D400E68420 /* Foundation.stringsdict in Resources */, + 40EA6BC41EF4599D00FCCDA2 /* api_mapbox_com-geotrust_2017.der in Resources */, DAC49C5D1CD02BC9009E1AA3 /* Localizable.stringsdict in Resources */, 40599F0C1DEE1B7600182B5D /* api_mapbox_staging.der in Resources */, - 40599F0D1DEE1B7A00182B5D /* api_mapbox_com-digicert.der in Resources */, - 40599F0E1DEE1B7E00182B5D /* api_mapbox_com-geotrust.der in Resources */, + 40599F0D1DEE1B7A00182B5D /* api_mapbox_com-digicert_2016.der in Resources */, + 40599F0E1DEE1B7E00182B5D /* api_mapbox_com-geotrust_2016.der in Resources */, + 40EA6BC21EF4599700FCCDA2 /* api_mapbox_com-digicert_2017.der in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/platform/ios/resources/api_mapbox_com-digicert.der b/platform/ios/resources/api_mapbox_com-digicert_2016.der similarity index 100% rename from platform/ios/resources/api_mapbox_com-digicert.der rename to platform/ios/resources/api_mapbox_com-digicert_2016.der diff --git a/platform/ios/resources/api_mapbox_com-digicert_2017.der b/platform/ios/resources/api_mapbox_com-digicert_2017.der new file mode 100644 index 0000000000000000000000000000000000000000..4a190085abc17a1755a03953327b27ba9398e3eb GIT binary patch literal 2030 zcma)7dsGu=7N5xrNJv5$!~h}ze6+YE-|(hBR^F&UBSBzoP(v6)DkPYM1VN<+jD=dB z1?}#kV%uuEB4(sNuypjvkZ#ns*YW9OVXXYTX&`|fw| z9iX>(1oX5)Bbfw~NH(;(j+1qTYlUOZdqC-*%hv)X&C0_NX?V(nVFncfnJ5ET(a5_f zG=#KEgsuPxAG&zQNs62JQe`^o1H1?m8QJhU zLKGR~#S6>QV2Tthg%>YLlcz{Da;1VN!cWz94 z@@{bKSJW9e5sBH>c0!e0E74%Q_f;~9LY}>p3q=5j#@IlEDX`vu6A30S(IHl>B(}*5-&W~0-+~J)TwfXOrunwcEFZMNJkja zl8j_!7Ex3_>Ik@mmW*&PEvC?@`RPkWqO3pyS` z^lNtXedpAXxX*327eFnx1R<6P@lceeEy%P z9Rw_o5(1$rTzkpjgxOlg|0ya8kFtC{J%#Q9AXA zwZ)QAT)#EuX~97f4=z)NxtRy^rQNj9h&ka=U1@XaqrvGaQFo{9ILrDlq=Vw^XulWS z>-@*vC*y6Q7q{F9*IsM=oFne|`Lolzh70a|{}Q*OdI>iYgyXn1#v{5*PJ7CKFwI`< zAB_KUWwlA%I->1elM5&PaouA-+~raCEH7&&;wK-t(<6$$t#ZLUlbC2BpAIUV434kR zd*Z<69c@=LZ|!Rt50<+$jeoKKEc@u*3#$8hP*+YtcK!3dm%yF3-T*F4lLhMP-z%Rw z%&b}|2s-o0)Ls?_fTy*s2+&cpY_ZIkATGk=+ z>wn|m8(WT7+Vt&%R+qwqm&-qMKh;>46A_S5L2rtkaxAG#@he(AaQxMYD_&Qcm#AMn zUO7AuoeT2g)+Sa+zwaMy66N21Sj{i!8M-Ilh2xsPKC`xZW@CofNfqGw@E7j5F4w*F zD--tszuse^Rf)a15Ak0Yz7Jt2ftghuojKNto*b>~bN$qPQn<4?N;17E+JEB76|GO8 z*#@^dx$~F1UxJe%%6K2|{dZoT4!>}P90-h{GFq44Wh!UvC z#sHQ%Fx44ED%n#Y*&vIRD=_bv2nGuSb9H_k)neMedJ`59uoiQ3#g<^6-+;LmWY$vP z#Nq(`6Qnhrbtc=9E>7G{~ z)k7;YjDKBtFPnXE6(Ya%w#}yei0PA@#v5BJ?P|K!Y4^gK^BvdN$^MNhEisu$vrCLTR6jB!^Qy9&V?~aZL z*IkCrh>(ea>a;EzLsca}bsVU&2s8ClH)0DDfNCH3mSCW@@%R}CZ0@Lok!x|3N+m-m zkSKIBug8)J? z`|&4{%h*3{gp18G zjF$FwWzv&wnTq>z|FU%-N)QY5iagdkxAfcmOG( z(x#c2b+pZ}THcWgm-YU&yiOun z)p+7u!NVs0gui{!+HS81B1803W1Ti+YB=Ao$GP`@q)S(4zq|kW+y$>ZqCYV2<_})~ zpkciBgkqs#pGys~9ow2UJdt&!=J<}2#z|qdvhEb9FanK6X2gRZ!2Ev|mj;&(J-tEjYj z{_Ec3a6naf=?R$B6%*R9H^*1OU2JyV^(eb$L%zReo}W*u7p+q|SoMDMxHKvyVGHGb z^~7VRgPGfo*?B9@_^eGS>tGpdamw_v4L=mj7e@^|RNh{a%xlIDhsNi1uvN}DT3lAP X`ziZzd_%ivn5ZGFE)pcbVYYt*fl7FM literal 0 HcmV?d00001 diff --git a/platform/ios/src/MGLAPIClient.m b/platform/ios/src/MGLAPIClient.m index 124d4361975..8a987d76d88 100644 --- a/platform/ios/src/MGLAPIClient.m +++ b/platform/ios/src/MGLAPIClient.m @@ -17,8 +17,10 @@ @interface MGLAPIClient () @property (nonatomic, copy) NSURLSession *session; @property (nonatomic, copy) NSURL *baseURL; -@property (nonatomic, copy) NSData *digicertCert; -@property (nonatomic, copy) NSData *geoTrustCert; +@property (nonatomic, copy) NSData *digicertCert_2016; +@property (nonatomic, copy) NSData *geoTrustCert_2016; +@property (nonatomic, copy) NSData *digicertCert_2017; +@property (nonatomic, copy) NSData *geoTrustCert_2017; @property (nonatomic, copy) NSData *testServerCert; @property (nonatomic, copy) NSString *userAgent; @property (nonatomic) BOOL usesTestServer; @@ -107,10 +109,14 @@ - (void)setupBaseURL { - (void)loadCertificates { NSData *certificate; - [self loadCertificate:&certificate withResource:@"api_mapbox_com-geotrust"]; - self.geoTrustCert = certificate; - [self loadCertificate:&certificate withResource:@"api_mapbox_com-digicert"]; - self.digicertCert = certificate; + [self loadCertificate:&certificate withResource:@"api_mapbox_com-geotrust_2016"]; + self.geoTrustCert_2016 = certificate; + [self loadCertificate:&certificate withResource:@"api_mapbox_com-digicert_2016"]; + self.digicertCert_2016 = certificate; + [self loadCertificate:&certificate withResource:@"api_mapbox_com-geotrust_2017"]; + self.geoTrustCert_2017 = certificate; + [self loadCertificate:&certificate withResource:@"api_mapbox_com-digicert_2017"]; + self.digicertCert_2017 = certificate; [self loadCertificate:&certificate withResource:@"api_mapbox_staging"]; self.testServerCert = certificate; } @@ -141,75 +147,53 @@ - (NSData *)serializedDataForEvents:(NS_ARRAY_OF(MGLMapboxEventAttributes *) *)e #pragma mark NSURLSessionDelegate +- (BOOL)evaluateCertificateWithCertificateData:(NSData *)certificateData keyCount:(CFIndex)keyCount serverTrust:(SecTrustRef)serverTrust challenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^) (NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler { + for (int lc = 0; lc < keyCount; lc++) { + SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, lc); + NSData *remoteCertificateData = CFBridgingRelease(SecCertificateCopyData(certificate)); + if ([remoteCertificateData isEqualToData:certificateData]) { + completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]); + return YES; + } + } + return NO; +} + - (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^) (NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler { + if([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) { - SecTrustRef serverTrust = [[challenge protectionSpace] serverTrust]; SecTrustResultType trustResult; - - // Validate the certificate chain with the device's trust store anyway - // This *might* give use revocation checking + + // Validate the certificate chain with the device's trust store anyway this *might* use revocation checking SecTrustEvaluate(serverTrust, &trustResult); - if (trustResult == kSecTrustResultUnspecified) - { + + BOOL found = NO; // For clarity; we start in a state where the challange has not been completed and no certificate has been found + + if (trustResult == kSecTrustResultUnspecified) { // Look for a pinned certificate in the server's certificate chain - long numKeys = SecTrustGetCertificateCount(serverTrust); - - BOOL found = NO; - // Try GeoTrust Cert First - for (int lc = 0; lc < numKeys; lc++) { - SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, lc); - NSData *remoteCertificateData = CFBridgingRelease(SecCertificateCopyData(certificate)); - - // Compare Remote Key With Local Version - if ([remoteCertificateData isEqualToData:_geoTrustCert]) { - // Found the certificate; continue connecting - completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]); - found = YES; - break; - } + CFIndex numKeys = SecTrustGetCertificateCount(serverTrust); + + // Check certs in the following order: digicert 2016, digicert 2017, geotrust 2016, geotrust 2017 + found = [self evaluateCertificateWithCertificateData:self.digicertCert_2016 keyCount:numKeys serverTrust:serverTrust challenge:challenge completionHandler:completionHandler]; + if (!found) { + found = [self evaluateCertificateWithCertificateData:self.digicertCert_2017 keyCount:numKeys serverTrust:serverTrust challenge:challenge completionHandler:completionHandler]; } - if (!found) { - // Fallback to Digicert Cert - for (int lc = 0; lc < numKeys; lc++) { - SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, lc); - NSData *remoteCertificateData = CFBridgingRelease(SecCertificateCopyData(certificate)); - - // Compare Remote Key With Local Version - if ([remoteCertificateData isEqualToData:_digicertCert]) { - // Found the certificate; continue connecting - completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]); - found = YES; - break; - } - } - - if (!found && _usesTestServer) { - // See if this is test server - for (int lc = 0; lc < numKeys; lc++) { - SecCertificateRef certificate = SecTrustGetCertificateAtIndex(serverTrust, lc); - NSData *remoteCertificateData = CFBridgingRelease(SecCertificateCopyData(certificate)); - - // Compare Remote Key With Local Version - if ([remoteCertificateData isEqualToData:_testServerCert]) { - // Found the certificate; continue connecting - completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]); - found = YES; - break; - } - } - } - - if (!found) { - // The certificate wasn't found in GeoTrust nor Digicert. Cancel the connection. - completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]); - } + found = [self evaluateCertificateWithCertificateData:self.geoTrustCert_2016 keyCount:numKeys serverTrust:serverTrust challenge:challenge completionHandler:completionHandler]; + } + if (!found) { + found = [self evaluateCertificateWithCertificateData:self.geoTrustCert_2017 keyCount:numKeys serverTrust:serverTrust challenge:challenge completionHandler:completionHandler]; + } + + // If challenge can't be completed with any of the above certs, then try the test server if the app is configured to use the test server + if (!found && _usesTestServer) { + found = [self evaluateCertificateWithCertificateData:self.testServerCert keyCount:numKeys serverTrust:serverTrust challenge:challenge completionHandler:completionHandler]; } } - else - { - // Certificate chain validation failed; cancel the connection + + if (!found) { + // No certificate was found so cancel the connection. completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]); } } From f6bfa078af45701d4c62e6993cf83147636cede5 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 19 Jun 2017 12:26:58 -0700 Subject: [PATCH 3/8] [core] Trigger repaint on source changes --- src/mbgl/style/sources/geojson_source.cpp | 2 ++ src/mbgl/style/style.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/src/mbgl/style/sources/geojson_source.cpp b/src/mbgl/style/sources/geojson_source.cpp index 110c1cd63c2..992f82b1e79 100644 --- a/src/mbgl/style/sources/geojson_source.cpp +++ b/src/mbgl/style/sources/geojson_source.cpp @@ -1,5 +1,6 @@ #include #include +#include namespace mbgl { namespace style { @@ -16,6 +17,7 @@ void GeoJSONSource::setURL(const std::string& url) { void GeoJSONSource::setGeoJSON(const mapbox::geojson::geojson& geoJSON) { impl->setGeoJSON(geoJSON); + impl->observer->onSourceChanged(*this); } optional GeoJSONSource::getURL() const { diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp index 568b575dfa0..f1ac22082b8 100644 --- a/src/mbgl/style/style.cpp +++ b/src/mbgl/style/style.cpp @@ -725,6 +725,7 @@ void Style::onSourceLoaded(Source& source) { void Style::onSourceChanged(Source& source) { observer->onSourceChanged(source); + observer->onUpdate(Update::Repaint); } void Style::onSourceError(Source& source, std::exception_ptr error) { From 78322a3f16ba996dfbcb3acc74d9db31d4d0cd69 Mon Sep 17 00:00:00 2001 From: Tobrun Date: Tue, 20 Jun 2017 09:16:55 +0200 Subject: [PATCH 4/8] [android] - update activity test generation with newest classes, make FillExtrusionActivity conform to generated activity test setup. (#9276) --- .../testapp/activity/style/FillExtrusionActivity.java | 9 +++++---- platform/android/scripts/generate-test-code.js | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/FillExtrusionActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/FillExtrusionActivity.java index 9a7790c6e53..52ba8d7c7b4 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/FillExtrusionActivity.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/FillExtrusionActivity.java @@ -26,6 +26,7 @@ public class FillExtrusionActivity extends AppCompatActivity { private MapView mapView; + private MapboxMap mapboxMap; @Override public void onCreate(Bundle savedInstanceState) { @@ -36,8 +37,8 @@ public void onCreate(Bundle savedInstanceState) { mapView.onCreate(savedInstanceState); mapView.getMapAsync(new OnMapReadyCallback() { @Override - public void onMapReady(@NonNull - final MapboxMap map) { + public void onMapReady(@NonNull final MapboxMap map) { + mapboxMap = map; Polygon domTower = Polygon.fromCoordinates(new double[][][] { new double[][] { new double[] { @@ -66,7 +67,7 @@ public void onMapReady(@NonNull GeoJsonSource source = new GeoJsonSource("extrusion-source", domTower); map.addSource(source); - map.addLayer( + mapboxMap.addLayer( new FillExtrusionLayer("extrusion-layer", source.getId()) .withProperties( fillExtrusionHeight(40f), @@ -75,7 +76,7 @@ public void onMapReady(@NonNull ) ); - map.animateCamera( + mapboxMap.animateCamera( CameraUpdateFactory.newCameraPosition( new CameraPosition.Builder() .target(new LatLng(52.09071040847704, 5.12112557888031)) diff --git a/platform/android/scripts/generate-test-code.js b/platform/android/scripts/generate-test-code.js index b054e4a2e7d..01a294a3016 100644 --- a/platform/android/scripts/generate-test-code.js +++ b/platform/android/scripts/generate-test-code.js @@ -14,7 +14,7 @@ global.camelize = function (str) { } -const excludeActivities = ["DeleteRegionActivity","RealTimeGeoJsonActivity","UpdateMetadataActivity","CarDrivingActivity","MyLocationTrackingModeActivity","MyLocationToggleActivity","MyLocationTintActivity","MyLocationDrawableActivity","DoubleMapActivity", "LocationPickerActivity","GeoJsonClusteringActivity","RuntimeStyleTestActivity", "AnimatedMarkerActivity", "ViewPagerActivity","MapFragmentActivity","SupportMapFragmentActivity","SnapshotActivity","NavigationDrawerActivity", "QueryRenderedFeaturesBoxHighlightActivity", "MultiMapActivity", "MapInDialogActivity", "SimpleMapActivity"]; +const excludeActivities = ["BaseLocationActivity","MockLocationEngine","DeleteRegionActivity","RealTimeGeoJsonActivity","UpdateMetadataActivity","CarDrivingActivity","MyLocationTrackingModeActivity","MyLocationToggleActivity","MyLocationTintActivity","MyLocationDrawableActivity","DoubleMapActivity", "LocationPickerActivity","GeoJsonClusteringActivity","RuntimeStyleTestActivity", "AnimatedMarkerActivity", "ViewPagerActivity","MapFragmentActivity","SupportMapFragmentActivity","SnapshotActivity","NavigationDrawerActivity", "QueryRenderedFeaturesBoxHighlightActivity", "MultiMapActivity", "MapInDialogActivity", "SimpleMapActivity"]; const appBasePath = 'platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity'; const testBasePath = 'platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/activity/gen'; const subPackages = fs.readdirSync(appBasePath); From 399c0071f856ad162905f32aa6516516ee59c7b1 Mon Sep 17 00:00:00 2001 From: Tobrun Date: Tue, 20 Jun 2017 09:17:09 +0200 Subject: [PATCH 5/8] Validate camera position before transforming (#9275) * [android] - add camera position validation before transforming * annotate CameraUpdate with nullability --- .../java/com/mapbox/mapboxsdk/camera/CameraUpdate.java | 2 ++ .../main/java/com/mapbox/mapboxsdk/maps/Transform.java | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdate.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdate.java index 7e0dbf08fbd..498aa8343b7 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdate.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraUpdate.java @@ -1,6 +1,7 @@ package com.mapbox.mapboxsdk.camera; import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import com.mapbox.mapboxsdk.maps.MapboxMap; @@ -9,6 +10,7 @@ */ public interface CameraUpdate { + @Nullable CameraPosition getCameraPosition(@NonNull MapboxMap mapboxMap); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java index 505e440dcb9..89fbb795040 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java @@ -93,7 +93,7 @@ public void onMapChanged(@MapView.MapChange int change) { @UiThread final void moveCamera(MapboxMap mapboxMap, CameraUpdate update, MapboxMap.CancelableCallback callback) { CameraPosition cameraPosition = update.getCameraPosition(mapboxMap); - if (!cameraPosition.equals(this.cameraPosition)) { + if (isValidCameraPosition(cameraPosition)) { trackingSettings.resetTrackingModesIfRequired(this.cameraPosition, cameraPosition, false); cancelTransitions(); cameraChangeDispatcher.onCameraMoveStarted(OnCameraMoveStartedListener.REASON_API_ANIMATION); @@ -109,7 +109,7 @@ final void moveCamera(MapboxMap mapboxMap, CameraUpdate update, MapboxMap.Cancel final void easeCamera(MapboxMap mapboxMap, CameraUpdate update, int durationMs, boolean easingInterpolator, final MapboxMap.CancelableCallback callback, boolean isDismissable) { CameraPosition cameraPosition = update.getCameraPosition(mapboxMap); - if (!cameraPosition.equals(this.cameraPosition)) { + if (isValidCameraPosition(cameraPosition)) { trackingSettings.resetTrackingModesIfRequired(this.cameraPosition, cameraPosition, isDismissable); cancelTransitions(); cameraChangeDispatcher.onCameraMoveStarted(OnCameraMoveStartedListener.REASON_API_ANIMATION); @@ -127,7 +127,7 @@ final void easeCamera(MapboxMap mapboxMap, CameraUpdate update, int durationMs, final void animateCamera(MapboxMap mapboxMap, CameraUpdate update, int durationMs, final MapboxMap.CancelableCallback callback) { CameraPosition cameraPosition = update.getCameraPosition(mapboxMap); - if (!cameraPosition.equals(this.cameraPosition)) { + if (isValidCameraPosition(cameraPosition)) { trackingSettings.resetTrackingModesIfRequired(this.cameraPosition, cameraPosition, false); cancelTransitions(); cameraChangeDispatcher.onCameraMoveStarted(OnCameraMoveStartedListener.REASON_API_ANIMATION); @@ -141,6 +141,10 @@ final void animateCamera(MapboxMap mapboxMap, CameraUpdate update, int durationM } } + private boolean isValidCameraPosition(@Nullable CameraPosition cameraPosition) { + return cameraPosition != null && !cameraPosition.equals(this.cameraPosition); + } + @UiThread @Nullable CameraPosition invalidateCameraPosition() { From 20cb791b4ca1b449157d8ea02f256807dd7bc9f3 Mon Sep 17 00:00:00 2001 From: Pablo Guardiola Date: Tue, 20 Jun 2017 09:24:07 +0200 Subject: [PATCH 6/8] [android] fix custom marker views anchor issue (#9282) --- .../annotations/MarkerViewManager.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java index bb51f3bfc29..b9e9bea4ede 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java @@ -10,6 +10,7 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.ViewTreeObserver; import android.widget.ImageView; import com.mapbox.mapboxsdk.R; @@ -33,6 +34,15 @@ public class MarkerViewManager implements MapView.OnMapChangedListener { private final ViewGroup markerViewContainer; + private final ViewTreeObserver.OnPreDrawListener markerViewPreDrawObserver = + new ViewTreeObserver.OnPreDrawListener() { + @Override + public boolean onPreDraw() { + invalidateViewMarkersInVisibleRegion(); + markerViewContainer.getViewTreeObserver().removeOnPreDrawListener(markerViewPreDrawObserver); + return false; + } + }; private final Map markerViewMap = new HashMap<>(); private final LongSparseArray markerViewAddedListenerMap = new LongSparseArray<>(); private final List markerViewAdapters = new ArrayList<>(); @@ -180,14 +190,16 @@ public void updateMarkerViewsPosition() { PointF point = mapboxMap.getProjection().toScreenLocation(marker.getPosition()); if (marker.getOffsetX() == MapboxConstants.UNMEASURED) { // ensure view is measured first + // #6805 invalidate marker views to ensure convertView width and height + // values are properly measured and up to date if (marker.getWidth() == 0) { - convertView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); - if (convertView.getMeasuredWidth() != 0) { - marker.setWidth(convertView.getMeasuredWidth()); - marker.setHeight(convertView.getMeasuredHeight()); - } + convertView.getViewTreeObserver().addOnPreDrawListener(markerViewPreDrawObserver); } } + + marker.setWidth(convertView.getWidth()); + marker.setHeight(convertView.getHeight()); + if (marker.getWidth() != 0) { int x = (int) (marker.getAnchorU() * marker.getWidth()); int y = (int) (marker.getAnchorV() * marker.getHeight()); From 985ff4cc1883d606b3770a34d384ade71f71bbdc Mon Sep 17 00:00:00 2001 From: Pablo Guardiola Date: Tue, 20 Jun 2017 09:24:43 +0200 Subject: [PATCH 7/8] [android] fix pulse marker view options parcelable creator (#9283) --- .../model/annotations/PulseMarkerViewOptions.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerViewOptions.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerViewOptions.java index d9c63577749..d752e5d0ef4 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerViewOptions.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/model/annotations/PulseMarkerViewOptions.java @@ -66,14 +66,14 @@ public PulseMarkerView getMarker() { return new PulseMarkerView(this); } - public static final Parcelable.Creator CREATOR - = new Parcelable.Creator() { - public CountryMarkerViewOptions createFromParcel(Parcel in) { - return new CountryMarkerViewOptions(in); + public static final Parcelable.Creator CREATOR + = new Parcelable.Creator() { + public PulseMarkerViewOptions createFromParcel(Parcel in) { + return new PulseMarkerViewOptions(in); } - public CountryMarkerViewOptions[] newArray(int size) { - return new CountryMarkerViewOptions[size]; + public PulseMarkerViewOptions[] newArray(int size) { + return new PulseMarkerViewOptions[size]; } }; } From 78426f1423ad3b739d7f7fa1fd7f248146281fa2 Mon Sep 17 00:00:00 2001 From: Pablo Guardiola Date: Tue, 20 Jun 2017 10:01:02 +0200 Subject: [PATCH 8/8] fix trackball long press timeout calling the main thread method on a background thread (#9305) --- .../main/java/com/mapbox/mapboxsdk/maps/MapKeyListener.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapKeyListener.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapKeyListener.java index 71752422828..d1f01a30f76 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapKeyListener.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapKeyListener.java @@ -2,6 +2,7 @@ import android.graphics.PointF; import android.os.Handler; +import android.os.Looper; import android.support.annotation.NonNull; import android.view.KeyEvent; import android.view.MotionEvent; @@ -204,7 +205,7 @@ boolean onTrackballEvent(MotionEvent event) { currentTrackballLongPressTimeOut = null; } currentTrackballLongPressTimeOut = new TrackballLongPressTimeOut(); - new Handler().postDelayed(currentTrackballLongPressTimeOut, + new Handler(Looper.getMainLooper()).postDelayed(currentTrackballLongPressTimeOut, ViewConfiguration.getLongPressTimeout()); return true;