diff options
author | zmiao <zmiao.jamie@gmail.com> | 2019-07-31 21:07:16 +0300 |
---|---|---|
committer | zmiao <zmiao.jamie@gmail.com> | 2019-07-31 21:07:16 +0300 |
commit | 7f36cd2b5692d2ee861d080149ce2edd0a95de48 (patch) | |
tree | 0f6ccca43a89a889b0cca256559848601e60b80f | |
parent | 10c0c688ecff69da254e2770573f200abf5c0e24 (diff) | |
parent | c9c46ce9fc8be6f14f2dded00c746b6d8c7e4eec (diff) | |
download | qtlocation-mapboxgl-7f36cd2b5692d2ee861d080149ce2edd0a95de48.tar.gz |
Merge branch 'master' into clusterProperties_aggregation
82 files changed, 766 insertions, 475 deletions
diff --git a/.gitmodules b/.gitmodules index 486a1c8bdc..185a92c41f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -19,9 +19,6 @@ [submodule "vendor/geojson.hpp"] path = vendor/geojson.hpp url = https://github.com/mapbox/geojson.hpp.git -[submodule "vendor/geometry.hpp"] - path = vendor/geometry.hpp - url = https://github.com/mapbox/geometry.hpp.git [submodule "vendor/polylabel"] path = vendor/polylabel url = https://github.com/mapbox/polylabel.git @@ -34,9 +31,6 @@ [submodule "vendor/supercluster.hpp"] path = vendor/supercluster.hpp url = https://github.com/mapbox/supercluster.hpp.git -[submodule "vendor/variant"] - path = vendor/variant - url = https://github.com/mapbox/variant.git [submodule "vendor/vector-tile"] path = vendor/vector-tile url = https://github.com/mapbox/vector-tile.git @@ -55,9 +49,6 @@ [submodule "vendor/icu"] path = vendor/icu url = https://github.com/unicode-org/icu.git -[submodule "vendor/optional"] - path = vendor/optional - url = https://github.com/mapbox/Optional.git [submodule "vendor/boost"] path = vendor/boost url = https://github.com/mapbox/mapbox-gl-native-boost.git @@ -103,3 +94,6 @@ [submodule "vendor/filesystem"] path = vendor/filesystem url = https://github.com/gulrak/filesystem.git +[submodule "vendor/mapbox-base"] + path = vendor/mapbox-base + url = https://github.com/mapbox/mapbox-base.git diff --git a/appveyor.yml b/appveyor.yml index 53970e1ac5..0e1bd01124 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -62,6 +62,7 @@ install: - git config --system core.longpaths true - git submodule sync - git submodule update --init + - git submodule foreach git submodule update --init - ps: | if (!(Test-Path cmake-3.10.1-win64-x64.zip)) { appveyor DownloadFile https://cmake.org/files/v3.10/cmake-3.10.1-win64-x64.zip diff --git a/benchmark/src/mbgl/benchmark/stub_geometry_tile_feature.hpp b/benchmark/src/mbgl/benchmark/stub_geometry_tile_feature.hpp index bff1a23ba8..b8f2ffb5b9 100644 --- a/benchmark/src/mbgl/benchmark/stub_geometry_tile_feature.hpp +++ b/benchmark/src/mbgl/benchmark/stub_geometry_tile_feature.hpp @@ -35,7 +35,7 @@ public: return properties.count(key) ? properties.at(key) : optional<Value>(); } - GeometryCollection getGeometries() const override { + const GeometryCollection& getGeometries() const override { return geometry; } }; diff --git a/circle.yml b/circle.yml index a60e83fa72..ff35e4456d 100644 --- a/circle.yml +++ b/circle.yml @@ -477,7 +477,9 @@ jobs: - install-dependencies: { mason: false, ccache: false } - run: name: Initialize submodules - command: git submodule update --init + command: | + git submodule update --init + git submodule foreach git submodule update --init - run: name: Verify submodule pin command: scripts/nitpick/submodule-pin.js @@ -720,7 +722,9 @@ jobs: - checkout - run: name: Checkout submodules - command: git submodule update --init + command: | + git submodule update --init + git submodule foreach git submodule update --init - run: name: Build Android library command: | @@ -890,9 +894,7 @@ jobs: - run: name: Upload coverage results to codecov.io command: | - curl -sSfL -o codecov https://codecov.io/bash - chmod +x codecov - ./codecov -c + bash <(curl -sSfL https://codecov.io/bash) || echo 'Codecov failed to upload' - run: name: Upload coverage metrics to s3 command: | @@ -1072,9 +1074,18 @@ jobs: if [[ $CIRCLE_BRANCH == master ]]; then platform/ios/scripts/deploy-snapshot.sh fi + background: true + - deploy: + name: Deploy to Mapbox CocoaPods spec repo + command: | + if [[ $CIRCLE_BRANCH == master ]]; then + platform/ios/scripts/deploy-to-cocoapods.sh + fi + background: true - run: name: Record size command: platform/ios/scripts/metrics.sh + background: true - run: name: Trigger metrics command: | @@ -1085,6 +1096,7 @@ jobs: echo "MOBILE_METRICS_TOKEN not provided" fi fi + background: true - save-dependencies - collect-xcode-build-logs - upload-xcode-build-logs @@ -1110,12 +1122,22 @@ jobs: - install-dependencies - install-ios-packaging-dependencies - run: + name: Trigger external deploy steps + command: | + export VERSION_TAG=${CIRCLE_TAG} + export GITHUB_TOKEN=${DANGER_GITHUB_API_TOKEN} + platform/ios/scripts/trigger-external-deploy-steps.sh + background: true + - run: name: Build, package, and upload iOS release command: | export VERSION_TAG=${CIRCLE_TAG} export GITHUB_TOKEN=${DANGER_GITHUB_API_TOKEN} platform/ios/scripts/deploy-packages.sh - platform/ios/scripts/trigger-external-deploy-steps.sh + - deploy: + name: Deploy to CocoaPods + command: platform/ios/scripts/deploy-to-cocoapods.sh + background: true - save-dependencies - collect-xcode-build-logs - upload-xcode-build-logs diff --git a/cmake/core.cmake b/cmake/core.cmake index 3278c4f7d3..abb55d174a 100644 --- a/cmake/core.cmake +++ b/cmake/core.cmake @@ -28,14 +28,12 @@ endif() # libraries in our public interface. target_link_libraries(mbgl-core PUBLIC boost + mapbox-base geojson.hpp - geometry.hpp ${ICU_LIBRARY} - optional polylabel protozero rapidjson - variant vector-tile ) diff --git a/cmake/loop-darwin.cmake b/cmake/loop-darwin.cmake index 46d8f9edc0..9e52639c52 100644 --- a/cmake/loop-darwin.cmake +++ b/cmake/loop-darwin.cmake @@ -8,7 +8,7 @@ target_include_directories(mbgl-loop-darwin ) target_link_libraries(mbgl-loop-darwin PUBLIC - optional + mapbox-base ) create_source_groups(mbgl-loop-darwin) diff --git a/cmake/vendor.cmake b/cmake/vendor.cmake index bc1bad757f..03e34ccbd9 100644 --- a/cmake/vendor.cmake +++ b/cmake/vendor.cmake @@ -12,12 +12,10 @@ include(${CMAKE_SOURCE_DIR}/vendor/expected.cmake) include(${CMAKE_SOURCE_DIR}/vendor/filesystem.cmake) include(${CMAKE_SOURCE_DIR}/vendor/geojson-vt-cpp.cmake) include(${CMAKE_SOURCE_DIR}/vendor/geojson.hpp.cmake) -include(${CMAKE_SOURCE_DIR}/vendor/geometry.hpp.cmake) include(${CMAKE_SOURCE_DIR}/vendor/icu.cmake) include(${CMAKE_SOURCE_DIR}/vendor/jni.hpp.cmake) include(${CMAKE_SOURCE_DIR}/vendor/kdbush.hpp.cmake) include(${CMAKE_SOURCE_DIR}/vendor/nunicode.cmake) -include(${CMAKE_SOURCE_DIR}/vendor/optional.cmake) include(${CMAKE_SOURCE_DIR}/vendor/pixelmatch-cpp.cmake) include(${CMAKE_SOURCE_DIR}/vendor/polylabel.cmake) include(${CMAKE_SOURCE_DIR}/vendor/protozero.cmake) @@ -25,11 +23,14 @@ include(${CMAKE_SOURCE_DIR}/vendor/rapidjson.cmake) include(${CMAKE_SOURCE_DIR}/vendor/shelf-pack-cpp.cmake) include(${CMAKE_SOURCE_DIR}/vendor/supercluster.hpp.cmake) include(${CMAKE_SOURCE_DIR}/vendor/unique_resource.cmake) -include(${CMAKE_SOURCE_DIR}/vendor/variant.cmake) include(${CMAKE_SOURCE_DIR}/vendor/vector-tile.cmake) include(${CMAKE_SOURCE_DIR}/vendor/wagyu.cmake) include(${CMAKE_SOURCE_DIR}/vendor/args.cmake) +if(NOT TARGET mapbox-base) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/vendor/mapbox-base ${CMAKE_BINARY_DIR}/.build-mapbox-gl-native-mapbox-base) +endif() + if(MBGL_PLATFORM STREQUAL "linux" OR MBGL_PLATFORM STREQUAL "macos") include(${CMAKE_SOURCE_DIR}/vendor/glfw.cmake) endif() diff --git a/misc/buck/mapbox-gl-native/BUCK b/misc/buck/mapbox-gl-native/BUCK index df6a9d563a..ed264e9756 100644 --- a/misc/buck/mapbox-gl-native/BUCK +++ b/misc/buck/mapbox-gl-native/BUCK @@ -45,11 +45,10 @@ mbgl_vendor_library("expected") mbgl_vendor_library("eternal") mbgl_vendor_library("geojson.hpp") mbgl_vendor_library("geojson-vt-cpp") -mbgl_vendor_library("geometry.hpp") mbgl_vendor_library("jni.hpp") mbgl_vendor_library("kdbush.hpp") +mbgl_vendor_library("mapbox-base") mbgl_vendor_library("sqlite") -mbgl_vendor_library("optional") mbgl_vendor_library("pixelmatch-cpp") mbgl_vendor_library("polylabel") mbgl_vendor_library("protozero") @@ -57,7 +56,6 @@ mbgl_vendor_library("rapidjson") mbgl_vendor_library("shelf-pack-cpp") mbgl_vendor_library("supercluster.hpp") mbgl_vendor_library("unique_resource") -mbgl_vendor_library("variant") mbgl_vendor_library("vector-tile") mbgl_vendor_library("wagyu") diff --git a/platform/android/CHANGELOG.md b/platform/android/CHANGELOG.md index cf9e1b5819..6aa8c8ffc0 100644 --- a/platform/android/CHANGELOG.md +++ b/platform/android/CHANGELOG.md @@ -2,10 +2,52 @@ Mapbox welcomes participation and contributions from everyone. If you'd like to do so please see the [`Contributing Guide`](https://github.com/mapbox/mapbox-gl-native/blob/master/CONTRIBUTING.md) first to get started. -## master +## 8.3.0-alpha.1 - July 31, 2019 +[Changes](https://github.com/mapbox/mapbox-gl-native/compare/android-v8.2.0...android-v8.3.0-alpha.1) since [Mapbox Maps SDK for Android v8.2.0](https://github.com/mapbox/mapbox-gl-native/releases/tag/android-v8.2.0): + +### Features + - Do not include CJK ideographs in the offline packs by default. This decreases overall offline download size but changes appereance by a default set local glyph generation [#14269](https://github.com/mapbox/mapbox-gl-native/pull/14269) + - Update target SDK to 28, update support library and fix gradle warnings [#15135](https://github.com/mapbox/mapbox-gl-native/pull/15135) + - Introduce VertexVector::extend() and use it in placement code [#15194](https://github.com/mapbox/mapbox-gl-native/pull/15194) ### Bug fixes + - Save location animation timestamp only when fed. Fixes an issue where external camera updates impacted location animation duration[#15265](https://github.com/mapbox/mapbox-gl-native/pull/15265) - Fixed flickering on style change for the same tile set [#15127](https://github.com/mapbox/mapbox-gl-native/pull/15127) + - Fix location render/camera modes being reinitialized even when the new mode is the same [#15266](https://github.com/mapbox/mapbox-gl-native/pull/15266) + - Ensure default local ideographs font family is not overwrote. Fix a bug that prevented local CJK glyphs generation. The local generation is now enabled by default and the font family used for generation is set to "sans-serif. [#15253](https://github.com/mapbox/mapbox-gl-native/pull/15253) + - Fix int overflow issue in GridIndex [#15245](https://github.com/mapbox/mapbox-gl-native/pull/15245) + - Align gesture animation reason for onCameraMoveStarted [#15218](https://github.com/mapbox/mapbox-gl-native/pull/15218) + - Remove layers first when clearing the style, fixes unnecessary log dumps [#15191](https://github.com/mapbox/mapbox-gl-native/pull/15191) + - Remove unused field from icon buffer [#15189](https://github.com/mapbox/mapbox-gl-native/pull/15189) + +### Performance improvements + - Release quad data after vertex buffers are created [#15189](https://github.com/mapbox/mapbox-gl-native/pull/15189) + - Decrease size of SymbolBucket [#15178](https://github.com/mapbox/mapbox-gl-native/pull/15178) + - Avoid geometry collections copying [#15201](https://github.com/mapbox/mapbox-gl-native/pull/15201) + +## 8.2.1 - July 31, 2019 +[Changes](https://github.com/mapbox/mapbox-gl-native/compare/android-v8.2.0...android-v8.2.1) since [Mapbox Maps SDK for Android v8.2.0](https://github.com/mapbox/mapbox-gl-native/releases/tag/android-v8.2.0): + +### Bug fixes + - Save location animation timestamp only when fed [#15265](https://github.com/mapbox/mapbox-gl-native/pull/15265) + +## 8.1.1 - July 26, 2019 +[Changes](https://github.com/mapbox/mapbox-gl-native/compare/android-v8.1.0...android-v8.1.1) since [Mapbox Maps SDK for Android v8.1.0](https://github.com/mapbox/mapbox-gl-native/releases/tag/android-v8.1.0): + +### Bug fixes + - Fixed rendering layers after fill-extrusion regression caused by optimization of fill-extrusion rendering [#15065](https://github.com/mapbox/mapbox-gl-native/pull/15065) + - Fixed a map update bug caused by the render tiles and the render passes getting unsynchronized [#15092](https://github.com/mapbox/mapbox-gl-native/pull/15092) + - Fixed collision with content insets [#15130](https://github.com/mapbox/mapbox-gl-native/pull/15130) + - Fixed a custom geometry source bug caused by using the outdated tiles after style update [#15112](https://github.com/mapbox/mapbox-gl-native/pull/15112) + - Allow map panning after quick zoom is disabled but a phantom gesture is executed [#15093](https://github.com/mapbox/mapbox-gl-native/pull/15093) + - Ensure location shadow's gradient radius is greater than 0 [#15099](https://github.com/mapbox/mapbox-gl-native/pull/15099) + - Ensure that move detector is enabled if double-tap is interrupted [#15103](https://github.com/mapbox/mapbox-gl-native/pull/15103) + +## 8.2.0 - July 24, 2019 +[Changes](https://github.com/mapbox/mapbox-gl-native/compare/android-v8.2.0-beta.1...android-v8.2.0) since [Mapbox Maps SDK for Android v8.2.0-beta.1](https://github.com/mapbox/mapbox-gl-native/releases/tag/android-v8.2.0-beta.1): + +### Bug fixes + - Fix rendering of layers that are on top of fill-extrusion layers [#15065](https://github.com/mapbox/mapbox-gl-native/pull/15065) ## 8.2.0-beta.1 - July 18, 2019 [Changes](https://github.com/mapbox/mapbox-gl-native/compare/android-v8.2.0-alpha.3...android-v8.2.0-beta.1) since [Mapbox Maps SDK for Android v8.2.0-alpha.3](https://github.com/mapbox/mapbox-gl-native/releases/tag/android-v8.2.0-alpha.3): diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationAnimatorCoordinator.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationAnimatorCoordinator.java index 6337287770..5aad038a28 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationAnimatorCoordinator.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationAnimatorCoordinator.java @@ -94,8 +94,23 @@ final class LocationAnimatorCoordinator { boolean snap = immediateAnimation(projection, previousCameraLatLng, targetLatLng) || immediateAnimation(projection, previousLayerLatLng, targetLatLng); - playAnimators( - snap ? 0 : getAnimationDuration(), + + long animationDuration = 0; + if (!snap) { + long previousUpdateTimeStamp = locationUpdateTimestamp; + locationUpdateTimestamp = SystemClock.elapsedRealtime(); + + if (previousUpdateTimeStamp == 0) { + animationDuration = 0; + } else { + animationDuration = (long) ((locationUpdateTimestamp - previousUpdateTimeStamp) * durationMultiplier) + /* make animation slightly longer with durationMultiplier, defaults to 1.1f */; + } + + animationDuration = Math.min(animationDuration, MAX_ANIMATION_DURATION_MS); + } + + playAnimators(animationDuration, ANIMATOR_LAYER_LATLNG, ANIMATOR_LAYER_GPS_BEARING, ANIMATOR_CAMERA_LATLNG, @@ -259,23 +274,6 @@ final class LocationAnimatorCoordinator { } } - private long getAnimationDuration() { - long previousUpdateTimeStamp = locationUpdateTimestamp; - locationUpdateTimestamp = SystemClock.elapsedRealtime(); - - long animationDuration; - if (previousUpdateTimeStamp == 0) { - animationDuration = 0; - } else { - animationDuration = (long) ((locationUpdateTimestamp - previousUpdateTimeStamp) * durationMultiplier) - /* make animation slightly longer with durationMultiplier, defaults to 1.1f */; - } - - animationDuration = Math.min(animationDuration, MAX_ANIMATION_DURATION_MS); - - return animationDuration; - } - private float checkGpsNorth(boolean isGpsNorth, float targetCameraBearing) { if (isGpsNorth) { targetCameraBearing = 0; @@ -362,7 +360,9 @@ final class LocationAnimatorCoordinator { float currentGpsBearingTarget = gpsBearingAnimator.getTarget(); createNewFloatAnimator(ANIMATOR_LAYER_GPS_BEARING, currentGpsBearing, currentGpsBearingTarget); - playAnimators(getAnimationDuration(), ANIMATOR_LAYER_LATLNG, ANIMATOR_LAYER_GPS_BEARING); + long duration = latLngAnimator.getDuration() - latLngAnimator.getCurrentPlayTime(); + + playAnimators(duration, ANIMATOR_LAYER_LATLNG, ANIMATOR_LAYER_GPS_BEARING); } if (compassBearingAnimator != null) { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationCameraController.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationCameraController.java index d22f7a8514..79d2e02bf1 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationCameraController.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationCameraController.java @@ -102,6 +102,10 @@ final class LocationCameraController { long transitionDuration, @Nullable Double zoom, @Nullable Double bearing, @Nullable Double tilt, @Nullable OnLocationCameraTransitionListener internalTransitionListener) { + if (this.cameraMode == cameraMode) { + return; + } + final boolean wasTracking = isLocationTracking(); this.cameraMode = cameraMode; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationLayerController.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationLayerController.java index c0c6017cd6..b18a7c4742 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationLayerController.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationLayerController.java @@ -111,11 +111,8 @@ final class LocationLayerController { removeLayers(); addLayers(); if (isHidden) { - for (String layerId : layerSet) { - setLayerVisibility(layerId, false); - } + hide(); } - setRenderMode(renderMode); } this.options = options; @@ -131,49 +128,24 @@ final class LocationLayerController { styleAccuracy(options.accuracyAlpha(), options.accuracyColor()); styleScaling(options); determineIconsSource(options); + + if (!isHidden) { + show(); + } } void setRenderMode(@RenderMode.Mode int renderMode) { - int previousMode = this.renderMode; + if (this.renderMode == renderMode) { + return; + } this.renderMode = renderMode; if (!isHidden) { - boolean isStale = locationFeature.getBooleanProperty(PROPERTY_LOCATION_STALE); - switch (renderMode) { - case RenderMode.NORMAL: - styleForeground(options); - setLayerVisibility(SHADOW_LAYER, true); - setLayerVisibility(FOREGROUND_LAYER, true); - setLayerVisibility(BACKGROUND_LAYER, true); - setLayerVisibility(ACCURACY_LAYER, !isStale); - setLayerVisibility(BEARING_LAYER, false); - break; - case RenderMode.COMPASS: - styleForeground(options); - setLayerVisibility(SHADOW_LAYER, true); - setLayerVisibility(FOREGROUND_LAYER, true); - setLayerVisibility(BACKGROUND_LAYER, true); - setLayerVisibility(ACCURACY_LAYER, !isStale); - setLayerVisibility(BEARING_LAYER, true); - break; - case RenderMode.GPS: - styleForeground(options); - setLayerVisibility(SHADOW_LAYER, false); - setLayerVisibility(FOREGROUND_LAYER, true); - setLayerVisibility(BACKGROUND_LAYER, true); - setLayerVisibility(ACCURACY_LAYER, false); - setLayerVisibility(BEARING_LAYER, false); - break; - default: - break; - } - - determineIconsSource(options); - } - - if (previousMode != renderMode) { - internalRenderModeChangedListener.onRenderModeChanged(renderMode); + styleForeground(options); + show(); } + determineIconsSource(options); + internalRenderModeChangedListener.onRenderModeChanged(renderMode); } int getRenderMode() { @@ -186,7 +158,32 @@ final class LocationLayerController { void show() { isHidden = false; - setRenderMode(renderMode); + boolean isStale = locationFeature.getBooleanProperty(PROPERTY_LOCATION_STALE); + switch (renderMode) { + case RenderMode.NORMAL: + setLayerVisibility(SHADOW_LAYER, true); + setLayerVisibility(FOREGROUND_LAYER, true); + setLayerVisibility(BACKGROUND_LAYER, true); + setLayerVisibility(ACCURACY_LAYER, !isStale); + setLayerVisibility(BEARING_LAYER, false); + break; + case RenderMode.COMPASS: + setLayerVisibility(SHADOW_LAYER, true); + setLayerVisibility(FOREGROUND_LAYER, true); + setLayerVisibility(BACKGROUND_LAYER, true); + setLayerVisibility(ACCURACY_LAYER, !isStale); + setLayerVisibility(BEARING_LAYER, true); + break; + case RenderMode.GPS: + setLayerVisibility(SHADOW_LAYER, false); + setLayerVisibility(FOREGROUND_LAYER, true); + setLayerVisibility(BACKGROUND_LAYER, true); + setLayerVisibility(ACCURACY_LAYER, false); + setLayerVisibility(BEARING_LAYER, false); + break; + default: + break; + } } void hide() { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java index eba87de0b2..74a864a6a1 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java @@ -31,7 +31,6 @@ import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; import static com.mapbox.mapboxsdk.constants.MapboxConstants.ZOOM_RATE; -import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveStartedListener.REASON_API_ANIMATION; import static com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraMoveStartedListener.REASON_API_GESTURE; /** @@ -714,7 +713,7 @@ final class MapGestureDetector { @Override public void onAnimationStart(Animator animation) { transform.cancelTransitions(); - cameraChangeDispatcher.onCameraMoveStarted(REASON_API_ANIMATION); + cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE); } @Override @@ -823,7 +822,7 @@ final class MapGestureDetector { @Override public void onAnimationStart(Animator animation) { transform.cancelTransitions(); - cameraChangeDispatcher.onCameraMoveStarted(REASON_API_ANIMATION); + cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE); } @Override diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java index 09bb5012d1..a394b97124 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMapOptions.java @@ -69,7 +69,7 @@ public class MapboxMapOptions implements Parcelable { private boolean prefetchesTiles = true; private boolean zMediaOverlay = false; - private String localIdeographFontFamily = "sans-serif"; + private String localIdeographFontFamily; private String apiBaseUri; @@ -246,8 +246,14 @@ public class MapboxMapOptions implements Parcelable { typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_enableTilePrefetch, true)); mapboxMapOptions.renderSurfaceOnTop( typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_enableZMediaOverlay, false)); - mapboxMapOptions.localIdeographFontFamily( - typedArray.getString(R.styleable.mapbox_MapView_mapbox_localIdeographFontFamily)); + + String localIdeographFontFamily = + typedArray.getString(R.styleable.mapbox_MapView_mapbox_localIdeographFontFamily); + if (localIdeographFontFamily == null) { + localIdeographFontFamily = "sans-serif"; + } + mapboxMapOptions.localIdeographFontFamily(localIdeographFontFamily); + mapboxMapOptions.pixelRatio( typedArray.getFloat(R.styleable.mapbox_MapView_mapbox_pixelRatio, 0)); mapboxMapOptions.foregroundLoadColor( diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineGeometryRegionDefinition.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineGeometryRegionDefinition.java index 7878460888..48a46d0b09 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineGeometryRegionDefinition.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineGeometryRegionDefinition.java @@ -51,7 +51,7 @@ public class OfflineGeometryRegionDefinition implements OfflineRegionDefinition @Keep public OfflineGeometryRegionDefinition( String styleURL, Geometry geometry, double minZoom, double maxZoom, float pixelRatio) { - this(styleURL, geometry, minZoom, maxZoom, pixelRatio, true); + this(styleURL, geometry, minZoom, maxZoom, pixelRatio, false); } /** @@ -88,6 +88,7 @@ public class OfflineGeometryRegionDefinition implements OfflineRegionDefinition this.minZoom = parcel.readDouble(); this.maxZoom = parcel.readDouble(); this.pixelRatio = parcel.readFloat(); + this.includeIdeographs = parcel.readByte() != 0; } @Override @@ -159,6 +160,7 @@ public class OfflineGeometryRegionDefinition implements OfflineRegionDefinition dest.writeDouble(minZoom); dest.writeDouble(maxZoom); dest.writeFloat(pixelRatio); + dest.writeByte((byte) (includeIdeographs ? 1 : 0)); } public static final Creator CREATOR = new Creator() { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineTilePyramidRegionDefinition.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineTilePyramidRegionDefinition.java index db2704650a..eff9644e59 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineTilePyramidRegionDefinition.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/offline/OfflineTilePyramidRegionDefinition.java @@ -48,7 +48,7 @@ public class OfflineTilePyramidRegionDefinition implements OfflineRegionDefiniti @Keep public OfflineTilePyramidRegionDefinition( String styleURL, LatLngBounds bounds, double minZoom, double maxZoom, float pixelRatio) { - this(styleURL, bounds, minZoom, maxZoom, pixelRatio, true); + this(styleURL, bounds, minZoom, maxZoom, pixelRatio, false); } /** @@ -88,6 +88,7 @@ public class OfflineTilePyramidRegionDefinition implements OfflineRegionDefiniti this.minZoom = parcel.readDouble(); this.maxZoom = parcel.readDouble(); this.pixelRatio = parcel.readFloat(); + this.includeIdeographs = parcel.readByte() != 0; } @@ -146,6 +147,7 @@ public class OfflineTilePyramidRegionDefinition implements OfflineRegionDefiniti dest.writeDouble(minZoom); dest.writeDouble(maxZoom); dest.writeFloat(pixelRatio); + dest.writeByte((byte) (includeIdeographs ? 1 : 0)); } public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationCameraControllerTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationCameraControllerTest.java index 7fb018d235..d1b8642c31 100644 --- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationCameraControllerTest.java +++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationCameraControllerTest.java @@ -142,6 +142,32 @@ public class LocationCameraControllerTest { } @Test + public void setCameraMode_doNotNotifyAboutDuplicates_NONE() { + OnCameraTrackingChangedListener internalTrackingChangedListener = mock(OnCameraTrackingChangedListener.class); + LocationCameraController camera = buildCamera(internalTrackingChangedListener); + camera.initializeOptions(mock(LocationComponentOptions.class)); + int cameraMode = NONE; + + camera.setCameraMode(cameraMode); + camera.setCameraMode(cameraMode); + + verify(internalTrackingChangedListener, times(1)).onCameraTrackingChanged(cameraMode); + } + + @Test + public void setCameraMode_doNotNotifyAboutDuplicates_TRACKING_GPS() { + OnCameraTrackingChangedListener internalTrackingChangedListener = mock(OnCameraTrackingChangedListener.class); + LocationCameraController camera = buildCamera(internalTrackingChangedListener); + camera.initializeOptions(mock(LocationComponentOptions.class)); + int cameraMode = TRACKING_GPS; + + camera.setCameraMode(cameraMode); + camera.setCameraMode(cameraMode); + + verify(internalTrackingChangedListener, times(1)).onCameraTrackingChanged(cameraMode); + } + + @Test public void setCameraMode_cancelTransitionsWhenSet() { MapboxMap mapboxMap = mock(MapboxMap.class); when(mapboxMap.getUiSettings()).thenReturn(mock(UiSettings.class)); diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.java index aa0a07b73e..0fbc47df55 100644 --- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.java +++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.java @@ -594,6 +594,44 @@ public class LocationLayerControllerTest { .addNumberProperty(PROPERTY_ACCURACY_RADIUS, accuracyRadiusValue); } + @Test + public void renderModeChanged_doNotNotifyAboutDuplicates_NORMAL() { + OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class); + LayerSourceProvider sourceProvider = buildLayerProvider(); + GeoJsonSource locationSource = mock(GeoJsonSource.class); + when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource); + LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class); + LocationComponentOptions options = mock(LocationComponentOptions.class); + + LocationLayerController controller = + new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options), + bitmapProvider, options, internalRenderModeChangedListener); + + controller.setRenderMode(RenderMode.NORMAL); + controller.setRenderMode(RenderMode.NORMAL); + + verify(internalRenderModeChangedListener, times(1)).onRenderModeChanged(RenderMode.NORMAL); + } + + @Test + public void renderModeChanged_doNotNotifyAboutDuplicates_GPS() { + OnRenderModeChangedListener internalRenderModeChangedListener = mock(OnRenderModeChangedListener.class); + LayerSourceProvider sourceProvider = buildLayerProvider(); + GeoJsonSource locationSource = mock(GeoJsonSource.class); + when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource); + LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class); + LocationComponentOptions options = mock(LocationComponentOptions.class); + + LocationLayerController controller = + new LocationLayerController(mapboxMap, mapboxMap.getStyle(), sourceProvider, buildFeatureProvider(options), + bitmapProvider, options, internalRenderModeChangedListener); + + controller.setRenderMode(RenderMode.GPS); + controller.setRenderMode(RenderMode.GPS); + + verify(internalRenderModeChangedListener, times(1)).onRenderModeChanged(RenderMode.GPS); + } + private LayerFeatureProvider buildFeatureProvider(@NonNull LocationComponentOptions options) { LayerFeatureProvider provider = mock(LayerFeatureProvider.class); when(provider.generateLocationFeature(null, options)).thenReturn(mock(Feature.class)); diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java index f03d1fb15f..11035c050f 100644 --- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java +++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/maps/MapboxMapOptionsTest.java @@ -8,6 +8,9 @@ import com.mapbox.mapboxsdk.constants.MapboxConstants; import com.mapbox.mapboxsdk.geometry.LatLng; import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.RobolectricTestRunner; +import org.robolectric.RuntimeEnvironment; import java.util.Arrays; @@ -18,6 +21,7 @@ import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +@RunWith(RobolectricTestRunner.class) public class MapboxMapOptionsTest { private static final double DELTA = 1e-15; @@ -172,5 +176,11 @@ public class MapboxMapOptionsTest { assertTrue(new MapboxMapOptions().crossSourceCollisions(true).getCrossSourceCollisions()); assertFalse(new MapboxMapOptions().crossSourceCollisions(false).getCrossSourceCollisions()); } + + @Test + public void testLocalIdeographFontFamily_enabledByDefault() { + MapboxMapOptions options = MapboxMapOptions.createFromAttributes(RuntimeEnvironment.application, null); + assertEquals("sans-serif", options.getLocalIdeographFontFamily()); + } } diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapGestureDetectorTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapGestureDetectorTest.kt index 1e5cdf8b73..3980199cad 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapGestureDetectorTest.kt +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapGestureDetectorTest.kt @@ -1,6 +1,5 @@ package com.mapbox.mapboxsdk.maps -import android.graphics.PointF import android.support.test.espresso.Espresso.onView import android.support.test.espresso.matcher.ViewMatchers.withId import com.mapbox.mapboxsdk.camera.CameraPosition @@ -12,7 +11,7 @@ import com.mapbox.mapboxsdk.maps.GesturesUiTestUtils.quickScale import com.mapbox.mapboxsdk.testapp.R import com.mapbox.mapboxsdk.testapp.activity.BaseTest import com.mapbox.mapboxsdk.testapp.activity.maplayout.SimpleMapActivity -import junit.framework.Assert +import org.junit.Assert import org.junit.Before import org.junit.Test @@ -38,7 +37,6 @@ class MapGestureDetectorTest : BaseTest() { onView(withId(R.id.mapView)).perform(quickScale(maxHeight / 2f, withVelocity = false)) rule.runOnUiThread { Assert.assertTrue(mapboxMap.cameraPosition.zoom > initialZoom!!) - Assert.assertTrue(Math.abs(mapboxMap.cameraPosition.zoom - initialZoom!!) > 0.5) } } @@ -60,18 +58,11 @@ class MapGestureDetectorTest : BaseTest() { Assert.assertEquals(initialCameraPosition!!, mapboxMap.cameraPosition) } - var expectedTarget: LatLng? = null - rule.runOnUiThread { - val currentPoint = mapboxMap.projection.toScreenLocation(initialCameraPosition!!.target) - val resultingPoint = PointF(currentPoint.x + maxWidth / 2f, currentPoint.y + maxHeight / 2f) - expectedTarget = mapboxMap.projection.fromScreenLocation(resultingPoint) - } - // move to expected target onView(withId(R.id.mapView)).perform(move(-maxWidth / 2f, -maxHeight / 2f, withVelocity = false)) rule.runOnUiThread { - Assert.assertEquals(expectedTarget!!.latitude, mapboxMap.cameraPosition.target.latitude, 5.0) - Assert.assertEquals(expectedTarget!!.longitude, mapboxMap.cameraPosition.target.longitude, 5.0) + Assert.assertNotEquals(initialCameraPosition!!.target.latitude, mapboxMap.cameraPosition.target.latitude, 1.0) + Assert.assertNotEquals(initialCameraPosition!!.target.longitude, mapboxMap.cameraPosition.target.longitude, 1.0) } } @@ -87,8 +78,8 @@ class MapGestureDetectorTest : BaseTest() { onView(withId(R.id.mapView)).perform(quickScale(maxHeight / 2f)) rule.runOnUiThread { // camera did not move - Assert.assertEquals(initialTarget!!.latitude, mapboxMap.cameraPosition.target.latitude, 0.5) - Assert.assertEquals(initialTarget!!.longitude, mapboxMap.cameraPosition.target.longitude, 0.5) + Assert.assertEquals(initialTarget!!.latitude, mapboxMap.cameraPosition.target.latitude, 1.0) + Assert.assertEquals(initialTarget!!.longitude, mapboxMap.cameraPosition.target.longitude, 1.0) } } @@ -98,18 +89,19 @@ class MapGestureDetectorTest : BaseTest() { validateTestSetup() onView(withId(R.id.mapView)).perform(quickScale(maxHeight / 2f, interrupt = true)) - var expectedTarget: LatLng? = null + var initialCameraPosition: CameraPosition? = null rule.runOnUiThread { - val currentPoint = mapboxMap.projection.toScreenLocation(mapboxMap.cameraPosition.target) - val resultingPoint = PointF(currentPoint.x + maxWidth / 2f, currentPoint.y + maxHeight / 2f) - expectedTarget = mapboxMap.projection.fromScreenLocation(resultingPoint) + // zoom in so we can move vertically + mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(4.0)) + initialCameraPosition = mapboxMap.cameraPosition + mapboxMap.uiSettings.isQuickZoomGesturesEnabled = false } // move to expected target onView(withId(R.id.mapView)).perform(move(-maxWidth / 2f, -maxHeight / 2f, withVelocity = false)) rule.runOnUiThread { - Assert.assertEquals(expectedTarget!!.latitude, mapboxMap.cameraPosition.target.latitude, 10.0) - Assert.assertEquals(expectedTarget!!.longitude, mapboxMap.cameraPosition.target.longitude, 10.0) + Assert.assertNotEquals(initialCameraPosition!!.target.latitude, mapboxMap.cameraPosition.target.latitude, 1.0) + Assert.assertNotEquals(initialCameraPosition!!.target.longitude, mapboxMap.cameraPosition.target.longitude, 1.0) } } @@ -169,18 +161,19 @@ class MapGestureDetectorTest : BaseTest() { onView(withId(R.id.mapView)).perform(quickScale(mapboxMap.gesturesManager.standardScaleGestureDetector.spanSinceStartThreshold / 2, withVelocity = false, duration = 50L, interrupt = true)) - var expectedTarget: LatLng? = null + var initialCameraPosition: CameraPosition? = null rule.runOnUiThread { - val currentPoint = mapboxMap.projection.toScreenLocation(mapboxMap.cameraPosition.target) - val resultingPoint = PointF(currentPoint.x + maxWidth / 2f, currentPoint.y + maxHeight / 2f) - expectedTarget = mapboxMap.projection.fromScreenLocation(resultingPoint) + // zoom in so we can move vertically + mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(4.0)) + initialCameraPosition = mapboxMap.cameraPosition + mapboxMap.uiSettings.isQuickZoomGesturesEnabled = false } // move to expected target onView(withId(R.id.mapView)).perform(move(-maxWidth / 2f, -maxHeight / 2f, withVelocity = false)) rule.runOnUiThread { - Assert.assertEquals(expectedTarget!!.latitude, mapboxMap.cameraPosition.target.latitude, 10.0) - Assert.assertEquals(expectedTarget!!.longitude, mapboxMap.cameraPosition.target.longitude, 10.0) + Assert.assertNotEquals(initialCameraPosition!!.target.latitude, mapboxMap.cameraPosition.target.latitude, 1.0) + Assert.assertNotEquals(initialCameraPosition!!.target.longitude, mapboxMap.cameraPosition.target.longitude, 1.0) } } }
\ No newline at end of file diff --git a/platform/android/config.cmake b/platform/android/config.cmake index dd75bb3b5b..4bd628fcdd 100644 --- a/platform/android/config.cmake +++ b/platform/android/config.cmake @@ -136,8 +136,8 @@ target_include_directories(example-custom-layer PRIVATE include ) -target_link_libraries(example-custom-layer - PRIVATE optional - PRIVATE -llog - PRIVATE -lGLESv2 +target_link_libraries(example-custom-layer PRIVATE + mapbox-base + -llog + -lGLESv2 ) diff --git a/platform/darwin/filesource-files.json b/platform/darwin/filesource-files.json index b2e6fbc9b4..62043a0dcd 100644 --- a/platform/darwin/filesource-files.json +++ b/platform/darwin/filesource-files.json @@ -1,7 +1,7 @@ { "//": "This file can be edited manually and is the canonical source.", "sources": [ - "platform/darwin/src/MGLLoggingConfiguration.m", + "platform/darwin/src/MGLLoggingConfiguration.mm", "platform/darwin/src/MGLNetworkConfiguration.m", "platform/darwin/src/http_file_source.mm", "platform/default/src/mbgl/storage/file_source.cpp", diff --git a/platform/darwin/src/MGLLoggingConfiguration.h b/platform/darwin/src/MGLLoggingConfiguration.h index d79336df4c..2445078584 100644 --- a/platform/darwin/src/MGLLoggingConfiguration.h +++ b/platform/darwin/src/MGLLoggingConfiguration.h @@ -16,33 +16,38 @@ NS_ASSUME_NONNULL_BEGIN */ typedef NS_ENUM(NSInteger, MGLLoggingLevel) { /** - None-level messages are ignored. + None-level won't print any messages. */ MGLLoggingLevelNone = 0, /** + Fault-level messages contain system-level error information. + */ + MGLLoggingLevelFault, + /** + Error-level messages contain information that is intended to aid in process-level + errors. + */ + MGLLoggingLevelError, + /** + Warning-level messages contain warning information for potential risks. + */ + MGLLoggingLevelWarning, + /** Info-level messages contain information that may be helpful for flow tracing but is not essential. */ MGLLoggingLevelInfo, -#if MGL_LOGGING_ENABLE_DEBUG /** Debug-level messages contain information that may be helpful for troubleshooting specific problems. */ +#if MGL_LOGGING_ENABLE_DEBUG MGLLoggingLevelDebug, #endif /** - Error-level messages contain information that is intended to aid in process-level - errors. - */ - MGLLoggingLevelError, - /** - Fault-level messages contain system-level error information. - */ - MGLLoggingLevelFault, - /** - :nodoc: Any new logging level should be included in the default logging implementation. + Verbose-level will print all messages. */ + MGLLoggingLevelVerbose, }; /** diff --git a/platform/darwin/src/MGLLoggingConfiguration.m b/platform/darwin/src/MGLLoggingConfiguration.mm index 4dfe3f7901..75d2439365 100644 --- a/platform/darwin/src/MGLLoggingConfiguration.m +++ b/platform/darwin/src/MGLLoggingConfiguration.mm @@ -1,3 +1,6 @@ +#include <mbgl/util/logging.hpp> +#include <mbgl/util/enum.hpp> + #import "MGLLoggingConfiguration_Private.h" #ifndef MGL_LOGGING_DISABLED @@ -5,10 +8,39 @@ #import <os/log.h> #endif -@implementation MGLLoggingConfiguration +namespace mbgl { + +class MGLCoreLoggingObserver : public Log :: Observer { +public: + //Return true not print messages at core level, and filter at platform level. + bool onRecord(EventSeverity severity, Event event, int64_t code, const std::string& msg) override{ + + NSString *message = [NSString stringWithFormat:@"[event]:%s [code]:%lld [message]:%@", Enum<Event>::toString(event), code, [NSString stringWithCString:msg.c_str() encoding:NSUTF8StringEncoding]]; + switch (severity) { + case EventSeverity::Debug: + MGLLogDebug(message); + break; + case EventSeverity::Info: + MGLLogInfo(message); + break; + case EventSeverity::Warning: + MGLLogWarning(message); + break; + case EventSeverity::Error: + MGLLogError(message); + break; + } + return true; + } +}; +} -+ (instancetype)sharedConfiguration +@implementation MGLLoggingConfiguration { + std::unique_ptr<mbgl::MGLCoreLoggingObserver> _coreLoggingObserver; +} + ++ (instancetype)sharedConfiguration { static dispatch_once_t once; static id sharedConfiguration; dispatch_once(&once, ^{ @@ -18,6 +50,13 @@ return sharedConfiguration; } +- (id)init{ + if(self = [super init]){ + mbgl::Log::setObserver(std::make_unique<mbgl::MGLCoreLoggingObserver>()); + } + return self; +} + - (void)setHandler:(void (^)(MGLLoggingLevel, NSString *, NSUInteger, NSString *))handler { if (!handler) { @@ -27,8 +66,7 @@ } } -- (void)logCallingFunction:(const char *)callingFunction functionLine:(NSUInteger)functionLine messageType:(MGLLoggingLevel)type format:(id)messageFormat, ... -{ +- (void)logCallingFunction:(const char *)callingFunction functionLine:(NSUInteger)functionLine messageType:(MGLLoggingLevel)type format:(id)messageFormat, ... { va_list formatList; va_start(formatList, messageFormat); NSString *formattedMessage = [[NSString alloc] initWithFormat:messageFormat arguments:formatList]; @@ -68,6 +106,7 @@ os_log_t mapbox_log; switch (level) { case MGLLoggingLevelInfo: + case MGLLoggingLevelWarning: mapbox_log = info_log; break; #if MGL_LOGGING_ENABLE_DEBUG @@ -92,6 +131,7 @@ NSString *category; switch (level) { case MGLLoggingLevelInfo: + case MGLLoggingLevelWarning: category = @"INFO"; break; #if MGL_LOGGING_ENABLE_DEBUG diff --git a/platform/darwin/src/MGLLoggingConfiguration_Private.h b/platform/darwin/src/MGLLoggingConfiguration_Private.h index 3acc0291c0..40b4df440d 100644 --- a/platform/darwin/src/MGLLoggingConfiguration_Private.h +++ b/platform/darwin/src/MGLLoggingConfiguration_Private.h @@ -14,6 +14,7 @@ NS_INLINE NSString *MGLStringFromNSEdgeInsets(NSEdgeInsets insets) { #define MGLLogInfo(...) #define MGLLogDebug(...) +#define MGLLogWarning(...) #define MGLLogError(...) #define MGLLogFault(...) @@ -25,9 +26,10 @@ NS_INLINE NSString *MGLStringFromNSEdgeInsets(NSEdgeInsets insets) { #define MGLLogDebug(...) #endif -#define MGLLogInfo(message, ...) MGLLogWithType(MGLLoggingLevelInfo, __PRETTY_FUNCTION__, __LINE__, message, ##__VA_ARGS__) -#define MGLLogError(message, ...) MGLLogWithType(MGLLoggingLevelError, __PRETTY_FUNCTION__, __LINE__, message, ##__VA_ARGS__) -#define MGLLogFault(message, ...) MGLLogWithType(MGLLoggingLevelFault, __PRETTY_FUNCTION__, __LINE__, message, ##__VA_ARGS__) +#define MGLLogInfo(message, ...) MGLLogWithType(MGLLoggingLevelInfo, __PRETTY_FUNCTION__, __LINE__, message, ##__VA_ARGS__) +#define MGLLogWarning(message, ...) MGLLogWithType(MGLLoggingLevelWarning, __PRETTY_FUNCTION__, __LINE__, message, ##__VA_ARGS__) +#define MGLLogError(message, ...) MGLLogWithType(MGLLoggingLevelError, __PRETTY_FUNCTION__, __LINE__, message, ##__VA_ARGS__) +#define MGLLogFault(message, ...) MGLLogWithType(MGLLoggingLevelFault, __PRETTY_FUNCTION__, __LINE__, message, ##__VA_ARGS__) #endif diff --git a/platform/darwin/src/logging_nslog.mm b/platform/darwin/src/logging_nslog.mm index dd428f56b1..ac3c939bb5 100644 --- a/platform/darwin/src/logging_nslog.mm +++ b/platform/darwin/src/logging_nslog.mm @@ -4,11 +4,11 @@ #import <Foundation/Foundation.h> namespace mbgl { - -void Log::platformRecord(EventSeverity severity, const std::string &msg) { - NSString *message = + + void Log::platformRecord(EventSeverity severity, const std::string &msg) { + NSString *message = [[NSString alloc] initWithBytes:msg.data() length:msg.size() encoding:NSUTF8StringEncoding]; - NSLog(@"[%s] %@", Enum<EventSeverity>::toString(severity), message); -} - + NSLog(@"[%s] %@", Enum<EventSeverity>::toString(severity), message); + } + } diff --git a/platform/default/src/mbgl/storage/sqlite3.cpp b/platform/default/src/mbgl/storage/sqlite3.cpp index 7596ca34a4..665e23b437 100644 --- a/platform/default/src/mbgl/storage/sqlite3.cpp +++ b/platform/default/src/mbgl/storage/sqlite3.cpp @@ -6,10 +6,10 @@ #include <cstring> #include <cstdio> #include <chrono> -#include <optional.hpp> #include <mbgl/util/traits.hpp> #include <mbgl/util/logging.hpp> +#include <mbgl/util/optional.hpp> namespace mapbox { namespace sqlite { @@ -98,10 +98,6 @@ public: int64_t changes = 0; }; -template <typename T> -using optional = std::experimental::optional<T>; - - #ifndef NDEBUG void logSqlMessage(void *, const int err, const char *msg) { mbgl::Log::Record(mbgl::EventSeverity::Debug, mbgl::Event::Database, err, "%s", msg); @@ -309,7 +305,7 @@ void Query::bind( stmt.impl->check(sqlite3_bind_int64(stmt.impl->stmt, offset, std::chrono::system_clock::to_time_t(value))); } -template <> void Query::bind(int offset, optional<std::string> value) { +template <> void Query::bind(int offset, mbgl::optional<std::string> value) { if (!value) { bind(offset, nullptr); } else { @@ -320,7 +316,7 @@ template <> void Query::bind(int offset, optional<std::string> value) { template <> void Query::bind( int offset, - optional<std::chrono::time_point<std::chrono::system_clock, std::chrono::seconds>> value) { + mbgl::optional<std::chrono::time_point<std::chrono::system_clock, std::chrono::seconds>> value) { if (!value) { bind(offset, nullptr); } else { @@ -387,39 +383,39 @@ Query::get(int offset) { std::chrono::system_clock::from_time_t(sqlite3_column_int64(stmt.impl->stmt, offset))); } -template <> optional<int64_t> Query::get(int offset) { +template <> mbgl::optional<int64_t> Query::get(int offset) { assert(stmt.impl); if (sqlite3_column_type(stmt.impl->stmt, offset) == SQLITE_NULL) { - return optional<int64_t>(); + return mbgl::nullopt; } else { return get<int64_t>(offset); } } -template <> optional<double> Query::get(int offset) { +template <> mbgl::optional<double> Query::get(int offset) { assert(stmt.impl); if (sqlite3_column_type(stmt.impl->stmt, offset) == SQLITE_NULL) { - return optional<double>(); + return mbgl::nullopt; } else { return get<double>(offset); } } -template <> optional<std::string> Query::get(int offset) { +template <> mbgl::optional<std::string> Query::get(int offset) { assert(stmt.impl); if (sqlite3_column_type(stmt.impl->stmt, offset) == SQLITE_NULL) { - return optional<std::string>(); + return mbgl::nullopt; } else { return get<std::string>(offset); } } template <> -optional<std::chrono::time_point<std::chrono::system_clock, std::chrono::seconds>> +mbgl::optional<std::chrono::time_point<std::chrono::system_clock, std::chrono::seconds>> Query::get(int offset) { assert(stmt.impl); if (sqlite3_column_type(stmt.impl->stmt, offset) == SQLITE_NULL) { - return {}; + return mbgl::nullopt; } else { return get<std::chrono::time_point<std::chrono::system_clock, std::chrono::seconds>>( offset); diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index e529607a48..8a1d356dfc 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -6,10 +6,28 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT ### Styles and rendering -* Fixed flickering on style change for the same tile set ([#15127](https://github.com/mapbox/mapbox-gl-native/pull/15127)) +* Fixed flickering on style change for the same tile set. ([#15127](https://github.com/mapbox/mapbox-gl-native/pull/15127)) +### Other changes + +* `MGLLoggingLevel` has been updated for better matching core log levels. Now can use `[MGLLoggingConfiguration sharedConfiguration].loggingLevel` to filter logs from core . [#15120](https://github.com/mapbox/mapbox-gl-native/pull/15120) + +## 4.11.2 - July 30, 2019 + +* Fixed a map update bug caused by the render tiles and the render passes becoming unsynchronized. ([#15092](https://github.com/mapbox/mapbox-gl-native/pull/15092)) +* Fixed a custom geometry source bug caused by using the outdated tiles after style update. ([#15112](https://github.com/mapbox/mapbox-gl-native/pull/15112)) + +## 5.0.2 - July 29, 2019 + +* Fixed an issue where fill extrusion layers would be incorrectly rendered above other layers. ([#15065](https://github.com/mapbox/mapbox-gl-native/pull/15065)) +* Fixed a map update bug caused by the render tiles and the render passes becoming unsynchronized. ([#15092](https://github.com/mapbox/mapbox-gl-native/pull/15092)) +* Fixed a custom geometry source bug caused by using the outdated tiles after style update. ([#15112](https://github.com/mapbox/mapbox-gl-native/pull/15112)) + +## 5.1.2 - July 25, 2019 -## 5.2.0 +* Fixed a crash during network access. ([#15113](https://github.com/mapbox/mapbox-gl-native/pull/15113)) + +## 5.2.0 - July 24, 2019 ### Networking @@ -57,10 +75,26 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT * `-[MGLMapView showAnnotations:edgePadding:animated:completionHandler:]` * `-[MGLMapView selectAnnotation:animated:completionHandler:]` * Deprecated variants of the above methods without completion handlers. ([#14959](https://github.com/mapbox/mapbox-gl-native/pull/14959)) -* Added `MGLMapView.compassView.visibility` and `MGLOrnamentVisibility` to allow configuration of compass visibility behavior. ([#15055](https://github.com/mapbox/mapbox-gl-native/pull/15055)) +* Added `MGLMapView.compassView.compassVisibility` and `MGLOrnamentVisibility` to allow configuration of compass visibility behavior. ([#15055](https://github.com/mapbox/mapbox-gl-native/pull/15055)) * Fixed a crash during network access. ([#15113](https://github.com/mapbox/mapbox-gl-native/pull/15113)) * Updated "map ID" to the more accurate term "tileset ID" in documentation; updated "style's Map ID" to the more accurate term "style URL". ([#15116](https://github.com/mapbox/mapbox-gl-native/pull/15116)) +## 4.10.1 - July 19, 2019 + +* Fixed a bug in telemetry collection. ([#15077](https://github.com/mapbox/mapbox-gl-native/pull/15077)) + +## 4.11.1 - July 19, 2019 + +* Fixed a bug in telemetry collection. ([#15077](https://github.com/mapbox/mapbox-gl-native/pull/15077)) + +## 5.0.1 - July 18, 2019 + +* Fixed a bug in telemetry collection. ([#15077](https://github.com/mapbox/mapbox-gl-native/pull/15077)) + +## 5.1.1 - July 18, 2019 + +* Fixed a bug in telemetry collection. ([#15077](https://github.com/mapbox/mapbox-gl-native/pull/15077)) + ## 5.1.0 - June 19, 2019 ### Styles and rendering diff --git a/platform/ios/Mapbox-iOS-SDK-snapshot-dynamic.podspec b/platform/ios/Mapbox-iOS-SDK-snapshot-dynamic.podspec index 419a083941..6c774a30c6 100644 --- a/platform/ios/Mapbox-iOS-SDK-snapshot-dynamic.podspec +++ b/platform/ios/Mapbox-iOS-SDK-snapshot-dynamic.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |m| - version = '5.2.0-beta.1' + version = '5.2.0' m.name = 'Mapbox-iOS-SDK-snapshot-dynamic' m.version = "#{version}-snapshot" diff --git a/platform/ios/Mapbox-iOS-SDK-stripped.podspec b/platform/ios/Mapbox-iOS-SDK-stripped.podspec index 2e73209888..f7502112ba 100644 --- a/platform/ios/Mapbox-iOS-SDK-stripped.podspec +++ b/platform/ios/Mapbox-iOS-SDK-stripped.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |m| - version = '5.2.0-beta.1' + version = '5.2.0' m.name = 'Mapbox-iOS-SDK-stripped' m.version = "#{version}-stripped" diff --git a/platform/ios/Mapbox-iOS-SDK.podspec b/platform/ios/Mapbox-iOS-SDK.podspec index fd11196b57..6d3e1bd14c 100644 --- a/platform/ios/Mapbox-iOS-SDK.podspec +++ b/platform/ios/Mapbox-iOS-SDK.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |m| - version = '5.2.0-beta.1' + version = '5.2.0' m.name = 'Mapbox-iOS-SDK' m.version = version diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj index 5f0d29a5e7..de2bec5d99 100644 --- a/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/ios.xcodeproj/project.pbxproj @@ -12,8 +12,6 @@ 071BBB031EE76146001FB02A /* MGLImageSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 071BBAFC1EE75CD4001FB02A /* MGLImageSource.h */; settings = {ATTRIBUTES = (Public, ); }; }; 071BBB041EE76147001FB02A /* MGLImageSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 071BBAFC1EE75CD4001FB02A /* MGLImageSource.h */; settings = {ATTRIBUTES = (Public, ); }; }; 071BBB071EE77631001FB02A /* MGLImageSourceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 071BBB051EE7761A001FB02A /* MGLImageSourceTests.m */; }; - 074A7F0D2277C093001A62D1 /* insert_access_token.sh in Resources */ = {isa = PBXBuildFile; fileRef = 074A7F0C2277C093001A62D1 /* insert_access_token.sh */; }; - 074A7F0E2277C093001A62D1 /* insert_access_token.sh in Resources */ = {isa = PBXBuildFile; fileRef = 074A7F0C2277C093001A62D1 /* insert_access_token.sh */; }; 075AF842227B6762008D7A4C /* MBXState.m in Sources */ = {isa = PBXBuildFile; fileRef = 075AF841227B6762008D7A4C /* MBXState.m */; }; 075AF845227B67C6008D7A4C /* MBXStateManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 075AF844227B67C6008D7A4C /* MBXStateManager.m */; }; 076171C32139C70900668A35 /* MGLMapViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 076171C22139C70900668A35 /* MGLMapViewTests.m */; }; @@ -43,8 +41,6 @@ 1F2B94C1221636D900210640 /* MGLNetworkConfiguration_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F2B94BF221636D800210640 /* MGLNetworkConfiguration_Private.h */; }; 1F6A82A221360F9D00BA5B41 /* MGLLoggingConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F6A82A021360F9C00BA5B41 /* MGLLoggingConfiguration.h */; settings = {ATTRIBUTES = (Public, ); }; }; 1F6A82A321360F9D00BA5B41 /* MGLLoggingConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F6A82A021360F9C00BA5B41 /* MGLLoggingConfiguration.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 1F6A82A421360F9D00BA5B41 /* MGLLoggingConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F6A82A121360F9C00BA5B41 /* MGLLoggingConfiguration.m */; }; - 1F6A82A521360F9D00BA5B41 /* MGLLoggingConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F6A82A121360F9C00BA5B41 /* MGLLoggingConfiguration.m */; }; 1F6A82A82138871900BA5B41 /* MGLLoggingConfiguration_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F6A82A62138871900BA5B41 /* MGLLoggingConfiguration_Private.h */; }; 1F6A82A92138871900BA5B41 /* MGLLoggingConfiguration_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F6A82A62138871900BA5B41 /* MGLLoggingConfiguration_Private.h */; }; 1F7454921ECBB42C00021D39 /* MGLLight.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1F0666891EC64F8E001C16D7 /* MGLLight.mm */; }; @@ -525,6 +521,8 @@ CABE5DAD2072FAB40003AF3C /* Mapbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA8847D21CBAF91600AB86E3 /* Mapbox.framework */; }; CAD9D0AA22A86D6F001B25EE /* MGLResourceTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = CAD9D0A922A86D6F001B25EE /* MGLResourceTests.mm */; }; CAE7AD5520F46EF5003B6782 /* MGLMapSnapshotterSwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAE7AD5420F46EF5003B6782 /* MGLMapSnapshotterSwiftTests.swift */; }; + CF75A91522D85E860058A5C4 /* MGLLoggingConfiguration.mm in Sources */ = {isa = PBXBuildFile; fileRef = CF75A91422D85E860058A5C4 /* MGLLoggingConfiguration.mm */; }; + CF75A91622D85E860058A5C4 /* MGLLoggingConfiguration.mm in Sources */ = {isa = PBXBuildFile; fileRef = CF75A91422D85E860058A5C4 /* MGLLoggingConfiguration.mm */; }; DA00FC8E1D5EEB0D009AABC8 /* MGLAttributionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = DA00FC8C1D5EEB0D009AABC8 /* MGLAttributionInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; DA00FC8F1D5EEB0D009AABC8 /* MGLAttributionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = DA00FC8C1D5EEB0D009AABC8 /* MGLAttributionInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; DA00FC901D5EEB0D009AABC8 /* MGLAttributionInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = DA00FC8D1D5EEB0D009AABC8 /* MGLAttributionInfo.mm */; }; @@ -899,7 +897,6 @@ 1F26B6C220E1A351007BCC21 /* simple_route.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = simple_route.json; sourceTree = "<group>"; }; 1F2B94BF221636D800210640 /* MGLNetworkConfiguration_Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLNetworkConfiguration_Private.h; sourceTree = "<group>"; }; 1F6A82A021360F9C00BA5B41 /* MGLLoggingConfiguration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLLoggingConfiguration.h; sourceTree = "<group>"; }; - 1F6A82A121360F9C00BA5B41 /* MGLLoggingConfiguration.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MGLLoggingConfiguration.m; sourceTree = "<group>"; }; 1F6A82A62138871900BA5B41 /* MGLLoggingConfiguration_Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MGLLoggingConfiguration_Private.h; sourceTree = "<group>"; }; 1F7454941ECD450D00021D39 /* MGLLight_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLLight_Private.h; sourceTree = "<group>"; }; 1F7454A61ED08AB400021D39 /* MGLLightTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLLightTest.mm; path = ../../darwin/test/MGLLightTest.mm; sourceTree = "<group>"; }; @@ -1207,6 +1204,7 @@ CAD9D0A922A86D6F001B25EE /* MGLResourceTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLResourceTests.mm; path = ../../darwin/test/MGLResourceTests.mm; sourceTree = "<group>"; }; CAE7AD5320F46EF5003B6782 /* integration-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "integration-Bridging-Header.h"; sourceTree = "<group>"; }; CAE7AD5420F46EF5003B6782 /* MGLMapSnapshotterSwiftTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MGLMapSnapshotterSwiftTests.swift; sourceTree = "<group>"; }; + CF75A91422D85E860058A5C4 /* MGLLoggingConfiguration.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLLoggingConfiguration.mm; sourceTree = "<group>"; }; DA00FC8C1D5EEB0D009AABC8 /* MGLAttributionInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLAttributionInfo.h; sourceTree = "<group>"; }; DA00FC8D1D5EEB0D009AABC8 /* MGLAttributionInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLAttributionInfo.mm; sourceTree = "<group>"; }; DA0CD58F1CF56F6A00A5F5A5 /* MGLFeatureTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLFeatureTests.mm; path = ../../darwin/test/MGLFeatureTests.mm; sourceTree = "<group>"; }; @@ -2141,7 +2139,7 @@ 1FCAE2A620B88B3800C577DD /* MGLLocationManager_Private.h */, 1FCAE2A120B872A400C577DD /* MGLLocationManager.m */, 1F6A82A021360F9C00BA5B41 /* MGLLoggingConfiguration.h */, - 1F6A82A121360F9C00BA5B41 /* MGLLoggingConfiguration.m */, + CF75A91422D85E860058A5C4 /* MGLLoggingConfiguration.mm */, 1F6A82A62138871900BA5B41 /* MGLLoggingConfiguration_Private.h */, ); name = Foundation; @@ -3079,7 +3077,6 @@ 353BAEF61D646370009A8DA9 /* amsterdam.geojson in Resources */, DA1DC9711CB6C6CE006E619F /* polyline.geojson in Resources */, DD4823761D94AE6C00EB71B7 /* line_filter_style.json in Resources */, - 074A7F0D2277C093001A62D1 /* insert_access_token.sh in Resources */, 076171C72141A91700668A35 /* Settings.bundle in Resources */, DA821D071CCC6D59007508D4 /* Main.storyboard in Resources */, DA1DC9731CB6C6CE006E619F /* threestates.geojson in Resources */, @@ -3109,7 +3106,6 @@ DA8933BC1CCD2CA100E68420 /* Foundation.strings in Resources */, DA8933A31CCC95B000E68420 /* Localizable.strings in Resources */, 960D0C361ECF5AAF008E151F /* Images.xcassets in Resources */, - 074A7F0E2277C093001A62D1 /* insert_access_token.sh in Resources */, DA8933F01CCD387900E68420 /* strip-frameworks.sh in Resources */, DAC49C5C1CD02BC9009E1AA3 /* Localizable.stringsdict in Resources */, DA8933BF1CCD2CAD00E68420 /* Foundation.stringsdict in Resources */, @@ -3358,6 +3354,7 @@ DAF25719201901E200367EF5 /* MGLHillshadeStyleLayer.mm in Sources */, 9C6E281922A97FDC0056B7BE /* UIKit+MMEMobileEvents.m in Sources */, 35136D451D42275100C20EFD /* MGLSymbolStyleLayer.mm in Sources */, + CF75A91522D85E860058A5C4 /* MGLLoggingConfiguration.mm in Sources */, 35599DED1D46F14E0048254D /* MGLStyleValue.mm in Sources */, DA8848211CBAFA6200AB86E3 /* MGLOfflinePack.mm in Sources */, 0778DD441F67556C00A73B34 /* MGLComputedShapeSource.mm in Sources */, @@ -3393,7 +3390,6 @@ DA88482B1CBAFA6200AB86E3 /* MGLTypes.m in Sources */, FA68F14D1E9D656600F9F6C2 /* MGLFillExtrusionStyleLayer.mm in Sources */, 404C26E41D89B877000AA13D /* MGLTileSource.mm in Sources */, - 1F6A82A421360F9D00BA5B41 /* MGLLoggingConfiguration.m in Sources */, 355AE0011E9281DA00F3939D /* MGLScaleBar.mm in Sources */, DA88481D1CBAFA6200AB86E3 /* MGLMapCamera.mm in Sources */, DACA86282019218600E9693A /* MGLRasterDEMSource.mm in Sources */, @@ -3485,6 +3481,7 @@ 35599DEE1D46F14E0048254D /* MGLStyleValue.mm in Sources */, DAA4E42B1CBB730400178DFB /* NSString+MGLAdditions.m in Sources */, DAA4E4261CBB730400178DFB /* MGLStyle.mm in Sources */, + CF75A91622D85E860058A5C4 /* MGLLoggingConfiguration.mm in Sources */, DAA32CC31E4C6B65006F8D24 /* MGLDistanceFormatter.m in Sources */, DAA4E41D1CBB730400178DFB /* MGLGeometry.mm in Sources */, 40834BFB1FE05E1800C1BD0D /* MMEAPIClient.m in Sources */, @@ -3521,7 +3518,6 @@ 355AE0021E9281DA00F3939D /* MGLScaleBar.mm in Sources */, 4018B1C81CDC287F00F666AF /* MGLAnnotationView.mm in Sources */, 07D8C6FB1F67560100381808 /* MGLComputedShapeSource.mm in Sources */, - 1F6A82A521360F9D00BA5B41 /* MGLLoggingConfiguration.m in Sources */, DAA4E4341CBB730400178DFB /* MGLFaux3DUserLocationAnnotationView.m in Sources */, DACA86292019218600E9693A /* MGLRasterDEMSource.mm in Sources */, 35B82BFB1D6C5F8400B1B721 /* NSPredicate+MGLAdditions.mm in Sources */, diff --git a/platform/ios/scripts/deploy-to-cocoapods.sh b/platform/ios/scripts/deploy-to-cocoapods.sh new file mode 100755 index 0000000000..27eb1fbabe --- /dev/null +++ b/platform/ios/scripts/deploy-to-cocoapods.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +# This relies on either: +# 1. You being authenticated locally with CocoaPods trunk. +# 2. The `COCOAPODS_TRUNK_TOKEN` environment variable being set. + +set -euo pipefail + +function step { >&2 echo -e "\033[1m\033[36m* $@\033[0m"; } +function finish { >&2 echo -en "\033[0m"; } +trap finish EXIT + +CIRCLE_TAG=${CIRCLE_TAG:-""} + +step "Pushing release to CocoaPods trunk…" + +if [[ $CIRCLE_TAG ]]; then + pod trunk push platform/ios/Mapbox-iOS-SDK.podspec --allow-warnings +else + echo "Skipping push to CocoaPods trunk for untagged build" +fi + +step "Pushing release/builds to Mapbox podspecs repo…" + +if [[ -z $(pod repo list | grep -i mapbox-public) ]]; then + pod repo add mapbox-public https://github.com/mapbox/pod-specs +else + echo "Found existing mapbox-public podspecs repo" +fi + +if [[ -z $(git config --global user.email) && $CI ]]; then + echo "Setting machine user as git committer" + git config --global user.email "MapboxCI@users.noreply.github.com" +fi + +if [[ $CIRCLE_TAG ]]; then + pod repo push mapbox-public platform/ios/Mapbox-iOS-SDK.podspec --allow-warnings + pod repo push mapbox-public platform/ios/Mapbox-iOS-SDK-stripped.podspec --allow-warnings +else + echo "Skipping push of release podspecs to mapbox-public for untagged build" + + # pod repo push mapbox-public platform/ios/Mapbox-iOS-SDK-snapshot-dynamic.podspec --allow-warnings + echo "Skipping push of snapshot to mapbox-public until we have a way to update the versions in the snapshot podspec" +fi diff --git a/platform/ios/scripts/install-packaging-dependencies.sh b/platform/ios/scripts/install-packaging-dependencies.sh index 08b1e4278e..3d87a93f20 100755 --- a/platform/ios/scripts/install-packaging-dependencies.sh +++ b/platform/ios/scripts/install-packaging-dependencies.sh @@ -2,7 +2,9 @@ set -euo pipefail +COCOAPODS_VERSION="1.7.5" JAZZY_VERSION="0.10.0" +CIRCLECI=${CIRCLECI:-false} function step { >&2 echo -e "\033[1m\033[36m* $@\033[0m"; } function finish { >&2 echo -en "\033[0m"; } @@ -10,18 +12,50 @@ trap finish EXIT step "Installing packaging dependencies…" +## +## aws +## if [ -z `which aws` ]; then brew install awscli +else + echo "Found awscli" fi +## +## wget +## if [ -z `which wget` ]; then brew install wget +else + echo "Found brew" fi +## +## cocoapods +## +if [[ -z `which pod` || $(pod --version) != "${COCOAPODS_VERSION}" ]]; then + step "Installing cocoapods…" + + if [[ "${CIRCLECI}" == true ]]; then + sudo gem install cocoapods -v $COCOAPODS_VERSION --no-document + else + gem install cocoapods -v $COCOAPODS_VERSION --no-document + fi + + if [ -z `which pod` ]; then + echo "Unable to install cocoapods ($COCOAPODS_VERSION)." + exit 1 + fi +else + echo "Found cocoapods (${COCOAPODS_VERSION})" +fi + +## +## jazzy +## if [[ -z `which jazzy` || $(jazzy -v) != "jazzy version: ${JAZZY_VERSION}" ]]; then step "Installing jazzy…" - CIRCLECI=${CIRCLECI:-false} if [[ "${CIRCLECI}" == true ]]; then sudo gem install jazzy -v $JAZZY_VERSION --no-document -- --with-sqlite3-lib=/usr/lib else @@ -32,4 +66,8 @@ if [[ -z `which jazzy` || $(jazzy -v) != "jazzy version: ${JAZZY_VERSION}" ]]; t echo "Unable to install jazzy ($JAZZY_VERSION). See https://github.com/mapbox/mapbox-gl-native/blob/master/platform/ios/INSTALL.md" exit 1 fi +else + echo "Found jazzy (${JAZZY_VERSION})" fi + +step "Finished installing packaging dependencies" diff --git a/platform/ios/sdk-files.json b/platform/ios/sdk-files.json index 5ce2423ba9..4a28116550 100644 --- a/platform/ios/sdk-files.json +++ b/platform/ios/sdk-files.json @@ -58,6 +58,7 @@ "platform/darwin/src/MGLHillshadeStyleLayer.mm", "platform/ios/vendor/mapbox-events-ios/MapboxMobileEvents/Categories/UIKit+MMEMobileEvents.m", "platform/darwin/src/MGLSymbolStyleLayer.mm", + "platform/darwin/src/MGLLoggingConfiguration.mm", "platform/darwin/src/MGLStyleValue.mm", "platform/darwin/src/MGLOfflinePack.mm", "platform/darwin/src/MGLComputedShapeSource.mm", @@ -93,7 +94,6 @@ "platform/darwin/src/MGLTypes.m", "platform/darwin/src/MGLFillExtrusionStyleLayer.mm", "platform/darwin/src/MGLTileSource.mm", - "platform/darwin/src/MGLLoggingConfiguration.m", "platform/ios/src/MGLScaleBar.mm", "platform/darwin/src/MGLMapCamera.mm", "platform/darwin/src/MGLRasterDEMSource.mm", diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md index 88fa37052b..68b7e243da 100644 --- a/platform/macos/CHANGELOG.md +++ b/platform/macos/CHANGELOG.md @@ -8,6 +8,7 @@ * The `MGLIdeographicFontFamilyName` Info.plist key now also accepts an array of font family names, to customize font fallback behavior. It can also be set to a Boolean value of `NO` to force the SDK to typeset CJK characters in a remote font specified by `MGLSymbolStyleLayer.textFontNames`. ([#14862](https://github.com/mapbox/mapbox-gl-native/pull/14862)) * Performance improvements for queryRenderedFeatures API and optimization that allocates containers based on a number of rendered layers. ([#14930](https://github.com/mapbox/mapbox-gl-native/pull/14930)) * Fixed rendering layers after fill-extrusion regression caused by optimization of fill-extrusion rendering. ([#15065](https://github.com/mapbox/mapbox-gl-native/pull/15065)) +* `MGLLoggingLevel` has been updated for better matching core log levels. Now can use `[MGLLoggingConfiguration sharedConfiguration].loggingLevel` to filter logs from core . [#15120](https://github.com/mapbox/mapbox-gl-native/pull/15120) ### Styles and rendering diff --git a/platform/macos/macos.xcodeproj/project.pbxproj b/platform/macos/macos.xcodeproj/project.pbxproj index 79540e1fef..45e5a6d653 100644 --- a/platform/macos/macos.xcodeproj/project.pbxproj +++ b/platform/macos/macos.xcodeproj/project.pbxproj @@ -25,7 +25,6 @@ 1F7454AB1ED1DDBD00021D39 /* MGLLightTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1F7454AA1ED1DDBD00021D39 /* MGLLightTest.mm */; }; 1F8A59FA21653483004DFE75 /* sideload_sat.db in Resources */ = {isa = PBXBuildFile; fileRef = 1F8A59F921653483004DFE75 /* sideload_sat.db */; }; 1F8A5A04216D4696004DFE75 /* MGLLoggingConfiguration_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F8A5A01216D4695004DFE75 /* MGLLoggingConfiguration_Private.h */; }; - 1F8A5A05216D4696004DFE75 /* MGLLoggingConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F8A5A02216D4695004DFE75 /* MGLLoggingConfiguration.m */; }; 1F8A5A06216D4696004DFE75 /* MGLLoggingConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F8A5A03216D4696004DFE75 /* MGLLoggingConfiguration.h */; settings = {ATTRIBUTES = (Public, ); }; }; 1F95931B1E6DE2B600D5B294 /* MGLNSDateAdditionsTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1F95931A1E6DE2B600D5B294 /* MGLNSDateAdditionsTests.mm */; }; 1F9EF4061FBA1B0E0063FBB0 /* mapbox_helmet.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 1F9EF4051FBA1B0D0063FBB0 /* mapbox_helmet.pdf */; }; @@ -133,6 +132,7 @@ CA8FBC0D21A4A74300D1203C /* MGLRendererConfigurationTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = CA8FBC0C21A4A74300D1203C /* MGLRendererConfigurationTests.mm */; }; CA9461A620884CCB0015EB12 /* MGLAnnotationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CA9461A520884CCB0015EB12 /* MGLAnnotationTests.m */; }; CAD9D0AC22A88A32001B25EE /* MGLResourceTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = CAD9D0AB22A88A32001B25EE /* MGLResourceTests.mm */; }; + CF762DEF22DC7EFF00338472 /* MGLLoggingConfiguration.mm in Sources */ = {isa = PBXBuildFile; fileRef = CF762DEE22DC7EFF00338472 /* MGLLoggingConfiguration.mm */; }; DA00FC8A1D5EEAC3009AABC8 /* MGLAttributionInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = DA00FC881D5EEAC3009AABC8 /* MGLAttributionInfo.h */; settings = {ATTRIBUTES = (Public, ); }; }; DA00FC8B1D5EEAC3009AABC8 /* MGLAttributionInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = DA00FC891D5EEAC3009AABC8 /* MGLAttributionInfo.mm */; }; DA0CD58E1CF56F5800A5F5A5 /* MGLFeatureTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = DA0CD58D1CF56F5800A5F5A5 /* MGLFeatureTests.mm */; }; @@ -348,7 +348,6 @@ 1F7454AA1ED1DDBD00021D39 /* MGLLightTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLLightTest.mm; sourceTree = "<group>"; }; 1F8A59F921653483004DFE75 /* sideload_sat.db */ = {isa = PBXFileReference; lastKnownFileType = file; name = sideload_sat.db; path = ../../../test/fixtures/offline_database/sideload_sat.db; sourceTree = "<group>"; }; 1F8A5A01216D4695004DFE75 /* MGLLoggingConfiguration_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLLoggingConfiguration_Private.h; sourceTree = "<group>"; }; - 1F8A5A02216D4695004DFE75 /* MGLLoggingConfiguration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLLoggingConfiguration.m; sourceTree = "<group>"; }; 1F8A5A03216D4696004DFE75 /* MGLLoggingConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLLoggingConfiguration.h; sourceTree = "<group>"; }; 1F95931A1E6DE2B600D5B294 /* MGLNSDateAdditionsTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLNSDateAdditionsTests.mm; path = ../../darwin/test/MGLNSDateAdditionsTests.mm; sourceTree = "<group>"; }; 1F9EF4051FBA1B0D0063FBB0 /* mapbox_helmet.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = mapbox_helmet.pdf; sourceTree = "<group>"; }; @@ -472,6 +471,7 @@ CA8FBC0C21A4A74300D1203C /* MGLRendererConfigurationTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLRendererConfigurationTests.mm; path = ../../darwin/test/MGLRendererConfigurationTests.mm; sourceTree = "<group>"; }; CA9461A520884CCB0015EB12 /* MGLAnnotationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MGLAnnotationTests.m; path = test/MGLAnnotationTests.m; sourceTree = SOURCE_ROOT; }; CAD9D0AB22A88A32001B25EE /* MGLResourceTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLResourceTests.mm; path = ../../darwin/test/MGLResourceTests.mm; sourceTree = "<group>"; }; + CF762DEE22DC7EFF00338472 /* MGLLoggingConfiguration.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLLoggingConfiguration.mm; sourceTree = "<group>"; }; DA00FC881D5EEAC3009AABC8 /* MGLAttributionInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLAttributionInfo.h; sourceTree = "<group>"; }; DA00FC891D5EEAC3009AABC8 /* MGLAttributionInfo.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLAttributionInfo.mm; sourceTree = "<group>"; }; DA0CD58D1CF56F5800A5F5A5 /* MGLFeatureTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLFeatureTests.mm; path = ../../darwin/test/MGLFeatureTests.mm; sourceTree = "<group>"; }; @@ -1253,7 +1253,7 @@ DA87A99F1DC9DC6200810D09 /* MGLValueEvaluator.h */, 1F8A5A03216D4696004DFE75 /* MGLLoggingConfiguration.h */, 1F8A5A01216D4695004DFE75 /* MGLLoggingConfiguration_Private.h */, - 1F8A5A02216D4695004DFE75 /* MGLLoggingConfiguration.m */, + CF762DEE22DC7EFF00338472 /* MGLLoggingConfiguration.mm */, ); name = Foundation; path = ../darwin/src; @@ -1659,6 +1659,7 @@ 40B77E461DB11BCD003DA2FE /* NSArray+MGLAdditions.mm in Sources */, DAE6C38C1CC31E2A00DB3429 /* MGLOfflinePack.mm in Sources */, 35D65C5B1D65AD5500722C23 /* NSDate+MGLAdditions.mm in Sources */, + CF762DEF22DC7EFF00338472 /* MGLLoggingConfiguration.mm in Sources */, DD0902B21DB1AC6400C5BDCE /* MGLNetworkConfiguration.m in Sources */, 1F7454A51ECFB00300021D39 /* MGLLight.mm in Sources */, DAE6C3B11CC31EF300DB3429 /* MGLAnnotationImage.m in Sources */, @@ -1710,7 +1711,6 @@ DAE6C3921CC31E2A00DB3429 /* MGLPolyline.mm in Sources */, 3527428A1D4C245800A1ECE6 /* MGLShapeSource.mm in Sources */, DAE6C3B51CC31EF300DB3429 /* MGLCompassCell.m in Sources */, - 1F8A5A05216D4696004DFE75 /* MGLLoggingConfiguration.m in Sources */, DA8F25901D51CA600010E6B5 /* MGLRasterStyleLayer.mm in Sources */, DAD165751CF4CD7A001FF4B9 /* MGLShapeCollection.mm in Sources */, 92FC0AE6207CDD8D007B6B54 /* MGLShapeOfflineRegion.mm in Sources */, diff --git a/platform/macos/sdk-files.json b/platform/macos/sdk-files.json index 6bd767fb98..022f679b4a 100644 --- a/platform/macos/sdk-files.json +++ b/platform/macos/sdk-files.json @@ -13,6 +13,7 @@ "platform/darwin/src/NSArray+MGLAdditions.mm", "platform/darwin/src/MGLOfflinePack.mm", "platform/darwin/src/NSDate+MGLAdditions.mm", + "platform/darwin/src/MGLLoggingConfiguration.mm", "platform/darwin/src/MGLNetworkConfiguration.m", "platform/darwin/src/MGLLight.mm", "platform/macos/src/MGLAnnotationImage.m", @@ -64,7 +65,6 @@ "platform/darwin/src/MGLPolyline.mm", "platform/darwin/src/MGLShapeSource.mm", "platform/macos/src/MGLCompassCell.m", - "platform/darwin/src/MGLLoggingConfiguration.m", "platform/darwin/src/MGLRasterStyleLayer.mm", "platform/darwin/src/MGLShapeCollection.mm", "platform/darwin/src/MGLShapeOfflineRegion.mm", diff --git a/scripts/generate-file-lists.js b/scripts/generate-file-lists.js index c4cf11a4c5..2100928438 100755 --- a/scripts/generate-file-lists.js +++ b/scripts/generate-file-lists.js @@ -7,17 +7,19 @@ const xcode = require('xcode'); require('./style-code'); -const classifier = /^(?:(?:(?:platform|vendor)\/(?:[^/]+)\/|(?:test|benchmark)\/)?(?:(include|src)\/)?)?(.+\.h(?:pp|xx)?)$/; +const classifier = /^(?:(?:(?:platform|vendor)\/(?:(?!include|src).)*\/|(?:test|benchmark)\/)?(?:(include|src)\/)?)?(.+\.h(?:pp|xx)?)$/; -function generateFileList(filename, root, regex, patterns) { +function generateFileList(filename, roots, regex, patterns) { writeFileList( filename, - child_process + [].concat.apply([], roots.map(function(root) { + return child_process .execSync(`git -C ${root} ls-files ${patterns.map((p) => '"' + p + '"').join(' ')}`) .toString() .trim() .split('\n') - .map(file => path.join(root, file))); + .map(file => path.join(root, file)) + }))) } function writeFileList(filename, files) { @@ -110,13 +112,13 @@ function generateXcodeSourceList(project, target, name) { writeIfModified(`${projectPath}/${name || target}-files.json`, JSON.stringify(json, null, 4) + '\n'); } -generateFileList('src/core-files.json', '.', /^(?:src|include)\/(?:mbgl\/)?(.+)\/[^\/]+$/, +generateFileList('src/core-files.json', [ '.' ], /^(?:src|include)\/(?:mbgl\/)?(.+)\/[^\/]+$/, [ 'include/*.hpp', 'include/*.h', 'src/*.hpp', 'src/*.cpp', 'src/*.h', 'src/*.c' ]); -generateFileList('benchmark/benchmark-files.json', '.', /^benchmark\/(?:(?:src|include)\/)?(?:mbgl\/)?(?:(.+)\/)?[^\/]+$/, - [ 'benchmark/*.hpp', 'benchmark/*.cpp', 'benchmark/*.h', 'benchmark/*.c' ]); +generateFileList('benchmark/benchmark-files.json', [ '.' ], /^benchmark\/(?:(?:src|include)\/)?(?:mbgl\/)?(?:(.+)\/)?[^\/]+$/, + [ 'benchmark/*.hpp', 'benchmark/*.cpp', 'benchmark/*.host', 'benchmark/*.c' ]); -generateFileList('test/test-files.json', '.', /^test\/(?:(?:src|include)\/)?(?:mbgl\/)?(?:(.+)\/)?[^\/]+$/, +generateFileList('test/test-files.json', [ '.' ], /^test\/(?:(?:src|include)\/)?(?:mbgl\/)?(?:(.+)\/)?[^\/]+$/, [ 'test/*.hpp', 'test/*.cpp', 'test/*.h', 'test/*.c' ]); generateXcodeSourceList('platform/macos/macos.xcodeproj', 'dynamic', 'sdk'); @@ -124,28 +126,26 @@ generateXcodeSourceList('platform/macos/macos.xcodeproj', 'dynamic', 'sdk'); generateXcodeSourceList('platform/ios/ios.xcodeproj', 'dynamic', 'sdk'); const vendorRegex = /^(?:(?:src|include)\/)?(?:(.+)\/)?[^\/]+$/ -generateFileList('vendor/args-files.json', 'vendor/args', vendorRegex, [ "args.hxx" ]); -generateFileList('vendor/boost-files.json', 'vendor/boost', vendorRegex, [ "include/**/*.hpp", "include/**/*.h" ]); -generateFileList('vendor/cheap-ruler-cpp-files.json', 'vendor/cheap-ruler-cpp', vendorRegex, [ "include/**/*.hpp" ]); -generateFileList('vendor/earcut.hpp-files.json', 'vendor/earcut.hpp', vendorRegex, [ "include/**/*.hpp" ]); -generateFileList('vendor/eternal-files.json', 'vendor/eternal', vendorRegex, [ "include/**/*.hpp" ]); -generateFileList('vendor/expected-files.json', 'vendor/expected', vendorRegex, [ "include/expected.hpp" ]); -generateFileList('vendor/filesystem-files.json', 'vendor/filesystem', vendorRegex, [ "include/**/*.hpp" ]); -generateFileList('vendor/geojson-vt-cpp-files.json', 'vendor/geojson-vt-cpp', vendorRegex, [ "include/**/*.hpp" ]); -generateFileList('vendor/geojson.hpp-files.json', 'vendor/geojson.hpp', vendorRegex, [ "include/**/*.hpp" ]); -generateFileList('vendor/geometry.hpp-files.json', 'vendor/geometry.hpp', vendorRegex, [ "include/**/*.hpp" ]); -generateFileList('vendor/icu-files.json', 'vendor/icu', vendorRegex, [ "include/**/*.h", "src/*.h", "src/*.cpp" ]); -generateFileList('vendor/jni.hpp-files.json', 'vendor/jni.hpp', vendorRegex, [ "include/**/*.hpp", ":!:include/jni/string_conversion.hpp" ]); -generateFileList('vendor/kdbush.hpp-files.json', 'vendor/kdbush.hpp', vendorRegex, [ "include/*.hpp" ]); -generateFileList('vendor/optional-files.json', 'vendor/optional', vendorRegex, [ "optional.hpp" ]); -generateFileList('vendor/pixelmatch-cpp-files.json', 'vendor/pixelmatch-cpp', vendorRegex, [ "include/**/*.hpp" ]); -generateFileList('vendor/polylabel-files.json', 'vendor/polylabel', vendorRegex, [ "include/**/*.hpp" ]); -generateFileList('vendor/protozero-files.json', 'vendor/protozero', vendorRegex, [ "include/**/*.hpp" ]); -generateFileList('vendor/rapidjson-files.json', 'vendor/rapidjson', vendorRegex, [ "include/**/*.h" ]); -generateFileList('vendor/shelf-pack-cpp-files.json', 'vendor/shelf-pack-cpp', vendorRegex, [ "include/**/*.hpp" ]); -generateFileList('vendor/sqlite-files.json', 'vendor/sqlite', vendorRegex, [ "include/*.h", "src/*.c" ]); -generateFileList('vendor/supercluster.hpp-files.json', 'vendor/supercluster.hpp', vendorRegex, [ "include/*.hpp" ]); -generateFileList('vendor/unique_resource-files.json', 'vendor/unique_resource', vendorRegex, [ "unique_resource.hpp" ]); -generateFileList('vendor/variant-files.json', 'vendor/variant', vendorRegex, [ "include/**/*.hpp" ]); -generateFileList('vendor/vector-tile-files.json', 'vendor/vector-tile', vendorRegex, [ "include/**/*.hpp" ]); -generateFileList('vendor/wagyu-files.json', 'vendor/wagyu', vendorRegex, [ "include/**/*.hpp" ]); +generateFileList('vendor/args-files.json', [ 'vendor/args' ], vendorRegex, [ "args.hxx" ]); +generateFileList('vendor/boost-files.json', [ 'vendor/boost' ], vendorRegex, [ "include/**/*.hpp", "include/**/*.h" ]); +generateFileList('vendor/cheap-ruler-cpp-files.json', [ 'vendor/cheap-ruler-cpp' ], vendorRegex, [ "include/**/*.hpp" ]); +generateFileList('vendor/earcut.hpp-files.json', [ 'vendor/earcut.hpp' ], vendorRegex, [ "include/**/*.hpp" ]); +generateFileList('vendor/eternal-files.json', [ 'vendor/eternal' ], vendorRegex, [ "include/**/*.hpp" ]); +generateFileList('vendor/expected-files.json', [ 'vendor/expected' ], vendorRegex, [ "include/expected.hpp" ]); +generateFileList('vendor/filesystem-files.json', [ 'vendor/filesystem' ], vendorRegex, [ "include/**/*.hpp" ]); +generateFileList('vendor/geojson-vt-cpp-files.json', [ 'vendor/geojson-vt-cpp' ], vendorRegex, [ "include/**/*.hpp" ]); +generateFileList('vendor/geojson.hpp-files.json', [ 'vendor/geojson.hpp' ], vendorRegex, [ "include/**/*.hpp" ]); +generateFileList('vendor/icu-files.json', [ 'vendor/icu' ], vendorRegex, [ "include/**/*.h", "src/*.h", "src/*.cpp" ]); +generateFileList('vendor/jni.hpp-files.json', [ 'vendor/jni.hpp' ], vendorRegex, [ "include/**/*.hpp", ":!:include/jni/string_conversion.hpp" ]); +generateFileList('vendor/kdbush.hpp-files.json', [ 'vendor/kdbush.hpp' ], vendorRegex, [ "include/*.hpp" ]); +generateFileList('vendor/mapbox-base-files.json', [ 'vendor/mapbox-base/libs/geometry.hpp', 'vendor/mapbox-base/libs/variant', 'vendor/mapbox-base/libs/optional' ], vendorRegex, [ "include/*.hpp", "include/**/*.hpp", "optional.hpp" ]); +generateFileList('vendor/pixelmatch-cpp-files.json', [ 'vendor/pixelmatch-cpp' ], vendorRegex, [ "include/**/*.hpp" ]); +generateFileList('vendor/polylabel-files.json', [ 'vendor/polylabel' ], vendorRegex, [ "include/**/*.hpp" ]); +generateFileList('vendor/protozero-files.json', [ 'vendor/protozero' ], vendorRegex, [ "include/**/*.hpp" ]); +generateFileList('vendor/rapidjson-files.json', [ 'vendor/rapidjson' ], vendorRegex, [ "include/**/*.h" ]); +generateFileList('vendor/shelf-pack-cpp-files.json', [ 'vendor/shelf-pack-cpp' ], vendorRegex, [ "include/**/*.hpp" ]); +generateFileList('vendor/sqlite-files.json', [ 'vendor/sqlite' ], vendorRegex, [ "include/*.h", "src/*.c" ]); +generateFileList('vendor/supercluster.hpp-files.json', [ 'vendor/supercluster.hpp' ], vendorRegex, [ "include/*.hpp" ]); +generateFileList('vendor/unique_resource-files.json', [ 'vendor/unique_resource' ], vendorRegex, [ "unique_resource.hpp" ]); +generateFileList('vendor/vector-tile-files.json', [ 'vendor/vector-tile' ], vendorRegex, [ "include/**/*.hpp" ]); +generateFileList('vendor/wagyu-files.json', [ 'vendor/wagyu' ], vendorRegex, [ "include/**/*.hpp" ]); diff --git a/src/csscolorparser/csscolorparser.cpp b/src/csscolorparser/csscolorparser.cpp index 106dae6cef..0de921b265 100644 --- a/src/csscolorparser/csscolorparser.cpp +++ b/src/csscolorparser/csscolorparser.cpp @@ -176,7 +176,7 @@ std::vector<std::string> split(const std::string& s, char delim) { return elems; } -optional<Color> parse(const std::string& css_str) { +mbgl::optional<Color> parse(const std::string& css_str) { std::string str = css_str; // Remove all whitespace, not compliant, but should just be more accepting. diff --git a/src/csscolorparser/csscolorparser.hpp b/src/csscolorparser/csscolorparser.hpp index b6bc5570f9..88b916620e 100644 --- a/src/csscolorparser/csscolorparser.hpp +++ b/src/csscolorparser/csscolorparser.hpp @@ -25,15 +25,13 @@ #ifndef CSS_COLOR_PARSER_CPP #define CSS_COLOR_PARSER_CPP +#include <mbgl/util/optional.hpp> + #include <string> #include <cmath> -#include <optional.hpp> namespace CSSColorParser { -template <class T> -using optional = std::experimental::optional<T>; - struct Color { inline Color() { } @@ -52,7 +50,7 @@ inline bool operator!=(const Color& lhs, const Color& rhs) { return !(lhs == rhs); } -optional<Color> parse(const std::string& css_str); +mbgl::optional<Color> parse(const std::string& css_str); } // namespace CSSColorParser diff --git a/src/mbgl/annotation/annotation_tile.cpp b/src/mbgl/annotation/annotation_tile.cpp index 6c3c9eb617..a410adc95e 100644 --- a/src/mbgl/annotation/annotation_tile.cpp +++ b/src/mbgl/annotation/annotation_tile.cpp @@ -58,7 +58,7 @@ FeatureIdentifier AnnotationTileFeature::getID() const { return data->id; } -GeometryCollection AnnotationTileFeature::getGeometries() const { +const GeometryCollection& AnnotationTileFeature::getGeometries() const { return data->geometries; } diff --git a/src/mbgl/annotation/annotation_tile.hpp b/src/mbgl/annotation/annotation_tile.hpp index 1e23fdf98a..741b598a8c 100644 --- a/src/mbgl/annotation/annotation_tile.hpp +++ b/src/mbgl/annotation/annotation_tile.hpp @@ -28,7 +28,7 @@ public: FeatureType getType() const override; optional<Value> getValue(const std::string&) const override; FeatureIdentifier getID() const override; - GeometryCollection getGeometries() const override; + const GeometryCollection& getGeometries() const override; private: std::shared_ptr<const AnnotationTileFeatureData> data; diff --git a/src/mbgl/geometry/feature_index.cpp b/src/mbgl/geometry/feature_index.cpp index 3675e8bc6e..b76e02be3f 100644 --- a/src/mbgl/geometry/feature_index.cpp +++ b/src/mbgl/geometry/feature_index.cpp @@ -159,7 +159,7 @@ void FeatureIndex::addFeature( continue; } - result[layerID].push_back(convertFeature(*geometryTileFeature, tileID)); + result[layerID].emplace_back(convertFeature(*geometryTileFeature, tileID)); } } diff --git a/src/mbgl/gfx/vertex_vector.hpp b/src/mbgl/gfx/vertex_vector.hpp index f41f842294..59fe67586b 100644 --- a/src/mbgl/gfx/vertex_vector.hpp +++ b/src/mbgl/gfx/vertex_vector.hpp @@ -11,11 +11,13 @@ template <class V> class VertexVector { public: using Vertex = V; + template<typename Arg> + void emplace_back(Arg&& vertex) { + v.emplace_back(std::forward<Arg>(vertex)); + } - template <class... Args> - void emplace_back(Args&&... args) { - static_assert(sizeof...(args) == 1, "wrong buffer element count"); - util::ignore({ (v.emplace_back(std::forward<Args>(args)), 0)... }); + void extend(std::size_t n, const Vertex& val) { + v.resize(v.size() + n, val); } std::size_t elements() const { diff --git a/src/mbgl/layout/pattern_layout.hpp b/src/mbgl/layout/pattern_layout.hpp index 95f8b181fc..858d515347 100644 --- a/src/mbgl/layout/pattern_layout.hpp +++ b/src/mbgl/layout/pattern_layout.hpp @@ -106,7 +106,7 @@ public: const auto i = patternFeature.i; std::unique_ptr<GeometryTileFeature> feature = std::move(patternFeature.feature); const PatternLayerMap& patterns = patternFeature.patterns; - GeometryCollection geometries = feature->getGeometries(); + const GeometryCollection& geometries = feature->getGeometries(); bucket->addFeature(*feature, geometries, patternPositions, patterns); featureIndex->insert(geometries, i, sourceLayerID, bucketLeaderID); diff --git a/src/mbgl/layout/symbol_feature.hpp b/src/mbgl/layout/symbol_feature.hpp index 72f613d4b6..ed9c0783d0 100644 --- a/src/mbgl/layout/symbol_feature.hpp +++ b/src/mbgl/layout/symbol_feature.hpp @@ -13,14 +13,14 @@ class SymbolFeature : public GeometryTileFeature { public: SymbolFeature(std::unique_ptr<GeometryTileFeature> feature_) : feature(std::move(feature_)), - geometry(feature->getGeometries()) // we need a mutable copy of the geometry for mergeLines() + geometry(feature->getGeometries().clone()) // we need a mutable copy of the geometry for mergeLines() {} FeatureType getType() const override { return feature->getType(); } optional<Value> getValue(const std::string& key) const override { return feature->getValue(key); }; - std::unordered_map<std::string,Value> getProperties() const override { return feature->getProperties(); }; + const PropertyMap& getProperties() const override { return feature->getProperties(); }; FeatureIdentifier getID() const override { return feature->getID(); }; - GeometryCollection getGeometries() const override { return geometry; }; + const GeometryCollection& getGeometries() const override { return geometry; }; friend bool operator < (const SymbolFeature& lhs, const SymbolFeature& rhs) { return lhs.sortKey < rhs.sortKey; diff --git a/src/mbgl/renderer/layers/render_circle_layer.cpp b/src/mbgl/renderer/layers/render_circle_layer.cpp index cf59319307..4f1620364f 100644 --- a/src/mbgl/renderer/layers/render_circle_layer.cpp +++ b/src/mbgl/renderer/layers/render_circle_layer.cpp @@ -167,7 +167,7 @@ bool RenderCircleLayer::queryIntersectsFeature( projectQueryGeometry(translatedQueryGeometry, posMatrix, transformState.getSize()); auto transformedSize = alignWithMap ? size * pixelsToTileUnits : size; - auto geometry = feature.getGeometries(); + const auto& geometry = feature.getGeometries(); for (auto& ring : geometry) { for (auto& point : ring) { const GeometryCoordinate& transformedPoint = alignWithMap ? point : projectPoint(point, posMatrix, transformState.getSize()); diff --git a/src/mbgl/renderer/layers/render_line_layer.cpp b/src/mbgl/renderer/layers/render_line_layer.cpp index 5c56826bd7..fcd52b21df 100644 --- a/src/mbgl/renderer/layers/render_line_layer.cpp +++ b/src/mbgl/renderer/layers/render_line_layer.cpp @@ -214,16 +214,22 @@ void RenderLineLayer::render(PaintParameters& parameters) { } } -optional<GeometryCollection> offsetLine(const GeometryCollection& rings, const double offset) { - if (offset == 0) return {}; +namespace { + +GeometryCollection offsetLine(const GeometryCollection& rings, double offset) { + assert(offset != 0.0f); + assert(!rings.empty()); GeometryCollection newRings; - Point<double> zero(0, 0); + newRings.reserve(rings.size()); + + const Point<double> zero(0, 0); for (const auto& ring : rings) { newRings.emplace_back(); auto& newRing = newRings.back(); + newRing.reserve(ring.size()); - for (auto i = ring.begin(); i != ring.end(); i++) { + for (auto i = ring.begin(); i != ring.end(); ++i) { auto& p = *i; Point<double> aToB = i == ring.begin() ? @@ -237,13 +243,15 @@ optional<GeometryCollection> offsetLine(const GeometryCollection& rings, const d const double cosHalfAngle = extrude.x * bToC.x + extrude.y * bToC.y; extrude *= (1.0 / cosHalfAngle); - newRing.push_back(convertPoint<int16_t>(extrude * offset) + p); + newRing.emplace_back(convertPoint<int16_t>(extrude * offset) + p); } } return newRings; } +} // namespace + bool RenderLineLayer::queryIntersectsFeature( const GeometryCoordinates& queryGeometry, const GeometryTileFeature& feature, @@ -263,16 +271,21 @@ bool RenderLineLayer::queryIntersectsFeature( // Evaluate function auto offset = evaluated.get<style::LineOffset>() .evaluate(feature, zoom, style::LineOffset::defaultValue()) * pixelsToTileUnits; + // Test intersection + const float halfWidth = getLineWidth(feature, zoom) / 2.0 * pixelsToTileUnits; // Apply offset to geometry - auto offsetGeometry = offsetLine(feature.getGeometries(), offset); + if (offset != 0.0f && !feature.getGeometries().empty()) { + return util::polygonIntersectsBufferedMultiLine( + translatedQueryGeometry.value_or(queryGeometry), + offsetLine(feature.getGeometries(), offset), + halfWidth); + } - // Test intersection - const float halfWidth = getLineWidth(feature, zoom) / 2.0 * pixelsToTileUnits; return util::polygonIntersectsBufferedMultiLine( - translatedQueryGeometry.value_or(queryGeometry), - offsetGeometry.value_or(feature.getGeometries()), - halfWidth); + translatedQueryGeometry.value_or(queryGeometry), + feature.getGeometries(), + halfWidth); } void RenderLineLayer::updateColorRamp() { diff --git a/src/mbgl/renderer/layers/render_raster_layer.cpp b/src/mbgl/renderer/layers/render_raster_layer.cpp index ecaee2985c..82d135b9ef 100644 --- a/src/mbgl/renderer/layers/render_raster_layer.cpp +++ b/src/mbgl/renderer/layers/render_raster_layer.cpp @@ -77,12 +77,14 @@ static std::array<float, 3> spinWeights(float spin) { void RenderRasterLayer::prepare(const LayerPrepareParameters& params) { renderTiles = params.source->getRenderTiles(); imageData = params.source->getImageRenderData(); - assert(renderTiles || imageData); + // It is possible image data is not available until the source loads it. + assert(renderTiles || imageData || !params.source->isEnabled()); } void RenderRasterLayer::render(PaintParameters& parameters) { - if (parameters.pass != RenderPass::Translucent) + if (parameters.pass != RenderPass::Translucent || (!renderTiles && !imageData)) { return; + } const auto& evaluated = static_cast<const RasterLayerProperties&>(*evaluatedProperties).evaluated; RasterProgram::Binders paintAttributeData{ evaluated, 0 }; diff --git a/src/mbgl/renderer/render_layer.cpp b/src/mbgl/renderer/render_layer.cpp index f15dc7e6f4..c1ca1fd017 100644 --- a/src/mbgl/renderer/render_layer.cpp +++ b/src/mbgl/renderer/render_layer.cpp @@ -47,6 +47,7 @@ bool RenderLayer::supportsZoom(float zoom) const { void RenderLayer::prepare(const LayerPrepareParameters& params) { assert(params.source); + assert(params.source->isEnabled()); renderTiles = params.source->getRenderTiles(); addRenderPassesFromTiles(); } diff --git a/src/mbgl/renderer/render_orchestrator.cpp b/src/mbgl/renderer/render_orchestrator.cpp index 4ce36434d2..5b6b27c185 100644 --- a/src/mbgl/renderer/render_orchestrator.cpp +++ b/src/mbgl/renderer/render_orchestrator.cpp @@ -274,9 +274,6 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(const UpdatePar // Reserve size for filteredLayersForSource if there are sources. if (!sourceImpls->empty()) { filteredLayersForSource.reserve(layerImpls->size()); - if (filteredLayersForSource.capacity() > layerImpls->size()) { - filteredLayersForSource.shrink_to_fit(); - } } // Update all sources and initialize renderItems. @@ -487,7 +484,12 @@ void RenderOrchestrator::queryRenderedSymbols(std::unordered_map<std::string, st std::vector<Feature> RenderOrchestrator::queryRenderedFeatures(const ScreenLineString& geometry, const RenderedQueryOptions& options, const std::unordered_map<std::string, const RenderLayer*>& layers) const { std::unordered_set<std::string> sourceIDs; + std::unordered_map<std::string, const RenderLayer*> filteredLayers; for (const auto& pair : layers) { + if (!pair.second->needsRendering() || !pair.second->supportsZoom(zoomHistory.lastZoom)) { + continue; + } + filteredLayers.emplace(pair); sourceIDs.emplace(pair.second->baseImpl->source); } @@ -497,12 +499,12 @@ std::vector<Feature> RenderOrchestrator::queryRenderedFeatures(const ScreenLineS std::unordered_map<std::string, std::vector<Feature>> resultsByLayer; for (const auto& sourceID : sourceIDs) { if (RenderSource* renderSource = getRenderSource(sourceID)) { - auto sourceResults = renderSource->queryRenderedFeatures(geometry, transformState, layers, options, projMatrix); + auto sourceResults = renderSource->queryRenderedFeatures(geometry, transformState, filteredLayers, options, projMatrix); std::move(sourceResults.begin(), sourceResults.end(), std::inserter(resultsByLayer, resultsByLayer.begin())); } } - queryRenderedSymbols(resultsByLayer, geometry, layers, options); + queryRenderedSymbols(resultsByLayer, geometry, filteredLayers, options); std::vector<Feature> result; @@ -511,11 +513,7 @@ std::vector<Feature> RenderOrchestrator::queryRenderedFeatures(const ScreenLineS } // Combine all results based on the style layer renderItems. - for (const auto& pair : layers) { - if (!pair.second->needsRendering() || !pair.second->supportsZoom(zoomHistory.lastZoom)) { - continue; - } - + for (const auto& pair : filteredLayers) { auto it = resultsByLayer.find(pair.second->baseImpl->id); if (it != resultsByLayer.end()) { std::move(it->second.begin(), it->second.end(), std::back_inserter(result)); @@ -560,6 +558,7 @@ FeatureExtensionValue RenderOrchestrator::queryFeatureExtensions(const std::stri } void RenderOrchestrator::reduceMemoryUse() { + filteredLayersForSource.shrink_to_fit(); for (const auto& entry : renderSources) { entry.second->reduceMemoryUse(); } diff --git a/src/mbgl/renderer/tile_pyramid.cpp b/src/mbgl/renderer/tile_pyramid.cpp index f47198e275..54e0b1eb26 100644 --- a/src/mbgl/renderer/tile_pyramid.cpp +++ b/src/mbgl/renderer/tile_pyramid.cpp @@ -293,6 +293,7 @@ std::unordered_map<std::string, std::vector<Feature>> TilePyramid::queryRendered } LineString<double> queryGeometry; + queryGeometry.reserve(geometry.size()); for (const auto& p : geometry) { queryGeometry.push_back(TileCoordinate::fromScreenCoordinate( diff --git a/src/mbgl/style/expression/compound_expression.cpp b/src/mbgl/style/expression/compound_expression.cpp index 825307432b..6958b1d625 100644 --- a/src/mbgl/style/expression/compound_expression.cpp +++ b/src/mbgl/style/expression/compound_expression.cpp @@ -435,7 +435,8 @@ const auto& propertiesCompoundExpression() { }; } std::unordered_map<std::string, Value> result; - const PropertyMap properties = params.feature->getProperties(); + const PropertyMap& properties = params.feature->getProperties(); + result.reserve(properties.size()); for (const auto& entry : properties) { result[entry.first] = toExpressionValue(entry.second); } diff --git a/src/mbgl/style/expression/expression.cpp b/src/mbgl/style/expression/expression.cpp index b3641b9448..eedc706633 100644 --- a/src/mbgl/style/expression/expression.cpp +++ b/src/mbgl/style/expression/expression.cpp @@ -15,9 +15,8 @@ public: FeatureType getType() const override { return apply_visitor(ToFeatureType(), feature.geometry); } - PropertyMap getProperties() const override { return feature.properties; } + const PropertyMap& getProperties() const override { return feature.properties; } FeatureIdentifier getID() const override { return feature.id; } - GeometryCollection getGeometries() const override { return {}; } optional<mbgl::Value> getValue(const std::string& key) const override { auto it = feature.properties.find(key); if (it != feature.properties.end()) { diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp index b7d2189afd..79bb984aa2 100644 --- a/src/mbgl/text/placement.cpp +++ b/src/mbgl/text/placement.cpp @@ -545,46 +545,38 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, const TransformState seenCrossTileIDs.insert(symbolInstance.crossTileID); if (symbolInstance.hasText) { - auto opacityVertex = SymbolSDFTextProgram::opacityVertex(opacityState.text.placed, opacityState.text.opacity); + size_t textOpacityVerticesSize = 0u; + const auto& opacityVertex = SymbolSDFTextProgram::opacityVertex(opacityState.text.placed, opacityState.text.opacity); if (symbolInstance.placedRightTextIndex) { - for (size_t i = 0; i < symbolInstance.rightJustifiedGlyphQuadsSize * 4; i++) { - bucket.text.opacityVertices.emplace_back(opacityVertex); - } + textOpacityVerticesSize += symbolInstance.rightJustifiedGlyphQuadsSize * 4; PlacedSymbol& placed = bucket.text.placedSymbols[*symbolInstance.placedRightTextIndex]; placed.hidden = opacityState.isHidden(); } if (symbolInstance.placedCenterTextIndex && !symbolInstance.singleLine) { - for (size_t i = 0; i < symbolInstance.centerJustifiedGlyphQuadsSize * 4; i++) { - bucket.text.opacityVertices.emplace_back(opacityVertex); - } + textOpacityVerticesSize += symbolInstance.centerJustifiedGlyphQuadsSize * 4; PlacedSymbol& placed = bucket.text.placedSymbols[*symbolInstance.placedCenterTextIndex]; placed.hidden = opacityState.isHidden(); } if (symbolInstance.placedLeftTextIndex && !symbolInstance.singleLine) { - for (size_t i = 0; i < symbolInstance.leftJustifiedGlyphQuadsSize * 4; i++) { - bucket.text.opacityVertices.emplace_back(opacityVertex); - } + textOpacityVerticesSize += symbolInstance.leftJustifiedGlyphQuadsSize * 4; PlacedSymbol& placed = bucket.text.placedSymbols[*symbolInstance.placedLeftTextIndex]; placed.hidden = opacityState.isHidden(); } if (symbolInstance.placedVerticalTextIndex) { - for (size_t i = 0; i < symbolInstance.verticalGlyphQuadsSize * 4; i++) { - bucket.text.opacityVertices.emplace_back(opacityVertex); - } + textOpacityVerticesSize += symbolInstance.verticalGlyphQuadsSize * 4; bucket.text.placedSymbols[*symbolInstance.placedVerticalTextIndex].hidden = opacityState.isHidden(); } + bucket.text.opacityVertices.extend(textOpacityVerticesSize, opacityVertex); + auto prevOffset = variableOffsets.find(symbolInstance.crossTileID); if (prevOffset != variableOffsets.end()) { markUsedJustification(bucket, prevOffset->second.anchor, symbolInstance); } } if (symbolInstance.hasIcon) { - auto opacityVertex = SymbolIconProgram::opacityVertex(opacityState.icon.placed, opacityState.icon.opacity); - bucket.icon.opacityVertices.emplace_back(opacityVertex); - bucket.icon.opacityVertices.emplace_back(opacityVertex); - bucket.icon.opacityVertices.emplace_back(opacityVertex); - bucket.icon.opacityVertices.emplace_back(opacityVertex); + const auto& opacityVertex = SymbolIconProgram::opacityVertex(opacityState.icon.placed, opacityState.icon.opacity); + bucket.icon.opacityVertices.extend(4, opacityVertex); if (symbolInstance.placedIconIndex) { bucket.icon.placedSymbols[*symbolInstance.placedIconIndex].hidden = opacityState.isHidden(); } @@ -594,10 +586,8 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, const TransformState if (feature.alongLine) { return; } - auto dynamicVertex = CollisionBoxProgram::dynamicVertex(placed, false, {}); - for (size_t i = 0; i < feature.boxes.size() * 4; i++) { - bucket.collisionBox->dynamicVertices.emplace_back(dynamicVertex); - } + const auto& dynamicVertex = CollisionBoxProgram::dynamicVertex(placed, false, {}); + bucket.collisionBox->dynamicVertices.extend(feature.boxes.size() * 4, dynamicVertex); }; auto updateCollisionTextBox = [this, &bucket, &symbolInstance, &state, variablePlacement, rotateWithMap, pitchWithMap](const auto& feature, const bool placed) { @@ -629,10 +619,8 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, const TransformState used = false; } } - auto dynamicVertex = CollisionBoxProgram::dynamicVertex(placed, !used, shift); - for (size_t i = 0; i < feature.boxes.size() * 4; i++) { - bucket.collisionBox->dynamicVertices.emplace_back(dynamicVertex); - } + const auto& dynamicVertex = CollisionBoxProgram::dynamicVertex(placed, !used, shift); + bucket.collisionBox->dynamicVertices.extend(feature.boxes.size() * 4, dynamicVertex); }; auto updateCollisionCircles = [&](const auto& feature, const bool placed) { @@ -640,11 +628,8 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, const TransformState return; } for (const CollisionBox& box : feature.boxes) { - auto dynamicVertex = CollisionBoxProgram::dynamicVertex(placed, !box.used, {}); - bucket.collisionCircle->dynamicVertices.emplace_back(dynamicVertex); - bucket.collisionCircle->dynamicVertices.emplace_back(dynamicVertex); - bucket.collisionCircle->dynamicVertices.emplace_back(dynamicVertex); - bucket.collisionCircle->dynamicVertices.emplace_back(dynamicVertex); + const auto& dynamicVertex = CollisionBoxProgram::dynamicVertex(placed, !box.used, {}); + bucket.collisionCircle->dynamicVertices.extend(4, dynamicVertex); } }; @@ -665,18 +650,29 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, const TransformState } } +namespace { +optional<size_t> justificationToIndex(style::TextJustifyType justify, const SymbolInstance& symbolInstance) { + switch(justify) { + case style::TextJustifyType::Right: return symbolInstance.placedRightTextIndex; + case style::TextJustifyType::Center: return symbolInstance.placedCenterTextIndex; + case style::TextJustifyType::Left: return symbolInstance.placedLeftTextIndex; + case style::TextJustifyType::Auto: break; + } + assert(false); + return nullopt; +} + +const style::TextJustifyType justifyTypes[] = {style::TextJustifyType::Right, style::TextJustifyType::Center, style::TextJustifyType::Left}; + +} // namespace + void Placement::markUsedJustification(SymbolBucket& bucket, style::TextVariableAnchorType placedAnchor, SymbolInstance& symbolInstance) { - std::map<style::TextJustifyType, optional<size_t>> justificationToIndex { - {style::TextJustifyType::Right, symbolInstance.placedRightTextIndex}, - {style::TextJustifyType::Center, symbolInstance.placedCenterTextIndex}, - {style::TextJustifyType::Left, symbolInstance.placedLeftTextIndex}, - }; - style::TextJustifyType justify = getAnchorJustification(placedAnchor); - assert(justify == style::TextJustifyType::Right || justify == style::TextJustifyType::Center || justify == style::TextJustifyType::Left); - const optional<size_t> autoIndex = justificationToIndex[justify]; - - for (auto& pair : justificationToIndex) { - const optional<size_t> index = pair.second; + style::TextJustifyType anchorJustify = getAnchorJustification(placedAnchor); + assert(anchorJustify != style::TextJustifyType::Auto); + const optional<size_t>& autoIndex = justificationToIndex(anchorJustify, symbolInstance); + + for (auto& justify : justifyTypes) { + const optional<size_t> index = justificationToIndex(justify, symbolInstance); if (index) { assert(bucket.text.placedSymbols.size() > *index); if (autoIndex && *index != *autoIndex) { diff --git a/src/mbgl/tile/geojson_tile_data.hpp b/src/mbgl/tile/geojson_tile_data.hpp index 3605af9690..5559965cd7 100644 --- a/src/mbgl/tile/geojson_tile_data.hpp +++ b/src/mbgl/tile/geojson_tile_data.hpp @@ -17,7 +17,7 @@ public: return apply_visitor(ToFeatureType(), feature.geometry); } - PropertyMap getProperties() const override { + const PropertyMap& getProperties() const override { return feature.properties; } @@ -25,15 +25,17 @@ public: return feature.id; } - GeometryCollection getGeometries() const override { - GeometryCollection geometry = apply_visitor(ToGeometryCollection(), feature.geometry); + const GeometryCollection& getGeometries() const override { + if (!geometry) { + geometry = apply_visitor(ToGeometryCollection(), feature.geometry); - // https://github.com/mapbox/geojson-vt-cpp/issues/44 - if (getType() == FeatureType::Polygon) { - geometry = fixupPolygons(geometry); + // https://github.com/mapbox/geojson-vt-cpp/issues/44 + if (getType() == FeatureType::Polygon) { + geometry = fixupPolygons(*geometry); + } } - return geometry; + return *geometry; } optional<Value> getValue(const std::string& key) const override { @@ -43,6 +45,8 @@ public: } return optional<Value>(); } + + mutable optional<GeometryCollection> geometry; }; class GeoJSONTileLayer : public GeometryTileLayer { diff --git a/src/mbgl/tile/geometry_tile.cpp b/src/mbgl/tile/geometry_tile.cpp index 7f1bed49f4..a431ae423e 100644 --- a/src/mbgl/tile/geometry_tile.cpp +++ b/src/mbgl/tile/geometry_tile.cpp @@ -360,7 +360,7 @@ void GeometryTile::querySourceFeatures( continue; } - result.push_back(convertFeature(*feature, id.canonical)); + result.emplace_back(convertFeature(*feature, id.canonical)); } } } diff --git a/src/mbgl/tile/geometry_tile_data.cpp b/src/mbgl/tile/geometry_tile_data.cpp index 680f8d1497..5320df6893 100644 --- a/src/mbgl/tile/geometry_tile_data.cpp +++ b/src/mbgl/tile/geometry_tile_data.cpp @@ -57,32 +57,31 @@ std::vector<GeometryCollection> classifyRings(const GeometryCollection& rings) { std::size_t len = rings.size(); if (len <= 1) { - polygons.push_back(rings); + polygons.emplace_back(rings.clone()); return polygons; } GeometryCollection polygon; int8_t ccw = 0; - for (std::size_t i = 0; i < len; i++) { - double area = signedArea(rings[i]); - - if (area == 0) - continue; + for (const auto& ring : rings) { + double area = signedArea(ring); + if (area == 0) continue; - if (ccw == 0) + if (ccw == 0) { ccw = (area < 0 ? -1 : 1); + } if (ccw == (area < 0 ? -1 : 1) && !polygon.empty()) { - polygons.push_back(polygon); - polygon.clear(); + polygons.emplace_back(std::move(polygon)); } - polygon.push_back(rings[i]); + polygon.emplace_back(ring); } - if (!polygon.empty()) - polygons.push_back(polygon); + if (!polygon.empty()) { + polygons.emplace_back(std::move(polygon)); + } return polygons; } @@ -112,7 +111,7 @@ static Feature::geometry_type convertGeometry(const GeometryTileFeature& geometr ); }; - GeometryCollection geometries = geometryTileFeature.getGeometries(); + const GeometryCollection& geometries = geometryTileFeature.getGeometries(); switch (geometryTileFeature.getType()) { case FeatureType::Unknown: { @@ -180,4 +179,14 @@ Feature convertFeature(const GeometryTileFeature& geometryTileFeature, const Can return feature; } +const PropertyMap& GeometryTileFeature::getProperties() const { + static const PropertyMap dummy; + return dummy; +} + +const GeometryCollection& GeometryTileFeature::getGeometries() const { + static const GeometryCollection dummy; + return dummy; +} + } // namespace mbgl diff --git a/src/mbgl/tile/geometry_tile_data.hpp b/src/mbgl/tile/geometry_tile_data.hpp index 6ce67a532e..5d43a68388 100644 --- a/src/mbgl/tile/geometry_tile_data.hpp +++ b/src/mbgl/tile/geometry_tile_data.hpp @@ -35,6 +35,13 @@ public: GeometryCollection(Args&&... args) : std::vector<GeometryCoordinates>(std::forward<Args>(args)...) {} GeometryCollection(std::initializer_list<GeometryCoordinates> args) : std::vector<GeometryCoordinates>(std::move(args)) {} + GeometryCollection(GeometryCollection&&) = default; + GeometryCollection& operator=(GeometryCollection&&) = default; + + GeometryCollection clone() const { return GeometryCollection(*this); } + +private: + GeometryCollection(const GeometryCollection&) = default; }; class GeometryTileFeature { @@ -42,9 +49,9 @@ public: virtual ~GeometryTileFeature() = default; virtual FeatureType getType() const = 0; virtual optional<Value> getValue(const std::string& key) const = 0; - virtual PropertyMap getProperties() const { return PropertyMap(); } + virtual const PropertyMap& getProperties() const; virtual FeatureIdentifier getID() const { return NullValue {}; } - virtual GeometryCollection getGeometries() const = 0; + virtual const GeometryCollection& getGeometries() const; }; class GeometryTileLayer { @@ -90,31 +97,16 @@ struct ToGeometryCollection { return { { geom } }; } GeometryCollection operator()(const mapbox::geometry::multi_point<int16_t>& geom) const { - GeometryCoordinates coordinates; - coordinates.reserve(geom.size()); - for (const auto& point : geom) { - coordinates.emplace_back(point); - } - return { coordinates }; + return { geom }; } GeometryCollection operator()(const mapbox::geometry::line_string<int16_t>& geom) const { - GeometryCoordinates coordinates; - coordinates.reserve(geom.size()); - for (const auto& point : geom) { - coordinates.emplace_back(point); - } - return { coordinates }; + return { geom }; } GeometryCollection operator()(const mapbox::geometry::multi_line_string<int16_t>& geom) const { GeometryCollection collection; collection.reserve(geom.size()); for (const auto& ring : geom) { - GeometryCoordinates coordinates; - coordinates.reserve(ring.size()); - for (const auto& point : ring) { - coordinates.emplace_back(point); - } - collection.push_back(std::move(coordinates)); + collection.emplace_back(ring); } return collection; } @@ -122,25 +114,15 @@ struct ToGeometryCollection { GeometryCollection collection; collection.reserve(geom.size()); for (const auto& ring : geom) { - GeometryCoordinates coordinates; - coordinates.reserve(ring.size()); - for (const auto& point : ring) { - coordinates.emplace_back(point); - } - collection.push_back(std::move(coordinates)); + collection.emplace_back(ring); } return collection; } GeometryCollection operator()(const mapbox::geometry::multi_polygon<int16_t>& geom) const { GeometryCollection collection; - for (auto& polygon : geom) { - for (auto& ring : polygon) { - GeometryCoordinates coordinates; - coordinates.reserve(ring.size()); - for (auto& point : ring) { - coordinates.emplace_back(point); - } - collection.push_back(std::move(coordinates)); + for (const auto& polygon : geom) { + for (const auto& ring : polygon) { + collection.emplace_back(ring); } } return collection; diff --git a/src/mbgl/tile/geometry_tile_worker.cpp b/src/mbgl/tile/geometry_tile_worker.cpp index a69825d346..f4d57e5bfc 100644 --- a/src/mbgl/tile/geometry_tile_worker.cpp +++ b/src/mbgl/tile/geometry_tile_worker.cpp @@ -382,7 +382,7 @@ void GeometryTileWorker::parse() { if (!filter(expression::EvaluationContext { static_cast<float>(this->id.overscaledZ), feature.get() })) continue; - GeometryCollection geometries = feature->getGeometries(); + const GeometryCollection& geometries = feature->getGeometries(); bucket->addFeature(*feature, geometries, {}, PatternLayerMap ()); featureIndex->insert(geometries, i, sourceLayerID, leaderImpl.id); } diff --git a/src/mbgl/tile/vector_tile_data.cpp b/src/mbgl/tile/vector_tile_data.cpp index 2d47515e0f..d53f1deba6 100644 --- a/src/mbgl/tile/vector_tile_data.cpp +++ b/src/mbgl/tile/vector_tile_data.cpp @@ -26,22 +26,26 @@ optional<Value> VectorTileFeature::getValue(const std::string& key) const { return value->is<NullValue>() ? nullopt : std::move(value); } -std::unordered_map<std::string, Value> VectorTileFeature::getProperties() const { - return feature.getProperties(); +const PropertyMap& VectorTileFeature::getProperties() const { + if (!properties) { + properties = feature.getProperties(); + } + return *properties; } FeatureIdentifier VectorTileFeature::getID() const { return feature.getID(); } -GeometryCollection VectorTileFeature::getGeometries() const { - const float scale = float(util::EXTENT) / feature.getExtent(); - auto lines = feature.getGeometries<GeometryCollection>(scale); - if (feature.getVersion() >= 2 || feature.getType() != mapbox::vector_tile::GeomType::POLYGON) { - return lines; - } else { - return fixupPolygons(lines); +const GeometryCollection& VectorTileFeature::getGeometries() const { + if (!lines) { + const float scale = float(util::EXTENT) / feature.getExtent(); + lines = feature.getGeometries<GeometryCollection>(scale); + if (feature.getVersion() < 2 && feature.getType() == mapbox::vector_tile::GeomType::POLYGON) { + lines = fixupPolygons(*lines); + } } + return *lines; } VectorTileLayer::VectorTileLayer(std::shared_ptr<const std::string> data_, diff --git a/src/mbgl/tile/vector_tile_data.hpp b/src/mbgl/tile/vector_tile_data.hpp index 7c95121a37..f5086936f8 100644 --- a/src/mbgl/tile/vector_tile_data.hpp +++ b/src/mbgl/tile/vector_tile_data.hpp @@ -15,12 +15,14 @@ public: FeatureType getType() const override; optional<Value> getValue(const std::string& key) const override; - std::unordered_map<std::string, Value> getProperties() const override; + const PropertyMap& getProperties() const override; FeatureIdentifier getID() const override; - GeometryCollection getGeometries() const override; + const GeometryCollection& getGeometries() const override; private: mapbox::vector_tile::feature feature; + mutable optional<GeometryCollection> lines; + mutable optional<PropertyMap> properties; }; class VectorTileLayer : public GeometryTileLayer { diff --git a/src/mbgl/util/grid_index.cpp b/src/mbgl/util/grid_index.cpp index f6b59b1bac..f33e889ddb 100644 --- a/src/mbgl/util/grid_index.cpp +++ b/src/mbgl/util/grid_index.cpp @@ -9,14 +9,16 @@ namespace mbgl { template <class T> -GridIndex<T>::GridIndex(const float width_, const float height_, const int16_t cellSize_) : +GridIndex<T>::GridIndex(const float width_, const float height_, const uint32_t cellSize_) : width(width_), height(height_), - xCellCount(std::ceil(width_ / cellSize_)), - yCellCount(std::ceil(height_ / cellSize_)), - xScale(xCellCount / width_), - yScale(yCellCount / height_) + xCellCount(std::ceil(width / cellSize_)), + yCellCount(std::ceil(height / cellSize_)), + xScale(xCellCount / width), + yScale(yCellCount / height) { + assert(width > 0.0f); + assert(height > 0.0f); boxCells.resize(xCellCount * yCellCount); circleCells.resize(xCellCount * yCellCount); } @@ -30,7 +32,7 @@ void GridIndex<T>::insert(T&& t, const BBox& bbox) { auto cx2 = convertToXCellCoord(bbox.max.x); auto cy2 = convertToYCellCoord(bbox.max.y); - int16_t x, y, cellIndex; + std::size_t x, y, cellIndex; for (x = cx1; x <= cx2; ++x) { for (y = cy1; y <= cy2; ++y) { cellIndex = xCellCount * y + x; @@ -50,7 +52,7 @@ void GridIndex<T>::insert(T&& t, const BCircle& bcircle) { auto cx2 = convertToXCellCoord(bcircle.center.x + bcircle.radius); auto cy2 = convertToYCellCoord(bcircle.center.y + bcircle.radius); - int16_t x, y, cellIndex; + std::size_t x, y, cellIndex; for (x = cx1; x <= cx2; ++x) { for (y = cy1; y <= cy2; ++y) { cellIndex = xCellCount * y + x; @@ -151,7 +153,7 @@ void GridIndex<T>::query(const BBox& queryBBox, std::function<bool (const T&, co auto cx2 = convertToXCellCoord(queryBBox.max.x); auto cy2 = convertToYCellCoord(queryBBox.max.y); - int16_t x, y, cellIndex; + std::size_t x, y, cellIndex; for (x = cx1; x <= cx2; ++x) { for (y = cy1; y <= cy2; ++y) { cellIndex = xCellCount * y + x; @@ -214,7 +216,7 @@ void GridIndex<T>::query(const BCircle& queryBCircle, std::function<bool (const auto cx2 = convertToXCellCoord(queryBCircle.center.x + queryBCircle.radius); auto cy2 = convertToYCellCoord(queryBCircle.center.y + queryBCircle.radius); - int16_t x, y, cellIndex; + std::size_t x, y, cellIndex; for (x = cx1; x <= cx2; ++x) { for (y = cy1; y <= cy2; ++y) { cellIndex = xCellCount * y + x; @@ -252,12 +254,12 @@ void GridIndex<T>::query(const BCircle& queryBCircle, std::function<bool (const } template <class T> -int16_t GridIndex<T>::convertToXCellCoord(const float x) const { +std::size_t GridIndex<T>::convertToXCellCoord(const float x) const { return util::max(0.0, util::min(xCellCount - 1.0, std::floor(x * xScale))); } template <class T> -int16_t GridIndex<T>::convertToYCellCoord(const float y) const { +std::size_t GridIndex<T>::convertToYCellCoord(const float y) const { return util::max(0.0, util::min(yCellCount - 1.0, std::floor(y * yScale))); } diff --git a/src/mbgl/util/grid_index.hpp b/src/mbgl/util/grid_index.hpp index 4c2d7dccc8..cb38023e59 100644 --- a/src/mbgl/util/grid_index.hpp +++ b/src/mbgl/util/grid_index.hpp @@ -57,7 +57,7 @@ template <class T> class GridIndex { public: - GridIndex(const float width_, const float height_, const int16_t cellSize_); + GridIndex(const float width_, const float height_, const uint32_t cellSize_); using BBox = mapbox::geometry::box<float>; using BCircle = geometry::circle<float>; @@ -81,8 +81,8 @@ private: void query(const BBox&, std::function<bool (const T&, const BBox&)>) const; void query(const BCircle&, std::function<bool (const T&, const BBox&)>) const; - int16_t convertToXCellCoord(const float x) const; - int16_t convertToYCellCoord(const float y) const; + std::size_t convertToXCellCoord(const float x) const; + std::size_t convertToYCellCoord(const float y) const; bool boxesCollide(const BBox&, const BBox&) const; bool circlesCollide(const BCircle&, const BCircle&) const; @@ -91,8 +91,8 @@ private: const float width; const float height; - const int16_t xCellCount; - const int16_t yCellCount; + const std::size_t xCellCount; + const std::size_t yCellCount; const double xScale; const double yScale; diff --git a/test/gl/bucket.test.cpp b/test/gl/bucket.test.cpp index 9c9847cf4d..f97fd53919 100644 --- a/test/gl/bucket.test.cpp +++ b/test/gl/bucket.test.cpp @@ -131,7 +131,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(StubGeometryTileFeature { {}, FeatureType::Point, std::move(point), properties }, point, {}, PatternLayerMap()); ASSERT_FALSE(bucket.hasData()); ASSERT_FALSE(bucket.needsUpload()); diff --git a/test/map/map.test.cpp b/test/map/map.test.cpp index fd831a05b7..8cb781c6df 100644 --- a/test/map/map.test.cpp +++ b/test/map/map.test.cpp @@ -20,8 +20,10 @@ #include <mbgl/style/style.hpp> #include <mbgl/style/image.hpp> #include <mbgl/style/layers/background_layer.hpp> +#include <mbgl/style/layers/raster_layer.hpp> #include <mbgl/style/layers/symbol_layer.hpp> #include <mbgl/style/sources/geojson_source.hpp> +#include <mbgl/style/sources/image_source.hpp> #include <mbgl/util/color.hpp> using namespace mbgl; @@ -867,3 +869,12 @@ TEST(Map, Issue12432) { test.runLoop.run(); } + +// https://github.com/mapbox/mapbox-gl-native/issues/15216 +TEST(Map, Issue15216) { + MapTest<> test { 1.0f, MapMode::Continuous }; + test.map.getStyle().addSource(std::make_unique<ImageSource>("ImageSource", std::array<LatLng, 4>())); + test.map.getStyle().addLayer(std::make_unique<RasterLayer>("RasterLayer", "ImageSource")); + // Passes, if there is no assertion hit. + test.runLoop.runOnce(); +}
\ No newline at end of file diff --git a/test/src/mbgl/test/stub_geometry_tile_feature.hpp b/test/src/mbgl/test/stub_geometry_tile_feature.hpp index ef21f8e937..e74988df2e 100644 --- a/test/src/mbgl/test/stub_geometry_tile_feature.hpp +++ b/test/src/mbgl/test/stub_geometry_tile_feature.hpp @@ -33,7 +33,7 @@ public: return properties.count(key) ? properties.at(key) : optional<Value>(); } - GeometryCollection getGeometries() const override { + const GeometryCollection& getGeometries() const override { return geometry; } }; diff --git a/test/tile/vector_tile.test.cpp b/test/tile/vector_tile.test.cpp index b912af1f15..940c0272db 100644 --- a/test/tile/vector_tile.test.cpp +++ b/test/tile/vector_tile.test.cpp @@ -98,7 +98,7 @@ TEST(VectorTileData, ParseResults) { ASSERT_TRUE(feature->getID().is<uint64_t>()); ASSERT_EQ(feature->getID().get<uint64_t>(), 1u); - std::unordered_map<std::string, Value> properties = feature->getProperties(); + const std::unordered_map<std::string, Value>& properties = feature->getProperties(); ASSERT_EQ(properties.size(), 3u); ASSERT_EQ(properties.at("disputed"), *feature->getValue("disputed")); diff --git a/test/util/grid_index.test.cpp b/test/util/grid_index.test.cpp index b0a4e581a3..157e66b38d 100644 --- a/test/util/grid_index.test.cpp +++ b/test/util/grid_index.test.cpp @@ -51,3 +51,8 @@ TEST(GridIndex, CircleBox) { EXPECT_EQ(grid.query({{0, 80}, {20, 100}}), (std::vector<int16_t>{2})); } +TEST(GridIndex, IndexesFeaturesOverflow) { + GridIndex<int16_t> grid(5000, 5000, 25); + grid.insert(0, {{4500, 4500}, {4900, 4900}}); + EXPECT_EQ(grid.query({{4000, 4000}, {5000, 5000}}), (std::vector<int16_t>{0})); +} diff --git a/test/util/merge_lines.test.cpp b/test/util/merge_lines.test.cpp index 1c8c7aae8f..5dc846ad6e 100644 --- a/test/util/merge_lines.test.cpp +++ b/test/util/merge_lines.test.cpp @@ -42,14 +42,14 @@ 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 = { - { {}, 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 }, - { {}, FeatureType::LineString, { emptyLine }, properties }, - { {}, FeatureType::LineString, { emptyLine }, properties }, - { {}, FeatureType::LineString, { emptyLine }, properties } - }; + std::vector<StubGeometryTileFeature> expected1; + expected1.emplace_back(StubGeometryTileFeature({}, FeatureType::LineString, {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}}}, properties)); + expected1.emplace_back(StubGeometryTileFeature({}, FeatureType::LineString, {{{4, 0}, {5, 0}, {6, 0}}}, properties)); + expected1.emplace_back(StubGeometryTileFeature({}, FeatureType::LineString, {{{5, 0}, {6, 0}, {7, 0}, {8, 0}, {9, 0}}}, properties)); + expected1.emplace_back(StubGeometryTileFeature({}, FeatureType::LineString, { emptyLine }, properties)); + expected1.emplace_back(StubGeometryTileFeature({}, FeatureType::LineString, { emptyLine }, properties)); + expected1.emplace_back(StubGeometryTileFeature({}, FeatureType::LineString, { emptyLine }, properties)); + mbgl::util::mergeLines(input1); @@ -65,11 +65,11 @@ 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 = { - { {}, 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 } - }; + std::vector<StubGeometryTileFeature> expected2; + expected2.emplace_back(StubGeometryTileFeature({}, FeatureType::LineString, {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}}}, properties)); + expected2.emplace_back(StubGeometryTileFeature({}, FeatureType::LineString, { emptyLine }, properties)); + expected2.emplace_back(StubGeometryTileFeature({}, FeatureType::LineString, { emptyLine }, properties)); + mbgl::util::mergeLines(input2); @@ -85,11 +85,11 @@ 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 = { - { {}, FeatureType::LineString, {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {0, 0}}}, properties }, - { {}, FeatureType::LineString, { emptyLine }, properties }, - { {}, FeatureType::LineString, { emptyLine }, properties } - }; + std::vector<StubGeometryTileFeature> expected3; + expected3.emplace_back(StubGeometryTileFeature({}, FeatureType::LineString, {{{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {0, 0}}}, properties)); + expected3.emplace_back(StubGeometryTileFeature({}, FeatureType::LineString, { emptyLine }, properties)); + expected3.emplace_back(StubGeometryTileFeature({}, FeatureType::LineString, { emptyLine }, properties)); + mbgl::util::mergeLines(input3); @@ -102,20 +102,20 @@ 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 StubGeometryTileFeature expected{ {}, FeatureType::LineString, {}, properties }; mbgl::util::mergeLines(input); - EXPECT_EQ(input[0].geometry, expected[0].getGeometries()); + EXPECT_EQ(input[0].geometry, expected.getGeometries()); } 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 StubGeometryTileFeature expected{ {}, FeatureType::LineString, {}, properties }; mbgl::util::mergeLines(input); - EXPECT_EQ(input[0].geometry, expected[0].getGeometries()); + EXPECT_EQ(input[0].geometry, expected.getGeometries()); } diff --git a/vendor/geometry.hpp b/vendor/geometry.hpp deleted file mode 160000 -Subproject c83a2ab18a225254f128b6f5115aa39d04f2de2 diff --git a/vendor/geometry.hpp-files.json b/vendor/geometry.hpp-files.json deleted file mode 100644 index 942d372a38..0000000000 --- a/vendor/geometry.hpp-files.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "//": "This file is generated. Do not edit. Regenerate it with scripts/generate-file-lists.js", - "sources": [], - "public_headers": { - "mapbox/feature.hpp": "vendor/geometry.hpp/include/mapbox/feature.hpp", - "mapbox/geometry.hpp": "vendor/geometry.hpp/include/mapbox/geometry.hpp", - "mapbox/geometry/box.hpp": "vendor/geometry.hpp/include/mapbox/geometry/box.hpp", - "mapbox/geometry/empty.hpp": "vendor/geometry.hpp/include/mapbox/geometry/empty.hpp", - "mapbox/geometry/envelope.hpp": "vendor/geometry.hpp/include/mapbox/geometry/envelope.hpp", - "mapbox/geometry/for_each_point.hpp": "vendor/geometry.hpp/include/mapbox/geometry/for_each_point.hpp", - "mapbox/geometry/geometry.hpp": "vendor/geometry.hpp/include/mapbox/geometry/geometry.hpp", - "mapbox/geometry/line_string.hpp": "vendor/geometry.hpp/include/mapbox/geometry/line_string.hpp", - "mapbox/geometry/multi_line_string.hpp": "vendor/geometry.hpp/include/mapbox/geometry/multi_line_string.hpp", - "mapbox/geometry/multi_point.hpp": "vendor/geometry.hpp/include/mapbox/geometry/multi_point.hpp", - "mapbox/geometry/multi_polygon.hpp": "vendor/geometry.hpp/include/mapbox/geometry/multi_polygon.hpp", - "mapbox/geometry/point.hpp": "vendor/geometry.hpp/include/mapbox/geometry/point.hpp", - "mapbox/geometry/point_arithmetic.hpp": "vendor/geometry.hpp/include/mapbox/geometry/point_arithmetic.hpp", - "mapbox/geometry/polygon.hpp": "vendor/geometry.hpp/include/mapbox/geometry/polygon.hpp", - "mapbox/geometry_io.hpp": "vendor/geometry.hpp/include/mapbox/geometry_io.hpp" - }, - "private_headers": {} -} diff --git a/vendor/geometry.hpp.cmake b/vendor/geometry.hpp.cmake deleted file mode 100644 index d97c2a9f6c..0000000000 --- a/vendor/geometry.hpp.cmake +++ /dev/null @@ -1,5 +0,0 @@ -add_library(geometry.hpp INTERFACE) - -target_include_directories(geometry.hpp SYSTEM INTERFACE - ${CMAKE_SOURCE_DIR}/vendor/geometry.hpp/include -) diff --git a/vendor/mapbox-base b/vendor/mapbox-base new file mode 160000 +Subproject 13fa9eced82977791d814a7d549b2b6929b82b3 diff --git a/vendor/mapbox-base-files.json b/vendor/mapbox-base-files.json new file mode 100644 index 0000000000..2e952b9661 --- /dev/null +++ b/vendor/mapbox-base-files.json @@ -0,0 +1,29 @@ +{ + "//": "This file is generated. Do not edit. Regenerate it with scripts/generate-file-lists.js", + "sources": [], + "public_headers": { + "mapbox/feature.hpp": "vendor/mapbox-base/libs/geometry.hpp/include/mapbox/feature.hpp", + "mapbox/geometry.hpp": "vendor/mapbox-base/libs/geometry.hpp/include/mapbox/geometry.hpp", + "mapbox/geometry/box.hpp": "vendor/mapbox-base/libs/geometry.hpp/include/mapbox/geometry/box.hpp", + "mapbox/geometry/empty.hpp": "vendor/mapbox-base/libs/geometry.hpp/include/mapbox/geometry/empty.hpp", + "mapbox/geometry/envelope.hpp": "vendor/mapbox-base/libs/geometry.hpp/include/mapbox/geometry/envelope.hpp", + "mapbox/geometry/for_each_point.hpp": "vendor/mapbox-base/libs/geometry.hpp/include/mapbox/geometry/for_each_point.hpp", + "mapbox/geometry/geometry.hpp": "vendor/mapbox-base/libs/geometry.hpp/include/mapbox/geometry/geometry.hpp", + "mapbox/geometry/line_string.hpp": "vendor/mapbox-base/libs/geometry.hpp/include/mapbox/geometry/line_string.hpp", + "mapbox/geometry/multi_line_string.hpp": "vendor/mapbox-base/libs/geometry.hpp/include/mapbox/geometry/multi_line_string.hpp", + "mapbox/geometry/multi_point.hpp": "vendor/mapbox-base/libs/geometry.hpp/include/mapbox/geometry/multi_point.hpp", + "mapbox/geometry/multi_polygon.hpp": "vendor/mapbox-base/libs/geometry.hpp/include/mapbox/geometry/multi_polygon.hpp", + "mapbox/geometry/point.hpp": "vendor/mapbox-base/libs/geometry.hpp/include/mapbox/geometry/point.hpp", + "mapbox/geometry/point_arithmetic.hpp": "vendor/mapbox-base/libs/geometry.hpp/include/mapbox/geometry/point_arithmetic.hpp", + "mapbox/geometry/polygon.hpp": "vendor/mapbox-base/libs/geometry.hpp/include/mapbox/geometry/polygon.hpp", + "mapbox/geometry_io.hpp": "vendor/mapbox-base/libs/geometry.hpp/include/mapbox/geometry_io.hpp", + "optional.hpp": "vendor/mapbox-base/libs/optional/optional.hpp", + "mapbox/optional.hpp": "vendor/mapbox-base/libs/variant/include/mapbox/optional.hpp", + "mapbox/recursive_wrapper.hpp": "vendor/mapbox-base/libs/variant/include/mapbox/recursive_wrapper.hpp", + "mapbox/variant.hpp": "vendor/mapbox-base/libs/variant/include/mapbox/variant.hpp", + "mapbox/variant_cast.hpp": "vendor/mapbox-base/libs/variant/include/mapbox/variant_cast.hpp", + "mapbox/variant_io.hpp": "vendor/mapbox-base/libs/variant/include/mapbox/variant_io.hpp", + "mapbox/variant_visitor.hpp": "vendor/mapbox-base/libs/variant/include/mapbox/variant_visitor.hpp" + }, + "private_headers": {} +} diff --git a/vendor/optional b/vendor/optional deleted file mode 160000 -Subproject f6249e7fdcb80131c390a083f1621d96023e72e diff --git a/vendor/optional-files.json b/vendor/optional-files.json deleted file mode 100644 index 4d62a8903c..0000000000 --- a/vendor/optional-files.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "//": "This file is generated. Do not edit. Regenerate it with scripts/generate-file-lists.js", - "sources": [], - "public_headers": { - "optional.hpp": "vendor/optional/optional.hpp" - }, - "private_headers": {} -} diff --git a/vendor/optional.cmake b/vendor/optional.cmake deleted file mode 100644 index f4b379d3df..0000000000 --- a/vendor/optional.cmake +++ /dev/null @@ -1,5 +0,0 @@ -add_library(optional INTERFACE) - -target_include_directories(optional SYSTEM INTERFACE - ${CMAKE_SOURCE_DIR}/vendor/optional -) diff --git a/vendor/variant b/vendor/variant deleted file mode 160000 -Subproject cb02ad487e069e050e5db11b1e5e9ccbe269e2f diff --git a/vendor/variant-files.json b/vendor/variant-files.json deleted file mode 100644 index 28998fd4a1..0000000000 --- a/vendor/variant-files.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "//": "This file is generated. Do not edit. Regenerate it with scripts/generate-file-lists.js", - "sources": [], - "public_headers": { - "mapbox/optional.hpp": "vendor/variant/include/mapbox/optional.hpp", - "mapbox/recursive_wrapper.hpp": "vendor/variant/include/mapbox/recursive_wrapper.hpp", - "mapbox/variant.hpp": "vendor/variant/include/mapbox/variant.hpp", - "mapbox/variant_cast.hpp": "vendor/variant/include/mapbox/variant_cast.hpp", - "mapbox/variant_io.hpp": "vendor/variant/include/mapbox/variant_io.hpp", - "mapbox/variant_visitor.hpp": "vendor/variant/include/mapbox/variant_visitor.hpp" - }, - "private_headers": {} -} diff --git a/vendor/variant.cmake b/vendor/variant.cmake deleted file mode 100644 index f4827f41c6..0000000000 --- a/vendor/variant.cmake +++ /dev/null @@ -1,5 +0,0 @@ -add_library(variant INTERFACE) - -target_include_directories(variant SYSTEM INTERFACE - ${CMAKE_SOURCE_DIR}/vendor/variant/include -) |