-
-
Notifications
You must be signed in to change notification settings - Fork 40
Add RasterDemSource #652
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add RasterDemSource #652
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package org.maplibre.compose.sources | ||
|
|
||
| import org.maplibre.android.style.sources.RasterDemSource as MLNRasterDemSource | ||
| import org.maplibre.android.style.sources.TileSet | ||
| import org.maplibre.compose.util.correctedAndroidUri | ||
| import org.maplibre.compose.util.toLatLngBounds | ||
|
|
||
| public actual class RasterDemSource : Source { | ||
| override val impl: MLNRasterDemSource | ||
|
|
||
| internal constructor(source: MLNRasterDemSource) { | ||
| impl = source | ||
| } | ||
|
|
||
| public actual constructor(id: String, uri: String, tileSize: Int) { | ||
| impl = MLNRasterDemSource(id, uri.correctedAndroidUri(), tileSize) | ||
| } | ||
|
|
||
| public actual constructor( | ||
| id: String, | ||
| tiles: List<String>, | ||
| options: TileSetOptions, | ||
| tileSize: Int, | ||
| ) { | ||
| impl = | ||
| MLNRasterDemSource( | ||
| id, | ||
| TileSet( | ||
| "{\"type\": \"raster-dem\"}", | ||
| *tiles.map { it.correctedAndroidUri() }.toTypedArray(), | ||
| ) | ||
| .apply { | ||
| minZoom = options.minZoom.toFloat() | ||
| maxZoom = options.maxZoom.toFloat() | ||
| options.boundingBox?.let { setBounds(it.toLatLngBounds()) } | ||
| attribution = options.attributionHtml | ||
| }, | ||
| tileSize, | ||
| ) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| package org.maplibre.compose.sources | ||
|
|
||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.key | ||
|
|
||
| /** A map data source of DEM raster images. */ | ||
| public expect class RasterDemSource : Source { | ||
|
|
||
| /** | ||
| * @param id Unique identifier for this source | ||
| * @param uri URI pointing to a JSON file that conforms to the | ||
| * [TileJSON specification](https://github.com/mapbox/tilejson-spec/) | ||
| * @param tileSize width and height (measured in points) of each tiled image in the raster tile | ||
| * source | ||
| */ | ||
| public constructor(id: String, uri: String, tileSize: Int = 512) | ||
|
|
||
| /** | ||
| * @param id Unique identifier for this source | ||
| * @param tiles List of URIs pointing to tile images | ||
| * @param options see [TileSetOptions] | ||
| * @param tileSize width and height (measured in points) of each tiled image in the raster tile | ||
| * source | ||
| */ | ||
| public constructor( | ||
| id: String, | ||
| tiles: List<String>, | ||
| options: TileSetOptions = TileSetOptions(), | ||
| tileSize: Int = SourceDefaults.RASTER_TILE_SIZE, | ||
| ) | ||
| } | ||
|
|
||
| /** Remember a new [RasterDemSource] with the given [tileSize] from the given [uri]. */ | ||
| @Composable | ||
| public fun rememberRasterDemSource( | ||
| uri: String, | ||
| tileSize: Int = SourceDefaults.RASTER_TILE_SIZE, | ||
| ): RasterDemSource = | ||
| key(uri, tileSize) { | ||
| rememberUserSource( | ||
| factory = { RasterDemSource(id = it, uri = uri, tileSize = tileSize) }, | ||
| update = {}, | ||
| ) | ||
| } | ||
|
|
||
| @Composable | ||
| public fun rememberRasterDemSource( | ||
| tiles: List<String>, | ||
| options: TileSetOptions = TileSetOptions(), | ||
| tileSize: Int = SourceDefaults.RASTER_TILE_SIZE, | ||
| ): RasterDemSource = | ||
| key(tiles, options, tileSize) { | ||
| rememberUserSource( | ||
| factory = { RasterDemSource(id = it, tiles = tiles, options = options, tileSize = tileSize) }, | ||
| update = {}, | ||
| ) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package org.maplibre.compose.sources | ||
|
|
||
| public actual class RasterDemSource : Source { | ||
| public actual constructor(id: String, uri: String, tileSize: Int) : super() { | ||
| this.impl = TODO() | ||
| } | ||
|
|
||
| public actual constructor( | ||
| id: String, | ||
| tiles: List<String>, | ||
| options: TileSetOptions, | ||
| tileSize: Int, | ||
| ) : super() { | ||
| this.impl = TODO() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe at least use |
||
| } | ||
|
|
||
| override val impl: Nothing | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is the iOS documentation: https://maplibre.org/maplibre-native/ios/latest/documentation/maplibre/mlnrasterdemsource |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package org.maplibre.compose.sources | ||
|
|
||
| public actual class RasterDemSource : Source { | ||
| public actual constructor(id: String, uri: String, tileSize: Int) : super() { | ||
| this.impl = TODO() | ||
| } | ||
|
|
||
| public actual constructor( | ||
| id: String, | ||
| tiles: List<String>, | ||
| options: TileSetOptions, | ||
| tileSize: Int, | ||
| ) : super() { | ||
| this.impl = TODO() | ||
| } | ||
|
|
||
| override val impl: Nothing | ||
| } |
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The JS documentation would be here: https://maplibre.org/maplibre-gl-js/docs/API/classes/RasterDEMTileSource/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package org.maplibre.compose.sources | ||
|
|
||
| public actual class RasterDemSource : Source { | ||
| public actual constructor(id: String, uri: String, tileSize: Int) : super() { | ||
| this.impl = TODO() | ||
| } | ||
|
|
||
| public actual constructor( | ||
| id: String, | ||
| tiles: List<String>, | ||
| options: TileSetOptions, | ||
| tileSize: Int, | ||
| ) : super() { | ||
| this.impl = TODO() | ||
| } | ||
|
|
||
| override val impl: Nothing | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Raster DEM sources have the additional property
encodingwhich is missing here. Could be represented with