kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
Setup new class to handle "auth" urls
rodzic
11915df72e
commit
42cba353fa
|
@ -9,10 +9,9 @@ import org.osmdroid.util.MapTileIndex
|
||||||
|
|
||||||
class CustomTileSource {
|
class CustomTileSource {
|
||||||
|
|
||||||
//https://tile.openweathermap.org/map/{layer}/{z}/{x}/{y}.png?appid={API key}
|
|
||||||
companion object {
|
companion object {
|
||||||
val OPENWEATHER_RADAR = object : OnlineTileSourceBase(
|
val OPENWEATHER_RADAR = OnlineTileSourceAuth(
|
||||||
"Open Weather Map", 1, 15, 256, ".png", arrayOf(
|
"Open Weather Map", 1, 22, 256, ".png", arrayOf(
|
||||||
"https://tile.openweathermap.org/map/"
|
"https://tile.openweathermap.org/map/"
|
||||||
), "Openweathermap",
|
), "Openweathermap",
|
||||||
TileSourcePolicy(
|
TileSourcePolicy(
|
||||||
|
@ -21,16 +20,10 @@ class CustomTileSource {
|
||||||
or TileSourcePolicy.FLAG_NO_PREVENTIVE
|
or TileSourcePolicy.FLAG_NO_PREVENTIVE
|
||||||
or TileSourcePolicy.FLAG_USER_AGENT_MEANINGFUL
|
or TileSourcePolicy.FLAG_USER_AGENT_MEANINGFUL
|
||||||
or TileSourcePolicy.FLAG_USER_AGENT_NORMALIZED
|
or TileSourcePolicy.FLAG_USER_AGENT_NORMALIZED
|
||||||
|
),
|
||||||
|
"precipitation",
|
||||||
|
""
|
||||||
)
|
)
|
||||||
) {
|
|
||||||
//{layer}/{z}/{x}/{y}.png?appid={API key}
|
|
||||||
override fun getTileURLString(pMapTileIndex: Long): String {
|
|
||||||
return baseUrl + "precipitation/" + (MapTileIndex.getZoom(pMapTileIndex)
|
|
||||||
.toString() + "/" + MapTileIndex.getX(pMapTileIndex)
|
|
||||||
+ "/" + MapTileIndex.getY(pMapTileIndex)
|
|
||||||
+ mImageFilenameEnding + "?appid=")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//
|
//
|
||||||
// val RAIN_VIEWER = object : OnlineTileSourceBase(
|
// val RAIN_VIEWER = object : OnlineTileSourceBase(
|
||||||
// "RainViewer", 1, 15, 256, ".png", arrayOf(
|
// "RainViewer", 1, 15, 256, ".png", arrayOf(
|
||||||
|
@ -98,34 +91,6 @@ class CustomTileSource {
|
||||||
+ mImageFilenameEnding)
|
+ mImageFilenameEnding)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Transparent Background
|
|
||||||
//https://earthlive.maptiles.arcgis.com/arcgis/rest/services/GOES/GOES31D/MapServer/tile/
|
|
||||||
private val NOAA_RADAR = object : OnlineTileSourceBase(
|
|
||||||
"NOAA GOES Radar",
|
|
||||||
0,
|
|
||||||
18,
|
|
||||||
256,
|
|
||||||
"",
|
|
||||||
arrayOf(
|
|
||||||
"https://earthlive.maptiles.arcgis.com/arcgis/rest/services/GOES/GOES31D/MapServer/tile/"
|
|
||||||
),
|
|
||||||
"Dataset Citation: GOES-R Calibration Working Group and GOES-R Series Program, (2017): NOAA GOES-R Series Advanced Baseline Imager (ABI) Level 1b Radiances Band 13. NOAA National Centers for Environmental Information. doi:10.7289/V5BV7DSR",
|
|
||||||
TileSourcePolicy(
|
|
||||||
2,
|
|
||||||
TileSourcePolicy.FLAG_NO_BULK
|
|
||||||
or TileSourcePolicy.FLAG_NO_PREVENTIVE
|
|
||||||
or TileSourcePolicy.FLAG_USER_AGENT_MEANINGFUL
|
|
||||||
or TileSourcePolicy.FLAG_USER_AGENT_NORMALIZED
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
override fun getTileURLString(pMapTileIndex: Long): String {
|
|
||||||
return baseUrl + (MapTileIndex.getZoom(pMapTileIndex)
|
|
||||||
.toString() + "/" + MapTileIndex.getY(pMapTileIndex)
|
|
||||||
+ "/" + MapTileIndex.getX(pMapTileIndex)
|
|
||||||
+ mImageFilenameEnding)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private val USGS_HYDRO_CACHE = object : OnlineTileSourceBase(
|
private val USGS_HYDRO_CACHE = object : OnlineTileSourceBase(
|
||||||
"USGS Hydro Cache",
|
"USGS Hydro Cache",
|
||||||
0,
|
0,
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.content.res.Resources
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import org.osmdroid.api.IMapView
|
import org.osmdroid.api.IMapView
|
||||||
import org.osmdroid.tileprovider.tilesource.OnlineTileSourceBase
|
import org.osmdroid.tileprovider.tilesource.OnlineTileSourceBase
|
||||||
|
import org.osmdroid.tileprovider.tilesource.TileSourcePolicy
|
||||||
import org.osmdroid.util.MapTileIndex
|
import org.osmdroid.util.MapTileIndex
|
||||||
import kotlin.math.atan
|
import kotlin.math.atan
|
||||||
import kotlin.math.pow
|
import kotlin.math.pow
|
||||||
|
@ -18,7 +19,15 @@ open class NOAAWmsTileSource(
|
||||||
srs: String,
|
srs: String,
|
||||||
style: String?,
|
style: String?,
|
||||||
format: String,
|
format: String,
|
||||||
) : OnlineTileSourceBase(aName, 0, 9, 256, "png", aBaseUrl) {
|
) : OnlineTileSourceBase(
|
||||||
|
aName, 0, 5, 256, "png", aBaseUrl, "", TileSourcePolicy(
|
||||||
|
2,
|
||||||
|
TileSourcePolicy.FLAG_NO_BULK
|
||||||
|
or TileSourcePolicy.FLAG_NO_PREVENTIVE
|
||||||
|
or TileSourcePolicy.FLAG_USER_AGENT_MEANINGFUL
|
||||||
|
or TileSourcePolicy.FLAG_USER_AGENT_NORMALIZED
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
|
||||||
// array indexes for array to hold bounding boxes.
|
// array indexes for array to hold bounding boxes.
|
||||||
private val MINX = 0
|
private val MINX = 0
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.geeksville.mesh.model.map
|
||||||
|
|
||||||
|
import org.osmdroid.tileprovider.tilesource.OnlineTileSourceBase
|
||||||
|
import org.osmdroid.tileprovider.tilesource.TileSourcePolicy
|
||||||
|
import org.osmdroid.util.MapTileIndex
|
||||||
|
|
||||||
|
open class OnlineTileSourceAuth(
|
||||||
|
aName: String,
|
||||||
|
aZoomLevel: Int,
|
||||||
|
aZoomMaxLevel: Int,
|
||||||
|
aTileSizePixels: Int,
|
||||||
|
aImageFileNameEnding: String,
|
||||||
|
aBaseUrl: Array<String>,
|
||||||
|
pCopyright: String,
|
||||||
|
tileSourcePolicy: TileSourcePolicy,
|
||||||
|
layerName: String?,
|
||||||
|
apiKey: String
|
||||||
|
) :
|
||||||
|
OnlineTileSourceBase(
|
||||||
|
aName,
|
||||||
|
aZoomLevel,
|
||||||
|
aZoomMaxLevel,
|
||||||
|
aTileSizePixels,
|
||||||
|
aImageFileNameEnding,
|
||||||
|
aBaseUrl,
|
||||||
|
pCopyright,
|
||||||
|
tileSourcePolicy
|
||||||
|
|
||||||
|
) {
|
||||||
|
private var layerName = ""
|
||||||
|
private var apiKey = ""
|
||||||
|
|
||||||
|
init {
|
||||||
|
if (layerName != null) {
|
||||||
|
this.layerName = layerName
|
||||||
|
}
|
||||||
|
this.apiKey = apiKey
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getTileURLString(pMapTileIndex: Long): String {
|
||||||
|
return "$baseUrl$layerName/" + (MapTileIndex.getZoom(pMapTileIndex)
|
||||||
|
.toString() + "/" + MapTileIndex.getX(pMapTileIndex)
|
||||||
|
.toString() + "/" + MapTileIndex.getY(pMapTileIndex)
|
||||||
|
.toString()) + mImageFilenameEnding + "?appId=$apiKey"
|
||||||
|
}
|
||||||
|
}
|
|
@ -490,7 +490,7 @@ class MapFragment : ScreenFragment("Map"), Logging, View.OnClickListener {
|
||||||
val layer = TilesOverlay(
|
val layer = TilesOverlay(
|
||||||
MapTileProviderBasic(
|
MapTileProviderBasic(
|
||||||
activity,
|
activity,
|
||||||
CustomTileSource.NOAA_RADAR_WMS
|
CustomTileSource.OPENWEATHER_RADAR
|
||||||
), context
|
), context
|
||||||
)
|
)
|
||||||
layer.loadingBackgroundColor = Color.TRANSPARENT
|
layer.loadingBackgroundColor = Color.TRANSPARENT
|
||||||
|
|
Ładowanie…
Reference in New Issue