Working on overlays

pull/505/head
PWRxPSYCHO 2022-10-10 22:41:02 -04:00
rodzic 50cbc262f2
commit 2c08dd7cd0
3 zmienionych plików z 88 dodań i 27 usunięć

Wyświetl plik

@ -8,11 +8,51 @@ import org.osmdroid.util.MapTileIndex
class CustomTileSource {
companion object {
// Map Server information: https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer
//"https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/"
// Arcgis Information: https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9
//https://tile.openweathermap.org/map/{layer}/{z}/{x}/{y}.png?appid={API key}
companion object {
val OPENWEATHER_RADAR = object : OnlineTileSourceBase(
"Open Weather Map", 1, 15, 256, ".png", arrayOf(
"https://tile.openweathermap.org/map/"
), "Openweathermap",
TileSourcePolicy(
4,
TileSourcePolicy.FLAG_NO_BULK
or TileSourcePolicy.FLAG_NO_PREVENTIVE
or TileSourcePolicy.FLAG_USER_AGENT_MEANINGFUL
or TileSourcePolicy.FLAG_USER_AGENT_NORMALIZED
)
) {
//{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(
// "RainViewer", 1, 15, 256, ".png", arrayOf(
// "https://tilecache.rainviewer.com/v2/coverage/"
// ), "RainViewer",
// TileSourcePolicy(
// 4,
// 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 ESRI_IMAGERY = object : OnlineTileSourceBase(
"ESRI World Overview", 1, 20, 256, ".jpg", arrayOf(
"https://clarity.maptiles.arcgis.com/arcgis/rest/services/World_Imagery/MapServer/tile/"
@ -34,9 +74,15 @@ class CustomTileSource {
}
private val ESRI_WORLD_TOPO = object : OnlineTileSourceBase(
"ESRI World TOPO", 1, 20, 256, ".jpg", arrayOf(
"ESRI World TOPO",
1,
20,
256,
".jpg",
arrayOf(
"https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/"
), "Esri, HERE, Garmin, FAO, NOAA, USGS, © OpenStreetMap contributors, and the GIS User Community ",
),
"Esri, HERE, Garmin, FAO, NOAA, USGS, © OpenStreetMap contributors, and the GIS User Community ",
TileSourcePolicy(
4,
TileSourcePolicy.FLAG_NO_BULK
@ -62,7 +108,7 @@ class CustomTileSource {
256,
"",
arrayOf(
"https://earthlive.maptiles.arcgis.com/arcgis/rest/services/GOES/GOES31C/MapServer/tile/"
"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(
@ -137,18 +183,7 @@ class CustomTileSource {
"Recent Weather Radar",
arrayOf("https://new.nowcoast.noaa.gov/arcgis/services/nowcoast/radar_meteo_imagery_nexrad_time/MapServer/WmsServer?"),
"1",
"1.3.0",
"",
"EPSG%3A3857",
"",
"image/png"
)
val NOAA_SATELLITE_RADAR_WMS = NOAAWmsTileSource(
"Weather Satellite Imagery",
arrayOf("https://new.nowcoast.noaa.gov/arcgis/services/nowcoast/sat_meteo_imagery_time/MapServer/WmsServer?"),
"1,5,9,13,17,21,25",
"1.3.0",
"1.1.0",
"",
"EPSG%3A3857",
"",

Wyświetl plik

@ -15,10 +15,10 @@ open class NOAAWmsTileSource(
layername: String,
version: String,
time: String?,
crs: String,
srs: String,
style: String?,
format: String
) : OnlineTileSourceBase(aName, 0, 22, 256, "png", aBaseUrl) {
format: String,
) : OnlineTileSourceBase(aName, 0, 9, 256, "png", aBaseUrl) {
// array indexes for array to hold bounding boxes.
private val MINX = 0
@ -37,8 +37,7 @@ open class NOAAWmsTileSource(
private val MAP_SIZE = 20037508.34789244 * 2
private var layer = ""
private var version = "1.1.0"
private var crs = "EPSG:3A3857" //used by geo server
private var size = ""
private var srs = "EPSG%3A3857" //used by geo server
private var format = ""
private var time = ""
private var style: String? = null
@ -49,7 +48,7 @@ open class NOAAWmsTileSource(
Log.i(IMapView.LOGTAG, "WMS support is BETA. Please report any issues")
layer = layername
this.version = version
this.crs = crs
this.srs = srs
this.style = style
this.format = format
if (time != null) this.time = time
@ -128,7 +127,8 @@ open class NOAAWmsTileSource(
sb.append("&transparent=true")
sb.append("&height=").append(Resources.getSystem().displayMetrics.heightPixels)
sb.append("&width=").append(Resources.getSystem().displayMetrics.widthPixels)
sb.append("&crs=").append(crs)
sb.append("&srs=").append(srs)
sb.append("&size=").append(getSize())
sb.append("&bbox=")
val bbox = getBoundingBox(
MapTileIndex.getX(pMapTileIndex),
@ -139,8 +139,14 @@ open class NOAAWmsTileSource(
sb.append(bbox[MINY]).append(",")
sb.append(bbox[MAXX]).append(",")
sb.append(bbox[MAXY])
Log.i(IMapView.LOGTAG, sb.toString())
return sb.toString()
}
private fun getSize(): String {
val height = Resources.getSystem().displayMetrics.heightPixels
val width = Resources.getSystem().displayMetrics.widthPixels
return "$width,$height"
}
}

Wyświetl plik

@ -3,6 +3,7 @@ package com.geeksville.mesh.ui
import android.app.AlertDialog
import android.content.Context
import android.content.SharedPreferences
import android.content.res.Resources
import android.graphics.Canvas
import android.graphics.Color
import android.graphics.Paint
@ -22,6 +23,7 @@ import com.geeksville.mesh.databinding.MapViewBinding
import com.geeksville.mesh.model.UIViewModel
import com.geeksville.mesh.model.map.CustomOverlayManager
import com.geeksville.mesh.model.map.CustomTileSource
import com.geeksville.mesh.model.map.NOAAWmsTileSource
import com.geeksville.mesh.util.formatAgo
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.floatingactionbutton.FloatingActionButton
@ -31,6 +33,7 @@ import org.osmdroid.config.Configuration
import org.osmdroid.events.MapListener
import org.osmdroid.events.ScrollEvent
import org.osmdroid.events.ZoomEvent
import org.osmdroid.tileprovider.MapTileProviderBasic
import org.osmdroid.tileprovider.cachemanager.CacheManager
import org.osmdroid.tileprovider.cachemanager.CacheManager.CacheManagerCallback
import org.osmdroid.tileprovider.modules.SqlTileWriter
@ -46,6 +49,7 @@ import org.osmdroid.views.overlay.*
import org.osmdroid.views.overlay.gridlines.LatLonGridlineOverlay2
import java.io.File
import kotlin.math.pow
import android.util.DisplayMetrics
@AndroidEntryPoint
@ -377,6 +381,7 @@ class MapFragment : ScreenFragment("Map"), Logging, View.OnClickListener {
dialog.dismiss()
map.setTileSource(loadOnlineTileSourceBase())
renderDownloadButton()
drawOverlays()
}
val dialog = builder.create()
dialog.show()
@ -479,6 +484,21 @@ class MapFragment : ScreenFragment("Map"), Logging, View.OnClickListener {
createLatLongGrid(false)
map.overlayManager.addAll(nodeLayer, nodePositions)
map.overlayManager.addAll(nodeLayer, wayPoints)
if (map.tileProvider.tileSource.name()
.equals(CustomTileSource.getTileSource("ESRI World TOPO").name())
) {
val layer = TilesOverlay(
MapTileProviderBasic(
activity,
CustomTileSource.NOAA_RADAR_WMS
), context
)
layer.loadingBackgroundColor = Color.TRANSPARENT
layer.loadingLineColor = Color.TRANSPARENT
map.overlayManager.add(layer)
} else {
map.overlays.clear()
}
map.invalidate()
}