2022-12-30 13:18:02 -08:00
//
// A p p S e t t i n g s E n u m s . s w i f t
// M e s h t a s t i c
//
// C o p y r i g h t ( c ) G a r t h V a n d e r H o u w e n 1 2 / 3 0 / 2 2 .
//
import Foundation
2023-01-15 19:15:00 -08:00
import MapKit
2022-12-30 13:18:02 -08:00
2023-04-25 17:56:57 -07:00
enum MeshMapTypes : Int , CaseIterable , Identifiable {
2023-04-10 19:14:54 -07:00
2023-04-25 17:56:57 -07:00
case standard = 0
case mutedStandard = 5
case hybrid = 2
case hybridFlyover = 4
case satellite = 1
case satelliteFlyover = 3
2023-04-10 19:14:54 -07:00
2023-04-25 17:56:57 -07:00
var id : Int { self . rawValue }
2023-04-10 19:14:54 -07:00
2022-12-30 13:18:02 -08:00
var description : String {
2023-03-06 13:26:04 -08:00
switch self {
case . standard :
2023-05-05 09:27:24 -07:00
return " standard " . localized
2023-03-06 13:26:04 -08:00
case . mutedStandard :
2023-05-05 09:27:24 -07:00
return " standard.muted " . localized
2023-03-06 13:26:04 -08:00
case . hybrid :
2023-05-05 09:27:24 -07:00
return " hybrid " . localized
2023-03-06 13:26:04 -08:00
case . hybridFlyover :
2023-05-05 09:27:24 -07:00
return " hybrid.flyover " . localized
2023-03-06 13:26:04 -08:00
case . satellite :
2023-05-05 09:27:24 -07:00
return " satellite " . localized
2023-03-06 13:26:04 -08:00
case . satelliteFlyover :
2023-05-05 09:27:24 -07:00
return " satellite.flyover " . localized
2022-12-30 13:18:02 -08:00
}
}
2023-01-15 19:15:00 -08:00
func MKMapTypeValue ( ) -> MKMapType {
2023-04-10 19:14:54 -07:00
2023-01-15 19:15:00 -08:00
switch self {
case . standard :
return MKMapType . standard
case . mutedStandard :
return MKMapType . mutedStandard
case . hybrid :
return MKMapType . hybrid
case . hybridFlyover :
return MKMapType . hybridFlyover
case . satellite :
return MKMapType . satellite
case . satelliteFlyover :
return MKMapType . satelliteFlyover
}
}
2022-12-30 13:18:02 -08:00
}
2023-02-24 21:14:08 -08:00
enum UserTrackingModes : Int , CaseIterable , Identifiable {
2023-04-10 19:14:54 -07:00
2023-02-24 21:14:08 -08:00
case none = 0
case follow = 1
case followWithHeading = 2
2023-04-10 19:14:54 -07:00
2023-02-24 21:14:08 -08:00
var id : Int { self . rawValue }
2023-04-10 19:14:54 -07:00
2023-02-24 21:14:08 -08:00
var description : String {
2023-03-06 13:26:04 -08:00
switch self {
case . none :
2023-05-05 09:27:24 -07:00
return " map.usertrackingmode.none " . localized
2023-03-06 13:26:04 -08:00
case . follow :
2023-05-05 09:27:24 -07:00
return " map.usertrackingmode.follow " . localized
2023-03-06 13:26:04 -08:00
case . followWithHeading :
2023-05-05 09:27:24 -07:00
return " map.usertrackingmode.followwithheading " . localized
2023-02-24 21:14:08 -08:00
}
}
2023-04-23 22:38:02 -07:00
var icon : String {
switch self {
case . none : return " location "
case . follow : return " location.fill "
case . followWithHeading : return " location.north.line.fill "
}
}
2023-02-24 21:14:08 -08:00
func MKUserTrackingModeValue ( ) -> MKUserTrackingMode {
2023-04-10 19:14:54 -07:00
2023-02-24 21:14:08 -08:00
switch self {
case . none :
return MKUserTrackingMode . none
case . follow :
return MKUserTrackingMode . follow
case . followWithHeading :
return MKUserTrackingMode . followWithHeading
}
}
}
2022-12-30 13:18:02 -08:00
enum LocationUpdateInterval : Int , CaseIterable , Identifiable {
2023-04-10 19:14:54 -07:00
2022-12-30 13:18:02 -08:00
case fiveSeconds = 5
case tenSeconds = 10
case fifteenSeconds = 15
case thirtySeconds = 30
2023-05-05 09:27:24 -07:00
case fortyFiveSeconds = 45
2022-12-30 13:18:02 -08:00
case oneMinute = 60
case fiveMinutes = 300
case tenMinutes = 600
case fifteenMinutes = 900
2023-04-10 19:14:54 -07:00
2022-12-30 13:18:02 -08:00
var id : Int { self . rawValue }
var description : String {
2023-03-06 13:26:04 -08:00
switch self {
case . fiveSeconds :
2023-05-05 09:27:24 -07:00
return " interval.five.seconds " . localized
2023-03-06 13:26:04 -08:00
case . tenSeconds :
2023-05-05 09:27:24 -07:00
return " interval.ten.seconds " . localized
2023-03-06 13:26:04 -08:00
case . fifteenSeconds :
2023-05-05 09:27:24 -07:00
return " interval.fifteen.seconds " . localized
2023-03-06 13:26:04 -08:00
case . thirtySeconds :
2023-05-05 09:27:24 -07:00
return " interval.thirty.seconds " . localized
case . fortyFiveSeconds :
return " interval.fortyfive.seconds " . localized
2023-03-06 13:26:04 -08:00
case . oneMinute :
2023-05-05 09:27:24 -07:00
return " interval.one.minute " . localized
2023-03-06 13:26:04 -08:00
case . fiveMinutes :
2023-05-05 09:27:24 -07:00
return " interval.five.minutes " . localized
2023-03-06 13:26:04 -08:00
case . tenMinutes :
2023-05-05 09:27:24 -07:00
return " interval.ten.minutes " . localized
2023-03-06 13:26:04 -08:00
case . fifteenMinutes :
2023-05-05 09:27:24 -07:00
return " interval.fifteen.minutes " . localized
2022-12-30 13:18:02 -08:00
}
}
}
2023-05-06 16:15:12 -07:00
enum MapLayer : String , CaseIterable , Equatable {
case standard
case hybrid
case satellite
case offline
var localized : String { self . rawValue . localized }
}
2023-05-14 00:16:55 -07:00
enum MapTileServer : String , CaseIterable , Identifiable {
2023-04-10 19:14:54 -07:00
2023-05-09 19:31:25 -07:00
case openStreetMap
case openStreetMapDE
case openStreetMapFR
case openCycleMap
case openStreetMapHot
case openTopoMap
2023-05-08 07:35:31 -07:00
case usgsTopo
case usgsImageryTopo
case usgsImageryOnly
2023-05-10 13:44:27 -07:00
case terrain
2023-05-09 19:31:25 -07:00
case toner
2023-05-08 07:35:31 -07:00
case watercolor
var id : String { self . rawValue }
var attribution : String {
switch self {
2023-05-09 19:31:25 -07:00
case . openStreetMap :
return " Map and data © [OpenStreetMap](http://www.openstreetmap.org) and contributors, [CC-BY-SA](http://creativecommons.org/licenses/by-sa/2.0/) "
case . openStreetMapDE :
return " [OpenStreetMap DE](https://openstreetmap.de) map and data © [OpenStreetMap](http://www.openstreetmap.org) and contributors, [CC-BY-SA](http://creativecommons.org/licenses/by-sa/2.0/) "
case . openStreetMapFR :
return " [OpenStreetMap FR](https://www.openstreetmap.fr) map and data © [OpenStreetMap](http://www.openstreetmap.org) and contributors, [CC-BY-SA](http://creativecommons.org/licenses/by-sa/2.0/) "
case . openCycleMap :
return " [OpenCycleMap](https://www.cyclosm.org) map and data © [OpenStreetMap](http://www.openstreetmap.org) and contributors, [CC-BY-SA](http://creativecommons.org/licenses/by-sa/2.0/) "
case . openTopoMap :
return " [OpenTopoMap](https://opentopomap.org) map and data © [OpenStreetMap](http://www.openstreetmap.org) and contributors, [CC-BY-SA](http://creativecommons.org/licenses/by-sa/2.0/) "
case . openStreetMapHot :
return " [OpenStreetMap FR](https://www.openstreetmap.fr) map and data © [OpenStreetMap](http://www.openstreetmap.org) and contributors, [CC-BY-SA](http://creativecommons.org/licenses/by-sa/2.0/) "
2023-05-08 07:35:31 -07:00
case . usgsTopo :
2023-05-09 19:31:25 -07:00
return " [USGS](https://basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/MapServer) [National Map](http://nationalmap.gov/) topographic overlay. "
2023-05-08 07:35:31 -07:00
case . usgsImageryTopo :
2023-05-09 19:31:25 -07:00
return " [USGS](https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryTopo/MapServer) [National Map](http://nationalmap.gov/) imagery and topographic overlay. "
2023-05-08 07:35:31 -07:00
case . usgsImageryOnly :
2023-05-09 19:31:25 -07:00
return " [USGS](https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer) [National Map](http://nationalmap.gov/) imagery only overlay. "
2023-05-10 13:44:27 -07:00
case . terrain :
return " [Map Tiles](http://maps.stamen.com/#terrain/) by [Stamen Design](https://stamen.com), under [CC BY 3.0](https://creativecommons.org/licenses/by/3.0/). Data © [OpenStreetMap](http://www.openstreetmap.org) contributors under [CC-BY-SA](http://creativecommons.org/licenses/by-sa/2.0/). "
2023-05-09 19:31:25 -07:00
case . toner :
2023-05-10 13:44:27 -07:00
return " [Map Tiles](http://maps.stamen.com/#toner/) by [Stamen Design](https://stamen.com), under [CC BY 3.0](https://creativecommons.org/licenses/by/3.0/). Data © [OpenStreetMap](http://www.openstreetmap.org) contributors under [CC-BY-SA](http://creativecommons.org/licenses/by-sa/2.0/). "
2023-05-08 07:35:31 -07:00
case . watercolor :
2023-05-09 19:31:25 -07:00
return " Cooper Hewitt, Smithsonian Design Museum's [Watercolor Maptiles](https://watercolormaps.collection.cooperhewitt.org/) is a open-source mapping tool created by Stamen Design and built on [OpenStreetMap](http://www.openstreetmap.org) data. "
2023-05-08 07:35:31 -07:00
}
}
2023-04-27 18:01:23 -07:00
var description : String {
switch self {
2023-05-09 19:31:25 -07:00
case . openStreetMap :
return " Open Street Map "
case . openStreetMapDE :
return " Open Street Map DE "
case . openStreetMapFR :
return " Open Street Map FR "
case . openCycleMap :
return " Open Cycle Map "
case . openStreetMapHot :
return " Humanitarian (OSM) "
case . openTopoMap :
return " Open Topo Map "
2023-05-08 07:35:31 -07:00
case . usgsTopo :
return " USGS Topographic "
case . usgsImageryTopo :
return " USGS Topo Imagery "
case . usgsImageryOnly :
return " USGS Imagery Only "
2023-05-10 13:44:27 -07:00
case . terrain :
return " Terrain "
2023-05-09 19:31:25 -07:00
case . toner :
return " Toner "
2023-05-08 07:35:31 -07:00
case . watercolor :
return " Watercolor Maptiles "
2023-04-27 18:01:23 -07:00
}
}
2023-04-10 19:14:54 -07:00
var tileUrl : String {
switch self {
2023-05-09 19:31:25 -07:00
case . openStreetMap :
2023-04-10 19:14:54 -07:00
return " https://tile.openstreetmap.org/{z}/{x}/{y}.png "
2023-05-09 19:31:25 -07:00
case . openStreetMapDE :
return " https://tile.openstreetmap.de/{z}/{x}/{y}.png "
case . openStreetMapFR :
return " https://a.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png "
case . openCycleMap :
return " https://c.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png "
case . openStreetMapHot :
return " https://a.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png "
case . openTopoMap :
return " https://a.tile.opentopomap.org/{z}/{x}/{y}.png "
2023-05-08 07:35:31 -07:00
case . usgsTopo :
return " https://basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/MapServer/tile/{z}/{y}/{x} "
case . usgsImageryTopo :
return " https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryTopo/MapServer/tile/{z}/{y}/{x} "
case . usgsImageryOnly :
2023-04-10 19:14:54 -07:00
return " https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/tile/{z}/{y}/{x} "
2023-05-10 13:44:27 -07:00
case . terrain :
return " https://stamen-tiles-d.a.ssl.fastly.net/terrain/{z}/{x}/{y}.png "
2023-05-09 19:31:25 -07:00
case . toner :
return " https://stamen-tiles.a.ssl.fastly.net/toner/{z}/{x}/{y}.png "
2023-05-08 07:35:31 -07:00
case . watercolor :
return " https://watercolormaps.collection.cooperhewitt.org/tile/watercolor/{z}/{x}/{y}.jpg "
}
}
var zoomRange : [ Int ] {
switch self {
2023-05-09 19:31:25 -07:00
case . openStreetMap :
return [ Int ] ( 0. . . 18 )
case . openStreetMapDE :
return [ Int ] ( 0. . . 18 )
case . openStreetMapFR :
return [ Int ] ( 0. . . 18 )
case . openCycleMap :
return [ Int ] ( 0. . . 18 )
case . openTopoMap :
return [ Int ] ( 0. . . 18 )
case . openStreetMapHot :
return [ Int ] ( 0. . . 18 )
2023-05-08 07:35:31 -07:00
case . usgsTopo :
2023-05-13 20:50:20 -07:00
return [ Int ] ( 6. . . 16 )
2023-05-08 07:35:31 -07:00
case . usgsImageryTopo :
2023-05-13 20:50:20 -07:00
return [ Int ] ( 6. . . 16 )
2023-05-08 07:35:31 -07:00
case . usgsImageryOnly :
2023-05-13 20:50:20 -07:00
return [ Int ] ( 6. . . 16 )
2023-05-10 13:44:27 -07:00
case . terrain :
return [ Int ] ( 0. . . 15 )
2023-05-09 19:31:25 -07:00
case . toner :
return [ Int ] ( 0. . . 18 )
2023-05-08 07:35:31 -07:00
case . watercolor :
2023-05-09 19:31:25 -07:00
return [ Int ] ( 0. . . 18 )
2023-04-10 19:14:54 -07:00
}
}
}
2023-05-13 20:50:20 -07:00
2023-05-16 05:54:12 -07:00
enum OverlayType : String , CaseIterable , Equatable {
case tileServer
case geoJson
var localized : String { self . rawValue . localized }
}
2023-05-14 00:16:55 -07:00
enum MapOverlayServer : String , CaseIterable , Identifiable {
case baseReReflectivityCurrent
case baseReReflectivityOneHourAgo
case echoTopsEetCurrent
case echoTopsEetOneHourAgo
case q2OneHourPrecipitation
case q2TwentyFourHourPrecipitation
case q2FortyEightHourPrecipitation
case q2SeventyTwoHourPrecipitation
case mrmsHybridScanReflectivityComposite
var id : String { self . rawValue }
2023-05-16 05:54:12 -07:00
var overlayType : OverlayType {
switch self {
case . baseReReflectivityCurrent :
return . tileServer
case . baseReReflectivityOneHourAgo :
return . tileServer
case . echoTopsEetCurrent :
return . tileServer
case . echoTopsEetOneHourAgo :
return . tileServer
case . q2OneHourPrecipitation :
return . tileServer
case . q2TwentyFourHourPrecipitation :
return . tileServer
case . q2FortyEightHourPrecipitation :
return . tileServer
case . q2SeventyTwoHourPrecipitation :
return . tileServer
case . mrmsHybridScanReflectivityComposite :
return . tileServer
}
}
2023-05-14 00:16:55 -07:00
var attribution : String {
2023-05-14 00:19:42 -07:00
return " NEXRAD Weather tiles from Iowa State University Environmental Mesonet [OGC Web Services](https://mesonet.agron.iastate.edu/ogc/). "
2023-05-14 00:16:55 -07:00
}
var description : String {
switch self {
case . baseReReflectivityCurrent :
2023-05-14 00:19:42 -07:00
return " Base Reflectivity current "
2023-05-14 00:16:55 -07:00
case . baseReReflectivityOneHourAgo :
2023-05-14 00:19:42 -07:00
return " Base Reflectivity one hour ago "
2023-05-14 00:16:55 -07:00
case . echoTopsEetCurrent :
2023-05-14 00:19:42 -07:00
return " Echo Tops EET current "
2023-05-14 00:16:55 -07:00
case . echoTopsEetOneHourAgo :
2023-05-14 00:19:42 -07:00
return " Echo Tops EET one hour ago "
2023-05-14 00:16:55 -07:00
case . q2OneHourPrecipitation :
return " Q2 1 Hour Precipitation "
case . q2TwentyFourHourPrecipitation :
return " Q2 24 Hour Precipitation "
case . q2FortyEightHourPrecipitation :
return " Q2 48 Hour Precipitation "
case . q2SeventyTwoHourPrecipitation :
return " Q2 72 Hour Precipitation "
case . mrmsHybridScanReflectivityComposite :
return " MRMS Hybrid-Scan Reflectivity Composite "
}
}
var tileUrl : String {
switch self {
case . baseReReflectivityCurrent :
return " https://mesonet.agron.iastate.edu/cache/tile.py/1.0.0/nexrad-n0q-900913/{z}/{x}/{y} "
case . baseReReflectivityOneHourAgo :
return " https://mesonet.agron.iastate.edu/cache/tile.py/1.0.0/nexrad-n0q-900913-m55m/{z}/{x}/{y} "
case . echoTopsEetCurrent :
return " https://mesonet.agron.iastate.edu/cache/tile.py/1.0.0/nexrad-eet-900913/{z}/{x}/{y} "
case . echoTopsEetOneHourAgo :
return " https://mesonet.agron.iastate.edu/cache/tile.py/1.0.0/nexrad-eet-900913-m55m/{z}/{x}/{y} "
case . q2OneHourPrecipitation :
return " https://mesonet.agron.iastate.edu/cache/tile.py/1.0.0/q2-n1p-900913/{z}/{x}/{y} "
case . q2TwentyFourHourPrecipitation :
return " https://mesonet.agron.iastate.edu/cache/tile.py/1.0.0/q2-p24h-900913/{z}/{x}/{y} "
case . q2FortyEightHourPrecipitation :
return " https://mesonet.agron.iastate.edu/cache/tile.py/1.0.0/q2-p48h-900913/{z}/{x}/{y} "
case . q2SeventyTwoHourPrecipitation :
return " https://mesonet.agron.iastate.edu/cache/tile.py/1.0.0/q2-p72h-900913/{z}/{x}/{y} "
case . mrmsHybridScanReflectivityComposite :
return " https://mesonet.agron.iastate.edu/cache/tile.py/1.0.0/q2-hsr-900913/{z}/{x}/{y} "
}
}
var zoomRange : [ Int ] {
switch self {
case . baseReReflectivityCurrent :
return [ Int ] ( 0. . . 18 )
case . baseReReflectivityOneHourAgo :
return [ Int ] ( 0. . . 18 )
case . echoTopsEetCurrent :
return [ Int ] ( 0. . . 18 )
case . echoTopsEetOneHourAgo :
return [ Int ] ( 0. . . 18 )
case . q2OneHourPrecipitation :
return [ Int ] ( 0. . . 18 )
case . q2TwentyFourHourPrecipitation :
return [ Int ] ( 0. . . 18 )
case . q2FortyEightHourPrecipitation :
return [ Int ] ( 0. . . 18 )
case . q2SeventyTwoHourPrecipitation :
return [ Int ] ( 0. . . 18 )
case . mrmsHybridScanReflectivityComposite :
return [ Int ] ( 0. . . 18 )
}
}
}