2020-01-03 21:16:40 +01:00
// -*- mode: javascript; indent-tabs-mode: nil; c-basic-offset: 8 -*-
"use strict" ;
// Base layers configuration
// "url" : "https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png"
// "url" : "http://{a-c}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png"
// "url" : "http://{a-c}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png"
// "url" : "https://korona.geog.uni-heidelberg.de/tiles/roads/x={x}&y={y}&z={z}"
// "url" : "https://korona.geog.uni-heidelberg.de/tiles/asterh/x={x}&y={y}&z={z}"
// "url" : "https://{a-c}.tile.openstreetmap.de/tiles/osmde/{z}/{x}/{y}.png"
// "url" : "http://{a-c}.tilessputnik.ru/tiles/kmt2/{z}/{x}/{y}.png"
// "url" : "https://{a-c}.tile.openstreetmap.se/hydda/full/{z}/{x}/{y}.png"
// "url" : "https://{a-c}.tile.openstreetmap.se/osm/{z}/{x}/{y}.png"
function createBaseLayers ( ) {
2020-03-27 08:45:56 +01:00
let layers = new ol . Collection ( ) ;
let layers _group = new ol . layer . Group ( {
2020-01-03 21:16:40 +01:00
layers : layers ,
} ) ;
2020-03-27 08:45:56 +01:00
let world = new ol . Collection ( ) ;
let us = new ol . Collection ( ) ;
let europe = new ol . Collection ( ) ;
let custom = new ol . Collection ( ) ;
2020-01-03 21:16:40 +01:00
2020-02-08 20:32:04 +01:00
if ( localStorage [ 'customTiles' ] != undefined ) {
custom . push ( new ol . layer . Tile ( {
source : new ol . source . OSM ( {
"url" : localStorage [ 'customTiles' ] ,
} ) ,
name : 'custom_tiles' ,
title : 'Custom tiles' ,
type : 'base' ,
} ) ) ;
}
2020-02-08 19:38:42 +01:00
/ *
2020-01-03 21:16:40 +01:00
world . push ( new ol . layer . Tile ( {
source : new ol . source . OSM ( {
"url" : "https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png"
} ) ,
name : 'wikimedia' ,
title : 'OpenStreetMap Wikimedia' ,
type : 'base' ,
} ) ) ;
2020-02-08 19:38:42 +01:00
* /
2020-01-03 21:16:40 +01:00
world . push ( new ol . layer . Tile ( {
source : new ol . source . OSM ( ) ,
name : 'osm' ,
title : 'OpenStreetMap' ,
type : 'base' ,
} ) ) ;
2020-02-29 17:51:42 +01:00
world . push ( new ol . layer . Tile ( {
source : new ol . source . XYZ ( {
"url" : "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}" ,
"attributions" : "Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community" ,
} ) ,
name : 'esri' ,
title : 'ESRI Sat.' ,
type : 'base' ,
} ) ) ;
/ *
2020-01-03 21:16:40 +01:00
world . push ( new ol . layer . Tile ( {
source : new ol . source . OSM ( {
"url" : "http://{a-d}.tile.stamen.com/terrain/{z}/{x}/{y}.png" ,
"attributions" : 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. '
+ 'Data by <a _href="http://openstreetmap.org">OpenStreetMap</a>, under <a href="http://www.openstreetmap.org/copyright">ODbL</a>.' ,
} ) ,
name : 'terrain_roads' ,
title : 'Terrain + Roads' ,
type : 'base' ,
} ) ) ;
world . push ( new ol . layer . Tile ( {
source : new ol . source . OSM ( {
"url" : "http://{a-d}.tile.stamen.com/terrain-background/{z}/{x}/{y}.png" ,
"attributions" : 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, under <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. '
+ 'Data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under <a href="http://www.openstreetmap.org/copyright">ODbL</a>.' ,
} ) ,
name : 'terrain' ,
title : 'Terrain' ,
type : 'base' ,
} ) ) ;
2020-02-29 17:51:42 +01:00
* /
2020-01-03 21:16:40 +01:00
world . push ( new ol . layer . Tile ( {
source : new ol . source . OSM ( {
url : 'https://gibs-{a-c}.earthdata.nasa.gov/wmts/epsg3857/best/' +
'MODIS_Terra_CorrectedReflectance_TrueColor/default/2019-07-22/' +
'GoogleMapsCompatible_Level9/{z}/{y}/{x}.jpg' ,
} ) ,
2020-04-15 10:20:38 +02:00
name : 'gibs' ,
2020-01-03 21:16:40 +01:00
title : 'GIBS' ,
type : 'base' ,
} ) ) ;
// carto.com basemaps, see the following URLs for details on them:
// http://basemaps.cartocdn.com
// https://github.com/CartoDB/cartodb/wiki/BaseMaps-available
2020-03-27 08:45:56 +01:00
let basemaps = [ "dark_all" , "dark_nolabels" ,
2020-01-03 21:16:40 +01:00
"light_all" , "light_nolabels"
]
2020-03-27 08:45:56 +01:00
for ( let i in basemaps ) {
let basemap _id = basemaps [ i ] ;
2020-01-03 21:16:40 +01:00
world . push ( new ol . layer . Tile ( {
source : new ol . source . OSM ( {
2020-09-25 16:51:36 +02:00
"url" : "https://{a-d}.basemaps.cartocdn.com/" + basemap _id + "/{z}/{x}/{y}.png" ,
2020-01-03 21:16:40 +01:00
"attributions" : 'Courtesy of <a href="https://carto.com">CARTO.com</a>'
+ ' using data by <a href="http://openstreetmap.org">OpenStreetMap</a>, under <a href="http://www.openstreetmap.org/copyright">ODbL</a>.' ,
} ) ,
name : "carto_" + basemap _id ,
title : 'carto.com ' + basemap _id ,
type : 'base' ,
} ) ) ;
}
2020-05-07 21:48:32 +02:00
if ( localStorage [ 'bingKey' ] != undefined )
BingMapsAPIKey = localStorage [ 'bingKey' ] ;
2020-01-03 21:16:40 +01:00
if ( BingMapsAPIKey ) {
world . push ( new ol . layer . Tile ( {
source : new ol . source . BingMaps ( {
key : BingMapsAPIKey ,
imagerySet : 'Aerial'
} ) ,
name : 'bing_aerial' ,
title : 'Bing Aerial' ,
type : 'base' ,
} ) ) ;
world . push ( new ol . layer . Tile ( {
source : new ol . source . BingMaps ( {
key : BingMapsAPIKey ,
2020-08-19 08:15:53 +02:00
imagerySet : 'RoadOnDemand'
2020-01-03 21:16:40 +01:00
} ) ,
name : 'bing_roads' ,
title : 'Bing Roads' ,
type : 'base' ,
} ) ) ;
}
if ( ChartBundleLayers ) {
2020-03-27 08:45:56 +01:00
let chartbundleTypes = {
2020-01-03 21:16:40 +01:00
sec : "Sectional Charts" ,
2020-06-17 18:42:30 +02:00
enrh : "IFR Enroute High Charts"
} ;
for ( let type in chartbundleTypes ) {
us . push ( new ol . layer . Tile ( {
source : new ol . source . TileWMS ( {
url : 'https://map.adsbexchange.com/mapproxy/wms' ,
params : { LAYERS : type } ,
projection : 'EPSG:3857' ,
attributions : 'Tiles courtesy of <a href="http://www.chartbundle.com/">ChartBundle</a>'
} ) ,
name : 'chartbundle_' + type ,
title : chartbundleTypes [ type ] ,
type : 'base' ,
group : 'chartbundle' } ) ) ;
}
chartbundleTypes = {
2020-01-03 21:16:40 +01:00
tac : "Terminal Area Charts" ,
hel : "Helicopter Charts" ,
enrl : "IFR Enroute Low Charts" ,
enra : "IFR Area Charts" ,
2020-06-17 19:11:09 +02:00
secgrids : "Sect. w/ SAR grid" ,
2020-01-03 21:16:40 +01:00
} ;
2020-03-27 08:45:56 +01:00
for ( let type in chartbundleTypes ) {
2020-01-03 21:16:40 +01:00
us . push ( new ol . layer . Tile ( {
source : new ol . source . TileWMS ( {
2020-03-31 00:03:53 +02:00
url : 'https://wms.chartbundle.com/wms' ,
2020-01-03 21:16:40 +01:00
params : { LAYERS : type } ,
projection : 'EPSG:3857' ,
attributions : 'Tiles courtesy of <a href="http://www.chartbundle.com/">ChartBundle</a>'
} ) ,
name : 'chartbundle_' + type ,
title : chartbundleTypes [ type ] ,
type : 'base' ,
group : 'chartbundle' } ) ) ;
}
}
2020-01-07 00:59:49 +01:00
world . push ( new ol . layer . Tile ( {
source : new ol . source . OSM ( {
2020-06-10 13:59:16 +02:00
"url" : "https://map.adsbexchange.com/mapproxy/tiles/1.0.0/osm/osm_grid/{z}/{x}/{y}.png" ,
//'hosted by <a href="https://adsbexchange.com/">adsbexchange.com</a> '
"attributions" : '© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors.' ,
2020-01-07 00:59:49 +01:00
} ) ,
name : 'osm_adsbx' ,
title : 'OSM by ADSBx' ,
type : 'base' ,
} ) ) ;
2020-03-02 13:20:12 +01:00
world . push ( new ol . layer . Tile ( {
source : new ol . source . XYZ ( {
"url" : "https://map.adsbexchange.com/mapproxy/tiles/1.0.0/openaip/ul_grid/{z}/{x}/{y}.png" ,
"attributions" : "openAIP.net" ,
} ) ,
name : 'openaip' ,
title : 'openAIP TMS' ,
type : 'overlay' ,
opacity : 0.7 ,
visible : false ,
zIndex : 99 ,
2020-08-12 12:27:44 +02:00
maxZoom : 14 ,
2020-03-02 13:20:12 +01:00
} ) ) ;
2020-11-12 21:55:28 +01:00
if ( tfrs ) {
world . push ( new ol . layer . Vector ( {
source : new ol . source . Vector ( {
url : 'tfrs.kml' ,
format : new ol . format . KML ( ) ,
} ) ,
name : 'tfr' ,
title : 'TFRs' ,
type : 'overlay' ,
opacity : 0.7 ,
visible : true ,
zIndex : 99 ,
} ) ) ;
}
2020-11-12 20:09:36 +01:00
2020-03-27 08:45:56 +01:00
let nexrad = new ol . layer . Tile ( {
2020-01-03 21:16:40 +01:00
name : 'nexrad' ,
title : 'NEXRAD' ,
type : 'overlay' ,
2020-12-30 03:12:17 +01:00
opacity : 0.35 ,
2020-03-02 13:20:12 +01:00
visible : false ,
zIndex : 99 ,
2020-08-12 12:27:44 +02:00
maxZoom : 14 ,
2020-01-03 21:16:40 +01:00
} ) ;
2020-03-27 08:45:56 +01:00
let refreshNexrad = function ( ) {
2020-01-03 21:16:40 +01:00
// re-build the source to force a refresh of the nexrad tiles
2020-03-27 08:45:56 +01:00
let now = new Date ( ) . getTime ( ) ;
2020-01-03 21:16:40 +01:00
nexrad . setSource ( new ol . source . XYZ ( {
2020-03-31 00:03:53 +02:00
url : 'https://mesonet{1-3}.agron.iastate.edu/cache/tile.py/1.0.0/nexrad-n0q-900913/{z}/{x}/{y}.png?_=' + now ,
attributions : 'NEXRAD courtesy of <a href="https://mesonet.agron.iastate.edu/">IEM</a>'
2020-01-03 21:16:40 +01:00
} ) ) ;
} ;
refreshNexrad ( ) ;
2020-08-12 12:27:44 +02:00
window . setInterval ( refreshNexrad , 300 * 1000 ) ;
2020-01-23 20:45:54 +01:00
2020-12-30 03:12:17 +01:00
let noaaRadarSource = new ol . source . ImageWMS ( {
attributions : [ 'NOAA' ] ,
url : 'https://nowcoast.noaa.gov/arcgis/services/nowcoast/radar_meteo_imagery_nexrad_time/MapServer/WMSServer' ,
params : { 'LAYERS' : '1' } ,
projection : 'EPSG:3857' ,
} ) ;
let noaaRadar = new ol . layer . Image ( {
title : 'NOAA Radar' ,
zIndex : 99 ,
2020-12-31 12:26:40 +01:00
type : 'overlay' ,
visible : false ,
2020-12-30 03:12:17 +01:00
source : noaaRadarSource ,
opacity : 0.35 ,
} ) ;
2020-03-27 08:45:56 +01:00
let dwd ;
2020-01-23 20:45:54 +01:00
if ( enableDWD ) {
dwd = new ol . layer . Tile ( {
source : new ol . source . TileWMS ( {
url : 'https://maps.dwd.de/geoserver/wms' ,
params : { LAYERS : 'dwd:RX-Produkt' , validtime : ( new Date ( ) ) . getTime ( ) } ,
projection : 'EPSG:3857' ,
attributions : 'Deutscher Wetterdienst (DWD)'
} ) ,
name : 'radolan' ,
title : 'DWD RADOLAN' ,
type : 'overlay' ,
opacity : 0.3 ,
2020-03-02 13:20:12 +01:00
visible : false ,
zIndex : 99 ,
2020-08-12 12:27:44 +02:00
maxZoom : 14 ,
2020-01-23 20:45:54 +01:00
} ) ;
2020-03-27 08:45:56 +01:00
let refreshDwd = function ( ) {
2020-01-23 20:45:54 +01:00
dwd . getSource ( ) . updateParams ( { "validtime" : ( new Date ( ) ) . getTime ( ) } ) ;
} ;
refreshDwd ( ) ;
window . setInterval ( refreshDwd , 4 * 60000 ) ;
2020-03-02 13:20:12 +01:00
europe . push ( dwd ) ;
2020-01-23 20:45:54 +01:00
}
2020-03-02 13:20:12 +01:00
us . push ( nexrad ) ;
2020-12-30 03:12:17 +01:00
us . push ( noaaRadar ) ;
2020-03-02 13:20:12 +01:00
2020-03-27 08:45:56 +01:00
let createGeoJsonLayer = function ( title , name , url , fill , stroke , showLabel = true ) {
2020-03-01 23:12:41 +00:00
return new ol . layer . Vector ( {
type : 'overlay' ,
title : title ,
name : name ,
2020-03-02 13:20:12 +01:00
zIndex : 99 ,
visible : false ,
2020-03-01 23:12:41 +00:00
source : new ol . source . Vector ( {
url : url ,
format : new ol . format . GeoJSON ( {
defaultDataProjection : 'EPSG:4326' ,
projection : 'EPSG:3857'
} )
} ) ,
2020-03-02 23:13:36 +00:00
style : function style ( feature ) {
return new ol . style . Style ( {
2020-03-02 20:14:40 +01:00
fill : new ol . style . Fill ( {
2020-03-02 23:13:36 +00:00
color : fill
2020-03-02 20:14:40 +01:00
} ) ,
stroke : new ol . style . Stroke ( {
2020-03-02 23:13:36 +00:00
color : stroke ,
width : 1
} ) ,
text : new ol . style . Text ( {
2020-03-09 23:31:04 +01:00
text : showLabel ? feature . get ( "name" ) : "" ,
2020-03-02 23:13:36 +00:00
overflow : OLMap . getView ( ) . getZoom ( ) > 5 ,
scale : 1.25 ,
fill : new ol . style . Fill ( {
color : '#000000'
} ) ,
stroke : new ol . style . Stroke ( {
color : '#FFFFFF' ,
width : 2
} )
2020-03-02 20:14:40 +01:00
} )
2020-03-02 23:13:36 +00:00
} ) ;
}
2020-03-01 23:12:41 +00:00
} ) ;
2020-03-02 20:14:40 +01:00
} ;
2020-01-03 21:16:40 +01:00
2020-03-01 23:12:41 +00:00
// Taken from https://github.com/alkissack/Dump1090-OpenLayers3-html
2020-03-02 13:20:12 +01:00
europe . push ( createGeoJsonLayer ( 'UK Radar Corridors' , 'ukradarcorridors' , 'geojson/UK_Mil_RC.geojson' , 'rgba(22, 171, 22, 0.3)' , 'rgba(22, 171, 22, 1)' ) ) ;
2020-06-18 08:12:10 +02:00
europe . push ( createGeoJsonLayer ( 'UK A2A Refueling' , 'uka2arefueling' , 'geojson/UK_Mil_AAR_Zones.geojson' , 'rgba(52, 50, 168, 0.3)' , 'rgba(52, 50, 168, 1)' ) ) ;
2020-03-09 23:31:04 +01:00
europe . push ( createGeoJsonLayer ( 'UK AWACS Orbits' , 'uka2awacsorbits' , 'geojson/UK_Mil_AWACS_Orbits.geojson' , 'rgba(252, 186, 3, 0.3)' , 'rgba(252, 186, 3, 1)' , false ) ) ;
2020-03-09 22:21:00 +01:00
2020-03-12 17:46:13 +01:00
us . push ( createGeoJsonLayer ( 'US A2A Refueling' , 'usa2arefueling' , 'geojson/US_A2A_refueling.geojson' , 'rgba(52, 50, 168, 0.3)' , 'rgba(52, 50, 168, 1)' ) ) ;
2020-01-03 21:16:40 +01:00
2020-05-23 16:37:47 -04:00
us . push ( createGeoJsonLayer ( 'US ARTCC Boundaries' , 'usartccboundaries' , 'geojson/US_ARTCC_boundaries.geojson' , 'rgba(255, 0, 255, 0.3)' , 'rgba(255, 0, 255, 1)' , false ) ) ;
2020-05-08 21:55:20 +02:00
if ( l3harris ) {
let c = 1 ;
2020-07-27 23:05:29 +02:00
/ *
2020-05-08 21:55:20 +02:00
us . push ( createGeoJsonLayer ( 'L3 Area Labels Brown' , 'harris' + c ++ , 'geojson/L3Harris/Area_Labels_Brown.geojson' , 'rgba(52, 50, 168, 0.3)' , 'rgba(52, 50, 168, 1)' ) ) ;
us . push ( createGeoJsonLayer ( 'L3 Area Labels Green' , 'harris' + c ++ , 'geojson/L3Harris/Area_Labels_Green.geojson' , 'rgba(52, 50, 168, 0.3)' , 'rgba(52, 50, 168, 1)' ) ) ;
us . push ( createGeoJsonLayer ( 'L3 Den App GPS' , 'harris' + c ++ , 'geojson/L3Harris/Den_Apch_Inbound_Call_Points_GPS.geojson' , 'rgba(52, 50, 168, 0.3)' , 'rgba(52, 50, 168, 1)' ) ) ;
us . push ( createGeoJsonLayer ( 'L3 Den App Visual' , 'harris' + c ++ , 'geojson/L3Harris/Den_Apch_Inbound_Call_Points_Visual.geojson' , 'rgba(52, 50, 168, 0.3)' , 'rgba(52, 50, 168, 1)' ) ) ;
us . push ( createGeoJsonLayer ( 'L3 Harris' , 'harris' + c ++ , 'geojson/L3Harris/L3Harris.geojson' , 'rgba(52, 50, 168, 0.3)' , 'rgba(52, 50, 168, 1)' ) ) ;
us . push ( createGeoJsonLayer ( 'L3 Pueblo Inbound' , 'harris' + c ++ , 'geojson/L3Harris/Pueblo_Tower_Inbound_Call_Points_Visual.geojson' , 'rgba(52, 50, 168, 0.3)' , 'rgba(52, 50, 168, 1)' ) ) ;
us . push ( createGeoJsonLayer ( 'L3 Routes' , 'harris' + c ++ , 'geojson/L3Harris/Route_Name_Labels.geojson' , 'rgba(52, 50, 168, 0.3)' , 'rgba(52, 50, 168, 1)' ) ) ;
2020-07-27 23:05:29 +02:00
* /
us . push ( createGeoJsonLayer ( 'L3 Training Areas' , 'harris' + c ++ , 'geojson/L3Harris/L3Harris_Training_Areas.geojson' , 'rgba(52, 50, 168, 0.3)' , 'rgba(52, 50, 168, 1)' ) ) ;
us . push ( createGeoJsonLayer ( 'L3 USAFA Training' , 'harris' + c ++ , 'geojson/L3Harris/USAFA_Training_Areas.geojson' , 'rgba(52, 50, 168, 0.3)' , 'rgba(52, 50, 168, 1)' ) ) ;
us . push ( createGeoJsonLayer ( 'L3 VNAV' , 'harris' + c ++ , 'geojson/L3Harris/L3Harris_VNAV.geojson' , 'rgba(52, 50, 168, 0.3)' , 'rgba(52, 50, 168, 1)' ) ) ;
2020-05-08 21:55:20 +02:00
}
2020-02-08 20:32:04 +01:00
if ( custom . getLength ( ) > 0 ) {
layers . push ( new ol . layer . Group ( {
name : 'custom' ,
title : 'Custom' ,
2020-03-02 13:20:12 +01:00
layers : new ol . Collection ( custom . getArray ( ) . reverse ( ) ) ,
} ) ) ;
}
if ( europe . getLength ( ) > 0 ) {
layers . push ( new ol . layer . Group ( {
name : 'europe' ,
title : 'Europe' ,
layers : new ol . Collection ( europe . getArray ( ) . reverse ( ) ) ,
//fold: 'close',
2020-02-08 20:32:04 +01:00
} ) ) ;
}
2020-01-03 21:16:40 +01:00
if ( us . getLength ( ) > 0 ) {
layers . push ( new ol . layer . Group ( {
name : 'us' ,
title : 'US' ,
2020-03-02 13:20:12 +01:00
layers : new ol . Collection ( us . getArray ( ) . reverse ( ) ) ,
//fold: 'close',
2020-01-03 21:16:40 +01:00
} ) ) ;
}
2020-01-23 20:45:54 +01:00
2020-01-03 21:16:40 +01:00
if ( world . getLength ( ) > 0 ) {
layers . push ( new ol . layer . Group ( {
name : 'world' ,
title : 'Worldwide' ,
2020-03-02 13:20:12 +01:00
layers : new ol . Collection ( world . getArray ( ) . reverse ( ) ) ,
//fold: 'open',
2020-03-01 23:12:41 +00:00
} ) ) ;
}
2020-02-29 17:51:42 +01:00
2020-01-23 20:45:54 +01:00
2020-01-03 21:16:40 +01:00
return layers _group ;
}