Skip to content

Commit

Permalink
Expose getFeaturesets (#2887)
Browse files Browse the repository at this point in the history
  • Loading branch information
kiryldz authored Dec 13, 2024
1 parent 486e38a commit fd0ad76
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
Mapbox welcomes participation and contributions from everyone.

# main
## Features ✨ and improvements 🏁
* Localize geofencing attribution dialog.

# 11.9.0
## Features ✨ and improvements 🏁
* Expose experimental `getFeaturesets` for `MapboxMap` and `Style`.

# 11.9.0-rc.1 December 10, 2024
## Features ✨ and improvements 🏁
Expand Down
1 change: 1 addition & 0 deletions maps-sdk/api/maps-sdk.api
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ public final class com/mapbox/maps/Style : com/mapbox/maps/MapboxStyleManager {
public fun addStyleLayer (Lcom/mapbox/bindgen/Value;Lcom/mapbox/maps/LayerPosition;)Lcom/mapbox/bindgen/Expected;
public fun addStyleModel (Ljava/lang/String;Ljava/lang/String;)Lcom/mapbox/bindgen/Expected;
public fun addStyleSource (Ljava/lang/String;Lcom/mapbox/bindgen/Value;)Lcom/mapbox/bindgen/Expected;
public fun getFeaturesets ()Ljava/util/List;
public fun getStyleAtmosphereProperty (Ljava/lang/String;)Lcom/mapbox/maps/StylePropertyValue;
public fun getStyleDefaultCamera ()Lcom/mapbox/maps/CameraOptions;
public fun getStyleGlyphURL ()Ljava/lang/String;
Expand Down
12 changes: 12 additions & 0 deletions maps-sdk/src/main/java/com/mapbox/maps/Style.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,18 @@ class Style internal constructor(
return super.setStyleCustomRasterSourceTileData(sourceId, tiles)
}

/**
* Returns the available featuresets in the currently loaded style.
*
* Note: This function should only be called after the style is fully loaded; otherwise, the result may be unreliable.
*/
@MainThread
@MapboxExperimental
override fun getFeaturesets(): List<FeaturesetDescriptor> {
checkNativeStyle("getFeaturesets")
return super.getFeaturesets()
}

private fun checkNativeStyle(methodName: String) {
if (!isStyleValid) {
logW(
Expand Down
9 changes: 9 additions & 0 deletions maps-sdk/src/test/java/com/mapbox/maps/StyleTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -636,4 +636,13 @@ class StyleTest {
style.setStyleGlyphURL("url")
verifyOnce { styleManager.styleGlyphURL = "url" }
}

@Test
fun getFeaturesets() {
val featuresets = mockk<List<FeaturesetDescriptor>>()
every { styleManager.styleFeaturesets } returns featuresets
val actualFeaturesets = style.getFeaturesets()
verifyOnce { styleManager.styleFeaturesets }
assertEquals(featuresets, actualFeaturesets)
}
}
1 change: 1 addition & 0 deletions sdk-base/api/Release/metalava.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ package com.mapbox.maps {
method @CallSuper @MainThread public com.mapbox.bindgen.Expected<java.lang.String,com.mapbox.bindgen.None> addStyleLayer(com.mapbox.bindgen.Value parameters, com.mapbox.maps.LayerPosition? position);
method @CallSuper @MainThread @com.mapbox.maps.MapboxExperimental public com.mapbox.bindgen.Expected<java.lang.String,com.mapbox.bindgen.None> addStyleModel(String modelId, String modelUri);
method @CallSuper @MainThread public com.mapbox.bindgen.Expected<java.lang.String,com.mapbox.bindgen.None> addStyleSource(String sourceId, com.mapbox.bindgen.Value properties);
method @CallSuper @MainThread @com.mapbox.maps.MapboxExperimental public java.util.List<com.mapbox.maps.FeaturesetDescriptor> getFeaturesets();
method @RestrictTo(androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP_PREFIX) public final com.mapbox.maps.MapLoadingErrorDelegate getMapLoadingErrorDelegate();
method public final float getPixelRatio();
method @CallSuper @MainThread public com.mapbox.maps.StylePropertyValue getStyleAtmosphereProperty(String property);
Expand Down
1 change: 1 addition & 0 deletions sdk-base/api/sdk-base.api
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ public class com/mapbox/maps/MapboxStyleManager {
public fun addStyleLayer (Lcom/mapbox/bindgen/Value;Lcom/mapbox/maps/LayerPosition;)Lcom/mapbox/bindgen/Expected;
public fun addStyleModel (Ljava/lang/String;Ljava/lang/String;)Lcom/mapbox/bindgen/Expected;
public fun addStyleSource (Ljava/lang/String;Lcom/mapbox/bindgen/Value;)Lcom/mapbox/bindgen/Expected;
public fun getFeaturesets ()Ljava/util/List;
public final fun getMapLoadingErrorDelegate ()Lcom/mapbox/maps/MapLoadingErrorDelegate;
public final fun getPixelRatio ()F
public fun getStyleAtmosphereProperty (Ljava/lang/String;)Lcom/mapbox/maps/StylePropertyValue;
Expand Down
13 changes: 13 additions & 0 deletions sdk-base/src/main/java/com/mapbox/maps/MapboxStyleManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1521,4 +1521,17 @@ open class MapboxStyleManager @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
imageId: String,
bitmap: Bitmap
): Expected<String, None> = addImage(imageId, bitmap, false)

/**
* Returns the available featuresets in the currently loaded style.
*
* Note: This function should only be called after the style is fully loaded; otherwise, the result may be unreliable.
*/
@CallSuper
@MainThread
@MapboxExperimental
open fun getFeaturesets(): List<FeaturesetDescriptor> {
ThreadChecker.throwIfNotMainThread()
return styleManager.styleFeaturesets
}
}

0 comments on commit fd0ad76

Please sign in to comment.