├── .gitignore ├── Airports ├── Airports-APIKey │ ├── client │ │ ├── index.html │ │ ├── map.js │ │ └── style.css │ ├── package-lock.json │ ├── package.json │ └── server.js └── Airports-OAuth │ ├── client │ ├── index.html │ ├── map.js │ └── style.css │ ├── package-lock.json │ ├── package.json │ └── server.js ├── LICENSE ├── OSFeaturesAPI ├── index.html ├── js │ └── query.js └── style.css ├── OSLinkedIdentifiersAPI ├── img │ └── expand.png ├── index.html ├── js │ └── query.js └── style.css ├── OSMapsAPI ├── ArcGIS │ ├── index.html │ └── map.js ├── Leaflet │ ├── Proj4Leaflet │ │ ├── LICENSE │ │ └── proj4leaflet.js │ ├── index.html │ └── map.js ├── OpenLayers │ ├── index.html │ └── map.js └── style.css ├── OSVectorTileAPI ├── ArcGIS │ ├── index.html │ └── map.js ├── Leaflet │ ├── index.html │ └── map.js ├── MapboxGLJS │ ├── index.html │ └── map.js ├── OpenLayers │ ├── index.html │ ├── map.js │ └── ol-mapbox-style │ │ ├── LICENSE │ │ └── olms.js ├── StylingVTS │ ├── Adapting │ │ ├── README.md │ │ ├── index.html │ │ └── map.js │ ├── InCode │ │ ├── README.md │ │ ├── index.html │ │ └── map.js │ └── README.md └── style.css └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.iml 3 | **/node_modules 4 | *.idea 5 | -------------------------------------------------------------------------------- /Airports/Airports-APIKey/client/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Airports Demo 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 |
21 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Airports/Airports-APIKey/client/map.js: -------------------------------------------------------------------------------- 1 | // 2 | // Setup the EPSG:27700 (British National Grid) projection 3 | // 4 | proj4.defs("EPSG:27700", "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.999601 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894 +datum=OSGB36 +units=m +no_defs"); 5 | ol.proj.proj4.register(proj4); 6 | var bng = ol.proj.get('EPSG:27700'); 7 | bng.setExtent([-238375.0,0,700000,1300000]); 8 | 9 | // 10 | // Find the elements we use to display messages and feature details to the user 11 | // 12 | var message = document.getElementById('message'); 13 | var details = document.getElementById('details'); 14 | var attributes = document.getElementById('attributes'); 15 | const messageText = ' Check your network connection, or try restarting the server with another API key.'; 16 | 17 | // 18 | // Get the WMTS capabilities doc from the server, so that we can set up the mapping layer 19 | // 20 | var select; 21 | var url = '/proxy/maps/raster/v1/wmts?request=GetCapabilities&service=WMTS'; 22 | fetch(url) 23 | .then(response => response.text()) 24 | .then(text => { 25 | var parser = new ol.format.WMTSCapabilities(); 26 | var result = parser.read(text); 27 | var options = ol.source.WMTS.optionsFromCapabilities(result, { 28 | layer: 'Light_27700' 29 | }); 30 | 31 | var tileSource = new ol.source.WMTS({ 32 | attributions: '© Ordnance Survey', 33 | ...options 34 | }); 35 | var tileLayer = new ol.layer.Tile({ source: tileSource }); 36 | 37 | tileSource.on('tileloaderror', function(event) { 38 | message.classList.add('warning'); 39 | message.textContent = 'Could not load a map tile. You may be attempting to access Premium data with an API key that only has access to OS OpenData.' + messageText; 40 | }); 41 | 42 | var vectorSource = new ol.source.Vector({ 43 | format: new ol.format.GeoJSON({ 44 | dataProjection: 'EPSG:27700' 45 | }), 46 | url: getURLForExtent, 47 | strategy: ol.loadingstrategy.bbox 48 | }); 49 | 50 | var vectorLayer = new ol.layer.Vector({ 51 | source: vectorSource 52 | }); 53 | 54 | select = new ol.interaction.Select(); 55 | select.on('select', featureSelected); 56 | 57 | var map = new ol.Map({ 58 | target: 'map', 59 | layers: [tileLayer, vectorLayer], 60 | view: new ol.View({ 61 | projection: 'EPSG:27700', 62 | center: [512217, 221078], 63 | zoom: 5, 64 | minResolution: 0.109375 65 | }) 66 | }); 67 | map.getControls().forEach(control => { 68 | if(control instanceof ol.control.Attribution) { 69 | control.setCollapsed(false); 70 | } 71 | }); 72 | map.addInteraction(select); 73 | }) 74 | .catch(error => { 75 | message.classList.add('warning'); 76 | message.textContent = 'Got an error setting up the map!' + messageText; 77 | console.log(error); 78 | }); 79 | 80 | // 81 | // This function returns a URL that does a WFS feature query for the given extent. We filter the results to 82 | // look up Airports from the Zoomstack collection. 83 | // 84 | function getURLForExtent(extent) { 85 | const wfsParameters = { 86 | service: 'WFS', 87 | version: '2.0.0', 88 | request: 'GetFeature', 89 | typeNames: 'Zoomstack_Airports', 90 | outputFormat: 'GEOJSON', 91 | srsName: 'urn:ogc:def:crs:EPSG::27700', 92 | filter: 93 | ` 94 | 95 | Shape 96 | 97 | ${extent[1]} ${extent[0]} 98 | ${extent[3]} ${extent[2]} 99 | 100 | 101 | ` 102 | }; 103 | const urlParameters = Object.keys(wfsParameters) 104 | .map(param => param + '=' + encodeURI(wfsParameters[param])) 105 | .join('&'); 106 | 107 | return '/proxy/features/v1/wfs?' + urlParameters; 108 | } 109 | 110 | // 111 | // When the user clicks on a feature on the map, we display information about the selected feature in a table 112 | // 113 | function featureSelected(event) { 114 | if(event.selected.length === 0) { 115 | details.classList.add('hidden'); 116 | attributes.innerText = ''; 117 | } else { 118 | details.classList.remove('hidden'); 119 | const feature = event.selected[0]; 120 | let table = ''; 121 | feature.getKeys().forEach(key => { 122 | const value = feature.get(key); 123 | if(typeof value === 'string') { 124 | table += ''; 125 | } 126 | }); 127 | table += '
PropertyValue
' + key + '' + value + '
'; 128 | attributes.innerHTML = table; 129 | } 130 | } 131 | 132 | // 133 | // When the user clicks close we need to clear the current selection 134 | // 135 | function closeModal() { 136 | select.getFeatures().clear(); 137 | details.classList.add('hidden'); 138 | } 139 | -------------------------------------------------------------------------------- /Airports/Airports-APIKey/client/style.css: -------------------------------------------------------------------------------- 1 | /* Set the document to use flexbox layout */ 2 | body { 3 | margin: 0; 4 | height: 100vh; 5 | display: flex; 6 | flex-direction: column; 7 | } 8 | /* ensure the map fills as much of the screen as possible */ 9 | #map { 10 | flex: 1 1 auto; 11 | } 12 | 13 | #details { 14 | border-top: 6px solid #453c90; 15 | background-color: white; 16 | position: absolute; 17 | top: 50%; 18 | left: 50%; 19 | transform: translate(-50%, -50%); 20 | padding: 60px 40px 20px 40px; 21 | } 22 | 23 | table, tr, th, td { 24 | text-align: left; 25 | border-collapse: collapse; 26 | border: none; 27 | } 28 | 29 | /* 30 | NOTE: 31 | The CSS following this comment is for *styling purposes only* and is not essential for this demo to run 32 | - strip out the styles below if you want cleaner code 33 | */ 34 | 35 | body { 36 | font-family: "Source Sans Pro", sans-serif; 37 | font-size:16px; 38 | color: #666666; 39 | min-width: 480px; 40 | } 41 | 42 | 43 | h1{ 44 | margin: 0 0 10px 0; 45 | font-size: 32px; 46 | font-weight: normal; 47 | line-height: 1.4; 48 | letter-spacing: 0.7px; 49 | color: #453c90; 50 | } 51 | 52 | h2{ 53 | margin: 0 0 10px 0; 54 | font-size: 32px; 55 | font-weight: normal; 56 | line-height: 1.4; 57 | letter-spacing: 0.7px; 58 | } 59 | 60 | table { 61 | margin: 20px 0; 62 | } 63 | 64 | th { 65 | color: #453c90; 66 | background-color: white; 67 | border-bottom: 2px solid #453c90; 68 | } 69 | 70 | tr { 71 | color: #333333; 72 | } 73 | 74 | tr:nth-child(odd) { 75 | background-color: #f6f5f9; 76 | } 77 | 78 | tr { 79 | border-bottom: 1px solid #dddddd; 80 | } 81 | 82 | p{ 83 | margin: 10px 0; 84 | } 85 | 86 | b{ 87 | font-weight:600; 88 | } 89 | 90 | #header{ 91 | text-align: center; 92 | background-color: #ffffff; 93 | padding: 20px; 94 | border-bottom: 1px solid #dddddd; 95 | box-shadow: 0 2px 4px 1px rgba(0, 0, 0, 0.4); 96 | z-index:1000 97 | } 98 | 99 | .hidden{ 100 | display: none; 101 | } 102 | .warning{ 103 | color:#d40058; 104 | font-weight:400; 105 | } 106 | .close { 107 | border: none; 108 | font-size: 18px; 109 | position: absolute; 110 | top: 12px; 111 | right: 12px; 112 | } 113 | .close:hover { 114 | background-color: #f5f5f5; 115 | } 116 | 117 | form{ 118 | margin-top: 20px; 119 | text-align: left; 120 | } -------------------------------------------------------------------------------- /Airports/Airports-APIKey/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "omse-airport-demo", 3 | "version": "1.0.0", 4 | "description": "An application demonstrating combined use of the OS Maps API and OS Features API", 5 | "main": "server.js", 6 | "dependencies": { 7 | "express": "^4.19.2", 8 | "express-http-proxy": "^1.6.3", 9 | "path": "^0.12.7" 10 | }, 11 | "devDependencies": { 12 | "nodemon": "^2.0.20" 13 | }, 14 | "scripts": { 15 | "test": "echo \"Error: no test specified\" && exit 1", 16 | "dev": "nodemon --inspect server.js" 17 | }, 18 | "repository": { 19 | "type": "git", 20 | "url": "git+https://github.com/OrdnanceSurvey/OS-Data-Hub-API-Demos.git" 21 | }, 22 | "license": "Apache-2.0", 23 | "bugs": { 24 | "url": "https://github.com/OrdnanceSurvey/OS-Data-Hub-API-Demos/issues" 25 | }, 26 | "homepage": "https://github.com/OrdnanceSurvey/OS-Data-Hub-API-Demos#readme" 27 | } 28 | -------------------------------------------------------------------------------- /Airports/Airports-APIKey/server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const path = require('path'); 3 | const proxy = require('express-http-proxy'); 4 | 5 | // Read the application API key from the command line. 6 | const key = process.argv[2]; 7 | if(!key) { 8 | throw Error('Please provide an API key on the command line.\nUsage: server.js '); 9 | } 10 | console.log('Using API key: ' + key); 11 | 12 | // Setup the regular expression that we use to replace the server URL in the HTTP responses. 13 | const osDataHubAPIExpression = /https:\/\/api\.os\.uk/g; 14 | 15 | // Setup an express server. 16 | // This server serves the client files to the browser, and routes all '/proxy' requests onto the proxy router. 17 | const app = express(); 18 | app.use(express.static(path.join(__dirname, 'client'))); 19 | 20 | // Set up a proxy for the OS Data Hub API calls. Its main role is to add the API key header on to each request. 21 | app.use('/proxy', proxy('https://api.os.uk', { 22 | proxyReqOptDecorator: function(proxyReqOpts) { 23 | proxyReqOpts.headers.key = key; 24 | return proxyReqOpts; 25 | }, 26 | // We need to intercept and re-write text responses, as we need to re-route urls back through this proxy. 27 | userResDecorator: function (proxyRes, proxyResData, userReq) { 28 | const contentType = proxyRes.headers['content-type']; 29 | if(contentType !== 'image/png') { 30 | let body = proxyResData.toString('utf8'); 31 | body = body.replace(osDataHubAPIExpression, 'http://' + userReq.headers.host + '/proxy'); 32 | return body; 33 | } else { 34 | return proxyResData; 35 | } 36 | } 37 | })); 38 | 39 | app.listen(8080, () => console.log("Listening on port 8080. Please open http://localhost:8080 in a web browser.")); 40 | -------------------------------------------------------------------------------- /Airports/Airports-OAuth/client/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Airports Demo 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 |
21 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Airports/Airports-OAuth/client/map.js: -------------------------------------------------------------------------------- 1 | 2 | // The URL for the OS Data Hub APIs 3 | const dataHubApi = 'https://api.os.uk/'; 4 | 5 | // 6 | // Setup the EPSG:27700 (British National Grid) projection 7 | // 8 | proj4.defs("EPSG:27700", "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.999601 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894 +datum=OSGB36 +units=m +no_defs"); 9 | ol.proj.proj4.register(proj4); 10 | var bng = ol.proj.get('EPSG:27700'); 11 | bng.setExtent([-238375.0,0,700000,1300000]); 12 | 13 | // 14 | // Find the elements we use to display messages and feature details to the user 15 | // 16 | var message = document.getElementById('message'); 17 | var details = document.getElementById('details'); 18 | var attributes = document.getElementById('attributes'); 19 | const messageText = ' Check your network connection, or try restarting the server with another API key and secret.'; 20 | 21 | // Setup a select interaction. This allows users to click on features and see the feature attributes 22 | const select = new ol.interaction.Select(); 23 | select.on('select', featureSelected); 24 | 25 | // 26 | // Get an access token for the OS Data Hub APIs, and keep the token fresh 27 | // 28 | let currentToken; 29 | function getToken() { 30 | return fetch('/token') 31 | .then(response => response.json()) 32 | .then(result => { 33 | if(result.access_token) { 34 | // Store this token 35 | currentToken = result.access_token; 36 | 37 | // Get a new token 30 seconds before this one expires 38 | const timeoutMS = (result.expires_in - 30) * 1000; 39 | setTimeout(getToken, timeoutMS); 40 | } else { 41 | // We failed to get the token 42 | return Promise.reject(); 43 | } 44 | }) 45 | .catch(error => { 46 | message.classList.add('warning'); 47 | message.textContent = 'Got an error loading access token!' + messageText; 48 | return Promise.reject(); 49 | }); 50 | } 51 | 52 | getToken().then(() => { 53 | // 54 | // Get the WMTS capabilities doc from the server, so that we can set up the mapping layer 55 | // 56 | var url = dataHubApi + 'maps/raster/v1/wmts?request=GetCapabilities&service=WMTS'; 57 | fetch(url, { 58 | headers: { 59 | Authorization: 'Bearer ' + currentToken 60 | } 61 | }) 62 | .then(response => response.text()) 63 | .then(text => { 64 | var parser = new ol.format.WMTSCapabilities(); 65 | var result = parser.read(text); 66 | var options = ol.source.WMTS.optionsFromCapabilities(result, { 67 | layer: 'Light_27700' 68 | }); 69 | 70 | var tileSource = new ol.source.WMTS({ 71 | attributions: '© Ordnance Survey', 72 | tileLoadFunction: (tile, src) => { 73 | fetch(src, { 74 | headers: { 75 | Authorization: 'Bearer ' + currentToken 76 | } 77 | }) 78 | .then(response => { 79 | if(response.ok) { 80 | return response 81 | } 82 | return Reject(response); 83 | }) 84 | .then(response => response.blob()) 85 | .then(blob => { 86 | // We have loaded the image data from the WMTS service. We convert it into a base64 image 87 | // that we can set onto the OpenLayers tile. 88 | const reader = new FileReader(); 89 | reader.onloadend = () => { 90 | var data = 'data:image/png;base64,' + btoa(reader.result); 91 | tile.getImage().src = data; 92 | }; 93 | reader.readAsBinaryString(blob); 94 | }) 95 | .catch(error => { 96 | message.classList.add('warning'); 97 | message.textContent = 'Could not load a map tile. You may be attempting to access Premium data with an API key that only has access to OS OpenData.' + messageText; 98 | }); 99 | }, 100 | ...options 101 | }); 102 | var tileLayer = new ol.layer.Tile({ source: tileSource }); 103 | 104 | var vectorSource = new ol.source.Vector({ 105 | format: new ol.format.GeoJSON({ 106 | dataProjection: 'EPSG:27700' 107 | }), 108 | strategy: ol.loadingstrategy.bbox, 109 | loader: (extent) => { 110 | fetch(getURLForExtent(extent), { 111 | headers: { 112 | Authorization: 'Bearer ' + currentToken 113 | } 114 | }) 115 | .then(response => response.text()) 116 | .then(geojson => { 117 | // We have loaded GeoJSON features from the WFS service. We convert them into OpenLayers 118 | // features and set them onto the layer source. 119 | const features = vectorSource.getFormat().readFeatures(geojson); 120 | vectorSource.addFeatures(features); 121 | }) 122 | .catch(error => { 123 | message.classList.add('warning'); 124 | message.textContent = 'Got an error loading features!' + messageText; 125 | }); 126 | } 127 | }); 128 | 129 | var vectorLayer = new ol.layer.Vector({ 130 | source: vectorSource 131 | }); 132 | 133 | var map = new ol.Map({ 134 | target: 'map', 135 | layers: [tileLayer, vectorLayer], 136 | view: new ol.View({ 137 | projection: 'EPSG:27700', 138 | center: [512217, 221078], 139 | zoom: 5, 140 | minResolution: 0.109375 141 | }) 142 | }); 143 | map.getControls().forEach(control => { 144 | if(control instanceof ol.control.Attribution) { 145 | control.setCollapsed(false); 146 | } 147 | }); 148 | map.addInteraction(select); 149 | }) 150 | .catch(error => { 151 | message.classList.add('warning'); 152 | message.textContent = 'Got an error setting up the map!' + messageText; 153 | console.log(error); 154 | }); 155 | }); 156 | 157 | // 158 | // This function returns a URL that does a WFS feature query for the given extent. We filter the results to 159 | // look up Airports from the Zoomstack collection. 160 | // 161 | function getURLForExtent(extent) { 162 | const wfsParameters = { 163 | service: 'WFS', 164 | version: '2.0.0', 165 | request: 'GetFeature', 166 | typeNames: 'Zoomstack_Airports', 167 | outputFormat: 'GEOJSON', 168 | srsName: 'urn:ogc:def:crs:EPSG::27700', 169 | filter: 170 | ` 171 | 172 | Shape 173 | 174 | ${extent[1]} ${extent[0]} 175 | ${extent[3]} ${extent[2]} 176 | 177 | 178 | ` 179 | }; 180 | const urlParameters = Object.keys(wfsParameters) 181 | .map(param => param + '=' + encodeURI(wfsParameters[param])) 182 | .join('&'); 183 | 184 | return dataHubApi + 'features/v1/wfs?' + urlParameters; 185 | } 186 | 187 | // 188 | // When the user clicks on a feature on the map, we display information about the selected feature in a table 189 | // 190 | function featureSelected(event) { 191 | if(event.selected.length === 0) { 192 | details.classList.add('hidden'); 193 | attributes.innerText = ''; 194 | } else { 195 | details.classList.remove('hidden'); 196 | const feature = event.selected[0]; 197 | let table = ''; 198 | feature.getKeys().forEach(key => { 199 | const value = feature.get(key); 200 | if(typeof value === 'string') { 201 | table += ''; 202 | } 203 | }); 204 | table += '
PropertyValue
' + key + '' + value + '
'; 205 | attributes.innerHTML = table; 206 | } 207 | } 208 | 209 | // 210 | // When the user clicks close we need to clear the current selection 211 | // 212 | function closeModal() { 213 | select.getFeatures().clear(); 214 | details.classList.add('hidden'); 215 | } 216 | -------------------------------------------------------------------------------- /Airports/Airports-OAuth/client/style.css: -------------------------------------------------------------------------------- 1 | /* Set the document to use flexbox layout */ 2 | body { 3 | margin: 0; 4 | height: 100vh; 5 | display: flex; 6 | flex-direction: column; 7 | } 8 | /* ensure the map fills as much of the screen as possible */ 9 | #map { 10 | flex: 1 1 auto; 11 | } 12 | 13 | #details { 14 | border-top: 6px solid #453c90; 15 | background-color: white; 16 | position: absolute; 17 | top: 50%; 18 | left: 50%; 19 | transform: translate(-50%, -50%); 20 | padding: 60px 40px 20px 40px; 21 | } 22 | 23 | table, tr, th, td { 24 | text-align: left; 25 | border-collapse: collapse; 26 | border: none; 27 | } 28 | 29 | /* 30 | NOTE: 31 | The CSS following this comment is for *styling purposes only* and is not essential for this demo to run 32 | - strip out the styles below if you want cleaner code 33 | */ 34 | 35 | body { 36 | font-family: "Source Sans Pro", sans-serif; 37 | font-size:16px; 38 | color: #666666; 39 | min-width: 480px; 40 | } 41 | 42 | 43 | h1{ 44 | margin: 0 0 10px 0; 45 | font-size: 32px; 46 | font-weight: normal; 47 | line-height: 1.4; 48 | letter-spacing: 0.7px; 49 | color: #453c90; 50 | } 51 | 52 | h2{ 53 | margin: 0 0 10px 0; 54 | font-size: 32px; 55 | font-weight: normal; 56 | line-height: 1.4; 57 | letter-spacing: 0.7px; 58 | } 59 | 60 | table { 61 | margin: 20px 0; 62 | } 63 | 64 | th { 65 | color: #453c90; 66 | background-color: white; 67 | border-bottom: 2px solid #453c90; 68 | } 69 | 70 | tr { 71 | color: #333333; 72 | } 73 | 74 | tr:nth-child(odd) { 75 | background-color: #f6f5f9; 76 | } 77 | 78 | tr { 79 | border-bottom: 1px solid #dddddd; 80 | } 81 | 82 | p{ 83 | margin: 10px 0; 84 | } 85 | 86 | b{ 87 | font-weight:600; 88 | } 89 | 90 | #header{ 91 | text-align: center; 92 | background-color: #ffffff; 93 | padding: 20px; 94 | border-bottom: 1px solid #dddddd; 95 | box-shadow: 0 2px 4px 1px rgba(0, 0, 0, 0.4); 96 | z-index:1000 97 | } 98 | 99 | .hidden{ 100 | display: none; 101 | } 102 | .warning{ 103 | color:#d40058; 104 | font-weight:400; 105 | } 106 | .close { 107 | border: none; 108 | font-size: 18px; 109 | position: absolute; 110 | top: 12px; 111 | right: 12px; 112 | } 113 | .close:hover { 114 | background-color: #f5f5f5; 115 | } 116 | 117 | form{ 118 | margin-top: 20px; 119 | text-align: left; 120 | } -------------------------------------------------------------------------------- /Airports/Airports-OAuth/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "omse-airport-demo", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "abbrev": { 8 | "version": "1.1.1", 9 | "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", 10 | "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", 11 | "dev": true 12 | }, 13 | "accepts": { 14 | "version": "1.3.8", 15 | "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", 16 | "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", 17 | "requires": { 18 | "mime-types": "~2.1.34", 19 | "negotiator": "0.6.3" 20 | } 21 | }, 22 | "anymatch": { 23 | "version": "3.1.3", 24 | "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", 25 | "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", 26 | "dev": true, 27 | "requires": { 28 | "normalize-path": "^3.0.0", 29 | "picomatch": "^2.0.4" 30 | } 31 | }, 32 | "array-flatten": { 33 | "version": "1.1.1", 34 | "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", 35 | "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==" 36 | }, 37 | "balanced-match": { 38 | "version": "1.0.2", 39 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", 40 | "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", 41 | "dev": true 42 | }, 43 | "binary-extensions": { 44 | "version": "2.2.0", 45 | "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", 46 | "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", 47 | "dev": true 48 | }, 49 | "body-parser": { 50 | "version": "1.20.2", 51 | "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", 52 | "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==", 53 | "requires": { 54 | "bytes": "3.1.2", 55 | "content-type": "~1.0.5", 56 | "debug": "2.6.9", 57 | "depd": "2.0.0", 58 | "destroy": "1.2.0", 59 | "http-errors": "2.0.0", 60 | "iconv-lite": "0.4.24", 61 | "on-finished": "2.4.1", 62 | "qs": "6.11.0", 63 | "raw-body": "2.5.2", 64 | "type-is": "~1.6.18", 65 | "unpipe": "1.0.0" 66 | } 67 | }, 68 | "brace-expansion": { 69 | "version": "1.1.11", 70 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 71 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 72 | "dev": true, 73 | "requires": { 74 | "balanced-match": "^1.0.0", 75 | "concat-map": "0.0.1" 76 | } 77 | }, 78 | "braces": { 79 | "version": "3.0.2", 80 | "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", 81 | "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", 82 | "dev": true, 83 | "requires": { 84 | "fill-range": "^7.0.1" 85 | } 86 | }, 87 | "bytes": { 88 | "version": "3.1.2", 89 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", 90 | "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==" 91 | }, 92 | "call-bind": { 93 | "version": "1.0.7", 94 | "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", 95 | "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", 96 | "requires": { 97 | "es-define-property": "^1.0.0", 98 | "es-errors": "^1.3.0", 99 | "function-bind": "^1.1.2", 100 | "get-intrinsic": "^1.2.4", 101 | "set-function-length": "^1.2.1" 102 | } 103 | }, 104 | "chokidar": { 105 | "version": "3.5.3", 106 | "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", 107 | "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", 108 | "dev": true, 109 | "requires": { 110 | "anymatch": "~3.1.2", 111 | "braces": "~3.0.2", 112 | "fsevents": "~2.3.2", 113 | "glob-parent": "~5.1.2", 114 | "is-binary-path": "~2.1.0", 115 | "is-glob": "~4.0.1", 116 | "normalize-path": "~3.0.0", 117 | "readdirp": "~3.6.0" 118 | } 119 | }, 120 | "concat-map": { 121 | "version": "0.0.1", 122 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 123 | "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", 124 | "dev": true 125 | }, 126 | "content-disposition": { 127 | "version": "0.5.4", 128 | "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", 129 | "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", 130 | "requires": { 131 | "safe-buffer": "5.2.1" 132 | } 133 | }, 134 | "content-type": { 135 | "version": "1.0.5", 136 | "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", 137 | "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==" 138 | }, 139 | "cookie": { 140 | "version": "0.6.0", 141 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", 142 | "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==" 143 | }, 144 | "cookie-signature": { 145 | "version": "1.0.6", 146 | "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", 147 | "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" 148 | }, 149 | "debug": { 150 | "version": "2.6.9", 151 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", 152 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", 153 | "requires": { 154 | "ms": "2.0.0" 155 | } 156 | }, 157 | "define-data-property": { 158 | "version": "1.1.4", 159 | "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", 160 | "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", 161 | "requires": { 162 | "es-define-property": "^1.0.0", 163 | "es-errors": "^1.3.0", 164 | "gopd": "^1.0.1" 165 | } 166 | }, 167 | "depd": { 168 | "version": "2.0.0", 169 | "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", 170 | "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==" 171 | }, 172 | "destroy": { 173 | "version": "1.2.0", 174 | "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", 175 | "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==" 176 | }, 177 | "ee-first": { 178 | "version": "1.1.1", 179 | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", 180 | "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" 181 | }, 182 | "encodeurl": { 183 | "version": "1.0.2", 184 | "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", 185 | "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==" 186 | }, 187 | "es-define-property": { 188 | "version": "1.0.0", 189 | "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", 190 | "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", 191 | "requires": { 192 | "get-intrinsic": "^1.2.4" 193 | } 194 | }, 195 | "es-errors": { 196 | "version": "1.3.0", 197 | "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", 198 | "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==" 199 | }, 200 | "escape-html": { 201 | "version": "1.0.3", 202 | "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", 203 | "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" 204 | }, 205 | "etag": { 206 | "version": "1.8.1", 207 | "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", 208 | "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==" 209 | }, 210 | "express": { 211 | "version": "4.19.2", 212 | "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", 213 | "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", 214 | "requires": { 215 | "accepts": "~1.3.8", 216 | "array-flatten": "1.1.1", 217 | "body-parser": "1.20.2", 218 | "content-disposition": "0.5.4", 219 | "content-type": "~1.0.4", 220 | "cookie": "0.6.0", 221 | "cookie-signature": "1.0.6", 222 | "debug": "2.6.9", 223 | "depd": "2.0.0", 224 | "encodeurl": "~1.0.2", 225 | "escape-html": "~1.0.3", 226 | "etag": "~1.8.1", 227 | "finalhandler": "1.2.0", 228 | "fresh": "0.5.2", 229 | "http-errors": "2.0.0", 230 | "merge-descriptors": "1.0.1", 231 | "methods": "~1.1.2", 232 | "on-finished": "2.4.1", 233 | "parseurl": "~1.3.3", 234 | "path-to-regexp": "0.1.7", 235 | "proxy-addr": "~2.0.7", 236 | "qs": "6.11.0", 237 | "range-parser": "~1.2.1", 238 | "safe-buffer": "5.2.1", 239 | "send": "0.18.0", 240 | "serve-static": "1.15.0", 241 | "setprototypeof": "1.2.0", 242 | "statuses": "2.0.1", 243 | "type-is": "~1.6.18", 244 | "utils-merge": "1.0.1", 245 | "vary": "~1.1.2" 246 | } 247 | }, 248 | "fill-range": { 249 | "version": "7.0.1", 250 | "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", 251 | "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", 252 | "dev": true, 253 | "requires": { 254 | "to-regex-range": "^5.0.1" 255 | } 256 | }, 257 | "finalhandler": { 258 | "version": "1.2.0", 259 | "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", 260 | "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", 261 | "requires": { 262 | "debug": "2.6.9", 263 | "encodeurl": "~1.0.2", 264 | "escape-html": "~1.0.3", 265 | "on-finished": "2.4.1", 266 | "parseurl": "~1.3.3", 267 | "statuses": "2.0.1", 268 | "unpipe": "~1.0.0" 269 | } 270 | }, 271 | "forwarded": { 272 | "version": "0.2.0", 273 | "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", 274 | "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==" 275 | }, 276 | "fresh": { 277 | "version": "0.5.2", 278 | "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", 279 | "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==" 280 | }, 281 | "fsevents": { 282 | "version": "2.3.2", 283 | "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", 284 | "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", 285 | "dev": true, 286 | "optional": true 287 | }, 288 | "function-bind": { 289 | "version": "1.1.2", 290 | "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", 291 | "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==" 292 | }, 293 | "get-intrinsic": { 294 | "version": "1.2.4", 295 | "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", 296 | "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", 297 | "requires": { 298 | "es-errors": "^1.3.0", 299 | "function-bind": "^1.1.2", 300 | "has-proto": "^1.0.1", 301 | "has-symbols": "^1.0.3", 302 | "hasown": "^2.0.0" 303 | } 304 | }, 305 | "glob-parent": { 306 | "version": "5.1.2", 307 | "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", 308 | "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", 309 | "dev": true, 310 | "requires": { 311 | "is-glob": "^4.0.1" 312 | } 313 | }, 314 | "gopd": { 315 | "version": "1.0.1", 316 | "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", 317 | "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", 318 | "requires": { 319 | "get-intrinsic": "^1.1.3" 320 | } 321 | }, 322 | "has-flag": { 323 | "version": "3.0.0", 324 | "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", 325 | "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", 326 | "dev": true 327 | }, 328 | "has-property-descriptors": { 329 | "version": "1.0.2", 330 | "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", 331 | "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", 332 | "requires": { 333 | "es-define-property": "^1.0.0" 334 | } 335 | }, 336 | "has-proto": { 337 | "version": "1.0.3", 338 | "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz", 339 | "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==" 340 | }, 341 | "has-symbols": { 342 | "version": "1.0.3", 343 | "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", 344 | "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==" 345 | }, 346 | "hasown": { 347 | "version": "2.0.2", 348 | "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", 349 | "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", 350 | "requires": { 351 | "function-bind": "^1.1.2" 352 | } 353 | }, 354 | "http-errors": { 355 | "version": "2.0.0", 356 | "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", 357 | "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", 358 | "requires": { 359 | "depd": "2.0.0", 360 | "inherits": "2.0.4", 361 | "setprototypeof": "1.2.0", 362 | "statuses": "2.0.1", 363 | "toidentifier": "1.0.1" 364 | }, 365 | "dependencies": { 366 | "inherits": { 367 | "version": "2.0.4", 368 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", 369 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" 370 | } 371 | } 372 | }, 373 | "iconv-lite": { 374 | "version": "0.4.24", 375 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", 376 | "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", 377 | "requires": { 378 | "safer-buffer": ">= 2.1.2 < 3" 379 | } 380 | }, 381 | "ignore-by-default": { 382 | "version": "1.0.1", 383 | "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", 384 | "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==", 385 | "dev": true 386 | }, 387 | "inherits": { 388 | "version": "2.0.3", 389 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", 390 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" 391 | }, 392 | "ipaddr.js": { 393 | "version": "1.9.1", 394 | "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", 395 | "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==" 396 | }, 397 | "is-binary-path": { 398 | "version": "2.1.0", 399 | "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", 400 | "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", 401 | "dev": true, 402 | "requires": { 403 | "binary-extensions": "^2.0.0" 404 | } 405 | }, 406 | "is-extglob": { 407 | "version": "2.1.1", 408 | "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", 409 | "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", 410 | "dev": true 411 | }, 412 | "is-glob": { 413 | "version": "4.0.3", 414 | "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", 415 | "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", 416 | "dev": true, 417 | "requires": { 418 | "is-extglob": "^2.1.1" 419 | } 420 | }, 421 | "is-number": { 422 | "version": "7.0.0", 423 | "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", 424 | "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", 425 | "dev": true 426 | }, 427 | "media-typer": { 428 | "version": "0.3.0", 429 | "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", 430 | "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==" 431 | }, 432 | "merge-descriptors": { 433 | "version": "1.0.1", 434 | "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", 435 | "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==" 436 | }, 437 | "methods": { 438 | "version": "1.1.2", 439 | "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", 440 | "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==" 441 | }, 442 | "mime": { 443 | "version": "1.6.0", 444 | "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", 445 | "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" 446 | }, 447 | "mime-db": { 448 | "version": "1.52.0", 449 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", 450 | "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==" 451 | }, 452 | "mime-types": { 453 | "version": "2.1.35", 454 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", 455 | "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", 456 | "requires": { 457 | "mime-db": "1.52.0" 458 | } 459 | }, 460 | "minimatch": { 461 | "version": "3.1.2", 462 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", 463 | "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", 464 | "dev": true, 465 | "requires": { 466 | "brace-expansion": "^1.1.7" 467 | } 468 | }, 469 | "ms": { 470 | "version": "2.0.0", 471 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 472 | "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" 473 | }, 474 | "negotiator": { 475 | "version": "0.6.3", 476 | "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", 477 | "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==" 478 | }, 479 | "node-fetch": { 480 | "version": "2.7.0", 481 | "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", 482 | "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", 483 | "requires": { 484 | "whatwg-url": "^5.0.0" 485 | } 486 | }, 487 | "nodemon": { 488 | "version": "2.0.20", 489 | "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.20.tgz", 490 | "integrity": "sha512-Km2mWHKKY5GzRg6i1j5OxOHQtuvVsgskLfigG25yTtbyfRGn/GNvIbRyOf1PSCKJ2aT/58TiuUsuOU5UToVViw==", 491 | "dev": true, 492 | "requires": { 493 | "chokidar": "^3.5.2", 494 | "debug": "^3.2.7", 495 | "ignore-by-default": "^1.0.1", 496 | "minimatch": "^3.1.2", 497 | "pstree.remy": "^1.1.8", 498 | "semver": "^5.7.1", 499 | "simple-update-notifier": "^1.0.7", 500 | "supports-color": "^5.5.0", 501 | "touch": "^3.1.0", 502 | "undefsafe": "^2.0.5" 503 | }, 504 | "dependencies": { 505 | "debug": { 506 | "version": "3.2.7", 507 | "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", 508 | "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", 509 | "dev": true, 510 | "requires": { 511 | "ms": "^2.1.1" 512 | } 513 | }, 514 | "ms": { 515 | "version": "2.1.3", 516 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", 517 | "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", 518 | "dev": true 519 | } 520 | } 521 | }, 522 | "nopt": { 523 | "version": "1.0.10", 524 | "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", 525 | "integrity": "sha512-NWmpvLSqUrgrAC9HCuxEvb+PSloHpqVu+FqcO4eeF2h5qYRhA7ev6KvelyQAKtegUbC6RypJnlEOhd8vloNKYg==", 526 | "dev": true, 527 | "requires": { 528 | "abbrev": "1" 529 | } 530 | }, 531 | "normalize-path": { 532 | "version": "3.0.0", 533 | "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", 534 | "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", 535 | "dev": true 536 | }, 537 | "object-inspect": { 538 | "version": "1.13.1", 539 | "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz", 540 | "integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==" 541 | }, 542 | "on-finished": { 543 | "version": "2.4.1", 544 | "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", 545 | "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", 546 | "requires": { 547 | "ee-first": "1.1.1" 548 | } 549 | }, 550 | "parseurl": { 551 | "version": "1.3.3", 552 | "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", 553 | "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" 554 | }, 555 | "path": { 556 | "version": "0.12.7", 557 | "resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz", 558 | "integrity": "sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8=", 559 | "requires": { 560 | "process": "^0.11.1", 561 | "util": "^0.10.3" 562 | } 563 | }, 564 | "path-to-regexp": { 565 | "version": "0.1.7", 566 | "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", 567 | "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" 568 | }, 569 | "picomatch": { 570 | "version": "2.3.1", 571 | "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", 572 | "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", 573 | "dev": true 574 | }, 575 | "process": { 576 | "version": "0.11.10", 577 | "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", 578 | "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=" 579 | }, 580 | "proxy-addr": { 581 | "version": "2.0.7", 582 | "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", 583 | "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", 584 | "requires": { 585 | "forwarded": "0.2.0", 586 | "ipaddr.js": "1.9.1" 587 | } 588 | }, 589 | "pstree.remy": { 590 | "version": "1.1.8", 591 | "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", 592 | "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==", 593 | "dev": true 594 | }, 595 | "qs": { 596 | "version": "6.11.0", 597 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", 598 | "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", 599 | "requires": { 600 | "side-channel": "^1.0.4" 601 | } 602 | }, 603 | "range-parser": { 604 | "version": "1.2.1", 605 | "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", 606 | "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" 607 | }, 608 | "raw-body": { 609 | "version": "2.5.2", 610 | "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz", 611 | "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==", 612 | "requires": { 613 | "bytes": "3.1.2", 614 | "http-errors": "2.0.0", 615 | "iconv-lite": "0.4.24", 616 | "unpipe": "1.0.0" 617 | } 618 | }, 619 | "readdirp": { 620 | "version": "3.6.0", 621 | "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", 622 | "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", 623 | "dev": true, 624 | "requires": { 625 | "picomatch": "^2.2.1" 626 | } 627 | }, 628 | "safe-buffer": { 629 | "version": "5.2.1", 630 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", 631 | "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" 632 | }, 633 | "safer-buffer": { 634 | "version": "2.1.2", 635 | "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", 636 | "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" 637 | }, 638 | "semver": { 639 | "version": "5.7.1", 640 | "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", 641 | "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", 642 | "dev": true 643 | }, 644 | "send": { 645 | "version": "0.18.0", 646 | "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", 647 | "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", 648 | "requires": { 649 | "debug": "2.6.9", 650 | "depd": "2.0.0", 651 | "destroy": "1.2.0", 652 | "encodeurl": "~1.0.2", 653 | "escape-html": "~1.0.3", 654 | "etag": "~1.8.1", 655 | "fresh": "0.5.2", 656 | "http-errors": "2.0.0", 657 | "mime": "1.6.0", 658 | "ms": "2.1.3", 659 | "on-finished": "2.4.1", 660 | "range-parser": "~1.2.1", 661 | "statuses": "2.0.1" 662 | }, 663 | "dependencies": { 664 | "ms": { 665 | "version": "2.1.3", 666 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", 667 | "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" 668 | } 669 | } 670 | }, 671 | "serve-static": { 672 | "version": "1.15.0", 673 | "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", 674 | "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", 675 | "requires": { 676 | "encodeurl": "~1.0.2", 677 | "escape-html": "~1.0.3", 678 | "parseurl": "~1.3.3", 679 | "send": "0.18.0" 680 | } 681 | }, 682 | "set-function-length": { 683 | "version": "1.2.2", 684 | "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", 685 | "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", 686 | "requires": { 687 | "define-data-property": "^1.1.4", 688 | "es-errors": "^1.3.0", 689 | "function-bind": "^1.1.2", 690 | "get-intrinsic": "^1.2.4", 691 | "gopd": "^1.0.1", 692 | "has-property-descriptors": "^1.0.2" 693 | } 694 | }, 695 | "setprototypeof": { 696 | "version": "1.2.0", 697 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", 698 | "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" 699 | }, 700 | "side-channel": { 701 | "version": "1.0.6", 702 | "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz", 703 | "integrity": "sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==", 704 | "requires": { 705 | "call-bind": "^1.0.7", 706 | "es-errors": "^1.3.0", 707 | "get-intrinsic": "^1.2.4", 708 | "object-inspect": "^1.13.1" 709 | } 710 | }, 711 | "simple-update-notifier": { 712 | "version": "1.1.0", 713 | "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-1.1.0.tgz", 714 | "integrity": "sha512-VpsrsJSUcJEseSbMHkrsrAVSdvVS5I96Qo1QAQ4FxQ9wXFcB+pjj7FB7/us9+GcgfW4ziHtYMc1J0PLczb55mg==", 715 | "dev": true, 716 | "requires": { 717 | "semver": "~7.0.0" 718 | }, 719 | "dependencies": { 720 | "semver": { 721 | "version": "7.0.0", 722 | "resolved": "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz", 723 | "integrity": "sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==", 724 | "dev": true 725 | } 726 | } 727 | }, 728 | "statuses": { 729 | "version": "2.0.1", 730 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", 731 | "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==" 732 | }, 733 | "supports-color": { 734 | "version": "5.5.0", 735 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", 736 | "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", 737 | "dev": true, 738 | "requires": { 739 | "has-flag": "^3.0.0" 740 | } 741 | }, 742 | "to-regex-range": { 743 | "version": "5.0.1", 744 | "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", 745 | "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", 746 | "dev": true, 747 | "requires": { 748 | "is-number": "^7.0.0" 749 | } 750 | }, 751 | "toidentifier": { 752 | "version": "1.0.1", 753 | "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", 754 | "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==" 755 | }, 756 | "touch": { 757 | "version": "3.1.0", 758 | "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz", 759 | "integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==", 760 | "dev": true, 761 | "requires": { 762 | "nopt": "~1.0.10" 763 | } 764 | }, 765 | "tr46": { 766 | "version": "0.0.3", 767 | "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", 768 | "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" 769 | }, 770 | "type-is": { 771 | "version": "1.6.18", 772 | "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", 773 | "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", 774 | "requires": { 775 | "media-typer": "0.3.0", 776 | "mime-types": "~2.1.24" 777 | } 778 | }, 779 | "undefsafe": { 780 | "version": "2.0.5", 781 | "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", 782 | "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==", 783 | "dev": true 784 | }, 785 | "unpipe": { 786 | "version": "1.0.0", 787 | "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", 788 | "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==" 789 | }, 790 | "util": { 791 | "version": "0.10.4", 792 | "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz", 793 | "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==", 794 | "requires": { 795 | "inherits": "2.0.3" 796 | } 797 | }, 798 | "utils-merge": { 799 | "version": "1.0.1", 800 | "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", 801 | "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==" 802 | }, 803 | "vary": { 804 | "version": "1.1.2", 805 | "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", 806 | "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==" 807 | }, 808 | "webidl-conversions": { 809 | "version": "3.0.1", 810 | "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", 811 | "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" 812 | }, 813 | "whatwg-url": { 814 | "version": "5.0.0", 815 | "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", 816 | "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", 817 | "requires": { 818 | "tr46": "~0.0.3", 819 | "webidl-conversions": "^3.0.0" 820 | } 821 | } 822 | } 823 | } 824 | -------------------------------------------------------------------------------- /Airports/Airports-OAuth/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "omse-airport-demo", 3 | "version": "1.0.0", 4 | "description": "An application demonstrating combined use of the OS Maps API and OS Features API", 5 | "main": "server.js", 6 | "dependencies": { 7 | "express": "^4.19.2", 8 | "node-fetch": "^2.7.0", 9 | "path": "^0.12.7" 10 | }, 11 | "devDependencies": { 12 | "nodemon": "^2.0.20" 13 | }, 14 | "scripts": { 15 | "test": "echo \"Error: no test specified\" && exit 1", 16 | "dev": "nodemon --inspect server.js" 17 | }, 18 | "repository": { 19 | "type": "git", 20 | "url": "git+https://github.com/OrdnanceSurvey/OS-Data-Hub-API-Demos.git" 21 | }, 22 | "license": "Apache-2.0", 23 | "bugs": { 24 | "url": "https://github.com/OrdnanceSurvey/OS-Data-Hub-API-Demos/issues" 25 | }, 26 | "homepage": "https://github.com/OrdnanceSurvey/OS-Data-Hub-API-Demos#readme" 27 | } 28 | -------------------------------------------------------------------------------- /Airports/Airports-OAuth/server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const path = require('path'); 3 | const fetch = require('node-fetch'); 4 | 5 | // Read the application API key and secret from the command line. 6 | const key = process.argv[2]; 7 | const secret = process.argv[3]; 8 | if(!key || !secret) { 9 | throw Error('Please provide an API key and secret on the command line.\nUsage: server.js '); 10 | } 11 | console.log('Using API key: ' + key); 12 | 13 | // Setup an express server. 14 | // This server serves the client files to the browser, and provides an endpoint to get an access token. 15 | const app = express(); 16 | app.use(express.static(path.join(__dirname, 'client'))); 17 | 18 | app.get('/token', function(req, res) { 19 | const params = new URLSearchParams(); 20 | params.append('grant_type', 'client_credentials'); 21 | const authString = Buffer.from(key + ":" + secret).toString('base64'); 22 | fetch('https://api.os.uk/oauth2/token/v1', { 23 | method: 'POST', 24 | body: params, 25 | headers: { 26 | Authorization: 'Basic ' + authString 27 | } 28 | }) 29 | .then(res => res.json()) 30 | .then(json => { 31 | res.set('Content-Type', 'application/json'); 32 | res.send(json); 33 | }) 34 | .catch(() => { 35 | res.status(500).send('Failed to get access token, check the API key and secret'); 36 | }); 37 | }); 38 | 39 | app.listen(8080, () => console.log("Listening on port 8080. Please open http://localhost:8080 in a web browser.")); 40 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /OSFeaturesAPI/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | OS Features API Demo 5 | 6 | 7 | 8 | 9 | 10 | 23 |
24 |

To connect to your mapping API:

25 |
    26 |
  1. Go to the OS Data Hub,
  2. 27 |
  3. Create a project,
  4. 28 |
  5. Add the OS Features API to your project
  6. 29 |
  7. Copy the project API Key, and enter it into the box above.
  8. 30 |
31 |
32 |
33 | 34 | 35 | -------------------------------------------------------------------------------- /OSFeaturesAPI/js/query.js: -------------------------------------------------------------------------------- 1 | // We will return 10 results at a time 2 | let startIndex = 0; 3 | let count = 10; 4 | 5 | // Return the first 10 results 6 | window.query = function() { 7 | startIndex = 0; 8 | runQuery(); 9 | }; 10 | 11 | // Return the next 10 results (on each run of the loadMore function) 12 | window.loadMore = function() { 13 | startIndex += count; 14 | runQuery(); 15 | }; 16 | 17 | function runQuery() { 18 | var key = document.getElementById('keyInput').value; 19 | var message = document.getElementById('message'); 20 | var results = document.getElementById('results'); 21 | var search = document.getElementById('search'); 22 | var more = document.getElementById('more'); 23 | var instructions = document.getElementById('instructions'); 24 | 25 | results.innerHTML = ''; 26 | if(!key) { 27 | message.classList.add("warning"); 28 | message.textContent = 'To run the query, please enter a valid API key.'; 29 | instructions.classList.remove("hidden"); 30 | search.disabled = false; 31 | more.disabled = true; 32 | return; 33 | } 34 | message.classList.remove("warning"); 35 | message.textContent = 'To run the query, please enter a valid API key.'; 36 | instructions.classList.add("hidden"); 37 | 38 | // The parameters required to call the WFS service 39 | var parameters = { 40 | key: key, 41 | request: 'GetFeature', 42 | service: 'WFS', 43 | version: '2.0.0', 44 | // typeName defines tha layer we are querying 45 | // You can replace this with another layer if you wish 46 | typeName: 'Zoomstack_Airports', 47 | startIndex: startIndex, 48 | count: count, 49 | outputFormat: 'GEOJSON' 50 | }; 51 | // We encode the parameters and create the URL 52 | var encodedParameters = Object.keys(parameters) 53 | .map(paramName => paramName + '=' + encodeURI(parameters[paramName])) 54 | .join('&'); 55 | var url = 'https://api.os.uk/features/v1/wfs?' + encodedParameters; 56 | 57 | search.disabled = true; 58 | more.disabled = true; 59 | results.innerHTML = '

Loading...

'; 60 | fetch(url) 61 | .then(response => response.json()) 62 | .then(json => { 63 | search.disabled = false; 64 | if(json.features.length === count) { 65 | // We got a full set of results, so we should enable the load more button 66 | more.disabled = false; 67 | } 68 | results.innerHTML = ''; 69 | 70 | // If results are returned we display them one by one 71 | json.features.forEach(feature => { 72 | // Create a heading using the feature name 73 | var node = document.createElement('h1'); 74 | node.innerText = feature.properties.Name; 75 | results.appendChild(node); 76 | 77 | // Print out the feature geometry 78 | node = document.createElement('label'); 79 | node.setAttribute('for', feature.properties.OBJECTID); 80 | node.innerText = 'Geometry Type: '; 81 | results.appendChild(node); 82 | node = document.createElement('span'); 83 | node.id = feature.properties.OBJECTID; 84 | node.innerText = feature.geometry.type; 85 | results.appendChild(node); 86 | 87 | // Create a table with all of the feature properties 88 | const table = document.createElement('table'); 89 | results.appendChild(table); 90 | var row = document.createElement('tr'); 91 | row.innerHTML = 'Property NameValue'; 92 | table.appendChild(row); 93 | 94 | Object.keys(feature.properties).forEach(propertyName => { 95 | var row = document.createElement('tr'); 96 | row.innerHTML = '' + propertyName + '' + feature.properties[propertyName] + ''; 97 | table.appendChild(row); 98 | }); 99 | }); 100 | }) 101 | .catch(error => { 102 | search.disabled = false; 103 | more.disabled = true; 104 | message.classList.remove("warning"); 105 | message.textContent = 'Got an error when running the query! Check your network connection, or try another API key.'; 106 | }); 107 | } 108 | -------------------------------------------------------------------------------- /OSFeaturesAPI/style.css: -------------------------------------------------------------------------------- 1 | /* Set the document to use flexbox layout */ 2 | body { 3 | margin: 0; 4 | height: 100vh; 5 | display: flex; 6 | flex-direction: column; 7 | text-align: center; 8 | font-family: sans-serif; 9 | overflow-y: hidden; 10 | } 11 | 12 | #results { 13 | text-align: left; 14 | flex: 1 1 auto; 15 | padding: 10px; 16 | overflow-y: auto; 17 | } 18 | 19 | table, tr, th, td { 20 | border: none; 21 | border-collapse: collapse; 22 | } 23 | 24 | /* 25 | NOTE: 26 | The CSS following this comment is for *styling purposes only* and is not essential for this demo to run 27 | - strip out the styles below if you want cleaner code 28 | */ 29 | 30 | body { 31 | font-family: "Source Sans Pro", sans-serif; 32 | font-size:16px; 33 | color: #666666; 34 | min-width: 480px; 35 | } 36 | 37 | table { 38 | margin: 20px 0; 39 | } 40 | 41 | th { 42 | color: #453c90; 43 | background-color: white; 44 | border-bottom: 2px solid #453c90; 45 | } 46 | 47 | tr { 48 | color: #333333; 49 | } 50 | 51 | tr:nth-child(odd) { 52 | background-color: #f6f5f9; 53 | } 54 | 55 | tr { 56 | border-bottom: 1px solid #dddddd; 57 | } 58 | 59 | h1{ 60 | font-size: 32px; 61 | font-weight: normal; 62 | line-height: 1.4; 63 | letter-spacing: 0.7px; 64 | margin: 0 0 10px; 65 | color: #453c90; 66 | } 67 | 68 | p{ 69 | margin: 10px 0; 70 | } 71 | 72 | b{ 73 | font-weight:600; 74 | } 75 | label{ 76 | line-height: 1.7em; 77 | font-weight: 600; 78 | } 79 | input, button{ 80 | font-size: 16px; 81 | 82 | } 83 | 84 | input[type="text"]{ 85 | height: 24px; 86 | border-radius: 3px 0 0 3px; 87 | border: solid 1px #dddddd; 88 | padding: 12px 16px; 89 | flex: 1 1 auto; 90 | background-color: #f5f5f5; 91 | color: #333333; 92 | font-size: 16px; 93 | margin:0; 94 | } 95 | button{ 96 | height: 50px; 97 | border-radius: 0; 98 | background-color: #453c90; 99 | color: #fff; 100 | font-family: "Source Sans Pro", sans-serif; 101 | padding: 4px 20px; 102 | border:0; 103 | } 104 | button:disabled { 105 | background-color: #999999; 106 | color: #fff; 107 | } 108 | button.secondary { 109 | background-color: #fff; 110 | border: 1px solid #453c90; 111 | color: #453c90; 112 | } 113 | button.secondary:disabled { 114 | border: 1px solid #999999; 115 | color: #999999; 116 | } 117 | button:last-of-type { 118 | border-radius: 0 3px 3px 0; 119 | } 120 | 121 | #header{ 122 | text-align: center; 123 | background-color: #ffffff; 124 | padding: 20px; 125 | border-bottom: 1px solid #dddddd; 126 | box-shadow: 0 2px 4px 1px rgba(0, 0, 0, 0.4); 127 | z-index:1000 128 | 129 | } 130 | 131 | 132 | #instructions{ 133 | text-align: left; 134 | position: relative; 135 | background-color: #fff; 136 | padding: 10px 20px; 137 | top: 40px; 138 | margin: auto; 139 | z-index: 100; 140 | border-radius: 3px; 141 | box-shadow: 0 1px 4px 1px rgba(0, 0, 0, 0.4); 142 | } 143 | 144 | .hidden{ 145 | display:none; 146 | } 147 | .warning{ 148 | color:#d40058; 149 | font-weight:400; 150 | } 151 | .inputContainer { 152 | display: flex; 153 | } 154 | .geometry { 155 | text-overflow: ellipsis; 156 | white-space: nowrap; 157 | overflow: hidden; 158 | } 159 | form{ 160 | margin-top: 20px; 161 | text-align: left; 162 | } -------------------------------------------------------------------------------- /OSLinkedIdentifiersAPI/img/expand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OrdnanceSurvey/OS-Data-Hub-API-Demos/21dc7d5c178ca112101503fd3afa7366fd7861dd/OSLinkedIdentifiersAPI/img/expand.png -------------------------------------------------------------------------------- /OSLinkedIdentifiersAPI/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | OS Linked Identifiers API Demo 5 | 6 | 7 | 8 | 9 | 10 | 122 | 123 |
124 |
125 |

To connect to your linked identifiers API:

126 |
    127 |
  1. Go to the OS Data Hub,
  2. 128 |
  3. Create a project,
  4. 129 |
  5. Add the OS Linked Identifiers API to your project
  6. 130 |
  7. Copy the project API Key, and enter it into the box above.
  8. 131 |
132 |
133 | 134 | 135 |
136 | 137 | 138 | -------------------------------------------------------------------------------- /OSLinkedIdentifiersAPI/js/query.js: -------------------------------------------------------------------------------- 1 | const BASE_URL = 'https://api.os.uk/search/links/v1/'; 2 | 3 | const MISSING_ID_MSG = 'To run this query, please enter an ID.'; 4 | 5 | window.displayDropdownMenu = function(id) { 6 | var dropdownMenu = document.getElementById(id); 7 | if (dropdownMenu.classList.contains('hidden')) { 8 | dropdownMenu.classList.remove('hidden'); 9 | } else { 10 | dropdownMenu.classList.add('hidden'); 11 | } 12 | }; 13 | 14 | window.runByIdentifierQuery = function () { 15 | var byIdentifier = document.getElementById('byIdentifier').value; 16 | 17 | if(!byIdentifier) { 18 | displayErrorMessage(MISSING_ID_MSG); 19 | return; 20 | } 21 | 22 | var url = BASE_URL + 'identifiers/' + byIdentifier; 23 | runQuery(url); 24 | }; 25 | 26 | window.runByFeatureTypeQuery = function () { 27 | var featureType = document.getElementById('feature').value; 28 | var featureTypeID = document.getElementById('featureTypeID').value; 29 | 30 | if(featureType === 'null') { 31 | displayErrorMessage('To run this query, please select a feature type.'); 32 | return; 33 | } 34 | 35 | if(!featureTypeID) { 36 | displayErrorMessage(MISSING_ID_MSG); 37 | return; 38 | } 39 | 40 | var url = BASE_URL + 'featureTypes/' + encodeURI(featureType) + '/' + encodeURI(featureTypeID); 41 | runQuery(url); 42 | }; 43 | 44 | window.runByIdentifierTypeQuery = function () { 45 | var identifierType = document.getElementById('identifier').value; 46 | var identifierTypeID = document.getElementById('identifierTypeID').value; 47 | 48 | if(identifierType === 'null') { 49 | displayErrorMessage('To run this query, please select a identifier type.'); 50 | return; 51 | } 52 | 53 | if(!identifierTypeID) { 54 | displayErrorMessage(MISSING_ID_MSG); 55 | return; 56 | } 57 | 58 | var url = BASE_URL + 'identifierTypes/' + encodeURI(identifierType) + '/' + encodeURI(identifierTypeID); 59 | runQuery(url); 60 | }; 61 | 62 | window.productVersionInformationQuery = function () { 63 | var correlationMethodID = document.getElementById('correlationMethod').value; 64 | 65 | if(correlationMethodID === 'null') { 66 | displayErrorMessage('To run this query, please select a correlation method.'); 67 | return; 68 | } 69 | 70 | var url = BASE_URL + 'productVersionInfo/' + encodeURI(correlationMethodID); 71 | runQuery(url); 72 | }; 73 | 74 | window.runExample = function (id, featureType) { 75 | document.getElementById('dropdownMenu').classList.add('hidden'); 76 | 77 | var url = BASE_URL + 'featureTypes/' + featureType + '/' + id; 78 | document.getElementById('osExample').value = url; 79 | runQuery(url); 80 | }; 81 | 82 | window.runAdanacExample = function (id, featureType) { 83 | document.getElementById('dropdownMenuAdanac').classList.add('hidden'); 84 | 85 | var url = BASE_URL + 'featureTypes/' + featureType + '/' + id; 86 | document.getElementById('exampleAdanaDrive').value = url; 87 | runQuery(url); 88 | }; 89 | 90 | function displayErrorMessage(messageText) { 91 | var message = document.getElementById('message'); 92 | var results = document.getElementById('results'); 93 | var instructions = document.getElementById('instructions'); 94 | 95 | message.classList.add("warning"); 96 | message.textContent = messageText; 97 | instructions.classList.remove("hidden"); 98 | results.classList.add('hidden'); 99 | } 100 | 101 | function runQuery(baseUrl) { 102 | //API Key input box 103 | var key = document.getElementById('keyInput').value; 104 | var message = document.getElementById('message'); 105 | var results = document.getElementById('results'); 106 | var instructions = document.getElementById('instructions'); 107 | 108 | results.innerHTML = ''; 109 | if(!key) { 110 | displayErrorMessage('To run the query, please enter a valid API key.'); 111 | return; 112 | } 113 | 114 | message.classList.remove("warning"); 115 | message.textContent = 'To run any of the queries, please enter a valid API key.'; 116 | instructions.classList.add("hidden"); 117 | results.classList.remove("hidden"); 118 | 119 | var keyParam = 'key' + '=' + encodeURI(key); 120 | var url = baseUrl + '?' + keyParam; 121 | 122 | results.innerHTML = '

Loading...

'; 123 | fetch(url) 124 | .then(response => { 125 | results.innerHTML = ''; 126 | 127 | var divNode = document.createElement('div'); 128 | divNode.classList.add('urlContainer'); 129 | var url = response.url; 130 | divNode.innerHTML = 'URL: '+ url + ''; 131 | results.appendChild(divNode); 132 | 133 | var statusCode = response.status; 134 | var statusNode = document.createElement('div'); 135 | statusNode.innerHTML = 'Status: '+ statusCode + ''; 136 | results.appendChild(statusNode); 137 | 138 | return response.json(); 139 | }) 140 | .then(json => { 141 | var node = document.createElement('pre'); 142 | node.innerHTML = syntaxHighlight(JSON.stringify(json, undefined, 2)); 143 | results.appendChild(node); 144 | }) 145 | .catch(error => { 146 | message.classList.remove("warning"); 147 | message.textContent = 'Got an error when running the query! Check your network connection, or try another API key.'; 148 | }); 149 | } 150 | 151 | function syntaxHighlight(json) { 152 | return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) { 153 | var cls = 'value'; 154 | if (/^"/.test(match)) { 155 | if (/:$/.test(match)) { 156 | cls = 'key'; 157 | } 158 | } 159 | return '' + match + ''; 160 | }) 161 | } 162 | -------------------------------------------------------------------------------- /OSLinkedIdentifiersAPI/style.css: -------------------------------------------------------------------------------- 1 | /* Set the document to use flexbox layout */ 2 | body { 3 | margin: 0; 4 | height: 100vh; 5 | display: flex; 6 | flex-direction: row; 7 | text-align: center; 8 | font-family: sans-serif; 9 | overflow-y: hidden; 10 | } 11 | 12 | #results { 13 | text-align: left; 14 | flex: 1 1 auto; 15 | padding: 10px; 16 | overflow-y: auto; 17 | } 18 | 19 | /* 20 | NOTE: 21 | The CSS following this comment is for *styling purposes only* and is not essential for this demo to run 22 | - strip out the styles below if you want cleaner code 23 | */ 24 | 25 | body { 26 | font-family: "Source Sans Pro", sans-serif; 27 | font-size:16px; 28 | color: #666666; 29 | min-width: 480px; 30 | } 31 | 32 | h1 { 33 | font-size: 32px; 34 | font-weight: normal; 35 | line-height: 1.4; 36 | letter-spacing: 0.7px; 37 | margin: 0 0 10px; 38 | color: #453c90; 39 | } 40 | 41 | p { 42 | margin: 10px 0; 43 | } 44 | 45 | b { 46 | font-weight:600; 47 | } 48 | 49 | label { 50 | line-height: 1.7em; 51 | font-weight: 600; 52 | } 53 | 54 | input, button { 55 | font-size: 16px; 56 | } 57 | 58 | input[type="text"] { 59 | height: 24px; 60 | border-radius: 3px 0 0 3px; 61 | border: solid 1px #dddddd; 62 | padding: 12px 16px; 63 | flex: 1 1 auto; 64 | background-color: #f5f5f5; 65 | color: #333333; 66 | font-size: 16px; 67 | margin: 0 4px 0 0; 68 | } 69 | 70 | button { 71 | height: 50px; 72 | border-radius: 3px; 73 | background-color: #453c90; 74 | color: #fff; 75 | font-family: "Source Sans Pro", sans-serif; 76 | padding: 4px 20px; 77 | border:0; 78 | 79 | } 80 | 81 | select { 82 | height: 50px; 83 | border-radius: 3px; 84 | border: solid 1px #dddddd; 85 | font-family: "Source Sans Pro", sans-serif; 86 | font-size:16px; 87 | color: #666666; 88 | margin-right: 5px; 89 | width: 180px; 90 | } 91 | 92 | .key { 93 | color: #07a; 94 | } 95 | 96 | .value { 97 | color: #d40058; 98 | } 99 | 100 | #header { 101 | background-color: #ffffff; 102 | padding: 20px; 103 | box-shadow: 0 2px 4px 1px rgba(0, 0, 0, 0.4); 104 | width: 50%; 105 | flex: 1; 106 | overflow-y: auto; 107 | } 108 | 109 | #resultContainer { 110 | display: flex; 111 | width: 50%; 112 | padding: 20px; 113 | background: #f5f2f0; 114 | } 115 | 116 | #instructions { 117 | text-align: left; 118 | position: relative; 119 | background-color: #fff; 120 | padding: 10px 20px; 121 | top: 40px; 122 | margin: auto; 123 | z-index: 100; 124 | border-radius: 3px; 125 | box-shadow: 0 1px 4px 1px rgba(0, 0, 0, 0.4); 126 | } 127 | 128 | #correlationMethod { 129 | flex: 1; 130 | } 131 | 132 | .hidden { 133 | display:none; 134 | } 135 | 136 | .warning { 137 | color:#d40058; 138 | font-weight:400; 139 | } 140 | .inputContainer { 141 | display: flex; 142 | } 143 | 144 | .form { 145 | margin-top: 20px; 146 | text-align: left; 147 | } 148 | 149 | .urlContainer { 150 | margin-bottom: 8px; 151 | } 152 | 153 | .dropdownButton { 154 | outline: none; 155 | border-radius: 3px; 156 | border: solid 1px #453c90; 157 | color: #453c90; 158 | background-color: white; 159 | font-weight: 600; 160 | display: flex; 161 | padding-left: 12px; 162 | margin-right: 4px; 163 | } 164 | 165 | .dropdownButtonText { 166 | margin: auto 167 | } 168 | 169 | .dropdownImg { 170 | width: 24px; 171 | height: 24px; 172 | margin-top: auto; 173 | margin-bottom: auto; 174 | margin-left: 12px; 175 | } 176 | 177 | .dropdownMenu { 178 | width: 200px; 179 | list-style: none; 180 | border: 1px solid #666; 181 | padding: 0; 182 | border-radius: 3px; 183 | background: white; 184 | margin-top: 4px; 185 | } 186 | 187 | .menuOption { 188 | cursor: pointer; 189 | padding: 12px; 190 | } 191 | 192 | .menuOption:hover { 193 | background-color: #ddd; 194 | } 195 | 196 | .examplesContainer { 197 | padding-top: 4px; 198 | border-top: 2px solid #dddddd; 199 | margin-top: 24px; 200 | margin-bottom: 36px; 201 | } 202 | 203 | .exampleTitle { 204 | margin-top: 24px; 205 | margin-bottom: 8px 206 | } 207 | 208 | .exampleSelection { 209 | display: flex 210 | } -------------------------------------------------------------------------------- /OSMapsAPI/ArcGIS/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | OS Maps API Demo 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 37 |
38 |
39 |

To connect to your mapping API:

40 |
    41 |
  1. Go to the OS Data Hub,
  2. 42 |
  3. Create a project,
  4. 43 |
  5. Add the OS Maps API to your project
  6. 44 |
  7. Copy the project API Key, and enter it into the box above.
  8. 45 |
46 | 47 | Note that this sample will allow you to zoom the map down into Premium data layers. 48 | If your API key only has access to OS OpenData layers then those requests will fail. 49 | 50 |
51 | 52 | 53 | -------------------------------------------------------------------------------- /OSMapsAPI/ArcGIS/map.js: -------------------------------------------------------------------------------- 1 | require( 2 | [ 3 | "esri/Map", 4 | "esri/views/MapView", 5 | "esri/layers/WMTSLayer", 6 | "esri/geometry/Point", 7 | "esri/geometry/SpatialReference", 8 | "esri/geometry/projection", 9 | "dojo/domReady!" 10 | ], 11 | function(Map, MapView, WMTSLayer, Point, SpatialReference, projection) { 12 | var promise = projection.load(); 13 | 14 | window.setupLayer = function() { 15 | // This sets up the API key entry at the beginning 16 | var key = document.getElementById('keyInput').value; 17 | var message = document.getElementById('message'); 18 | var instructions = document.getElementById('instructions'); 19 | var style = document.getElementById('style').value; 20 | 21 | if(!key) { 22 | message.classList.add("warning"); 23 | message.textContent = 'To view the map, please enter a valid API key.'; 24 | instructions.classList.remove("hidden"); 25 | return; 26 | } 27 | message.classList.remove("warning"); 28 | message.textContent = 'To view the map, please enter a valid API key.'; 29 | instructions.classList.add("hidden"); 30 | 31 | // Defining the WMTS layer using the service URL to pull in the main settings 32 | var wmtsLayer = new WMTSLayer({ 33 | url: 'https://api.os.uk/maps/raster/v1/wmts', 34 | activeLayer: { 35 | id: style 36 | }, 37 | customParameters: { 38 | key: key 39 | }, 40 | copyright: '© Ordnance Survey' 41 | }); 42 | 43 | wmtsLayer.when(success => {}, error => { 44 | message.classList.add("warning"); 45 | message.textContent = 'Could not connect to the API. Ensure you are entering a project API key for a project that contains the OS Maps API'; 46 | instructions.classList.remove("hidden"); 47 | }); 48 | 49 | var map = new Map({ 50 | layers: [wmtsLayer] 51 | }); 52 | 53 | // Once the projection loads we define the center coordinates in EPSG:27700 54 | // Then set up the map view 55 | promise.then(() => { 56 | var center = new Point({ 57 | x: 425168, 58 | y: 563779, 59 | spatialReference: new SpatialReference({wkid: 27700}) 60 | }); 61 | if(style.indexOf('27700') === -1) { 62 | center = projection.project(center, new SpatialReference({ wkid: 3857 })); 63 | } 64 | new MapView({ 65 | map: map, 66 | container: "map", 67 | center: center, 68 | scale: 250000 69 | }); 70 | }); 71 | }; 72 | } 73 | ); 74 | -------------------------------------------------------------------------------- /OSMapsAPI/Leaflet/Proj4Leaflet/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012, Kartena AB 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 14 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 17 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 20 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | -------------------------------------------------------------------------------- /OSMapsAPI/Leaflet/Proj4Leaflet/proj4leaflet.js: -------------------------------------------------------------------------------- 1 | (function (factory) { 2 | var L, proj4; 3 | if (typeof define === 'function' && define.amd) { 4 | // AMD 5 | define(['leaflet', 'proj4'], factory); 6 | } else if (typeof module === 'object' && typeof module.exports === "object") { 7 | // Node/CommonJS 8 | L = require('leaflet'); 9 | proj4 = require('proj4'); 10 | module.exports = factory(L, proj4); 11 | } else { 12 | // Browser globals 13 | if (typeof window.L === 'undefined' || typeof window.proj4 === 'undefined') 14 | throw 'Leaflet and proj4 must be loaded first'; 15 | factory(window.L, window.proj4); 16 | } 17 | }(function (L, proj4) { 18 | 19 | L.Proj = {}; 20 | 21 | L.Proj._isProj4Obj = function(a) { 22 | return (typeof a.inverse !== 'undefined' && 23 | typeof a.forward !== 'undefined'); 24 | }; 25 | 26 | L.Proj.Projection = L.Class.extend({ 27 | initialize: function(code, def, bounds) { 28 | var isP4 = L.Proj._isProj4Obj(code); 29 | this._proj = isP4 ? code : this._projFromCodeDef(code, def); 30 | this.bounds = isP4 ? def : bounds; 31 | }, 32 | 33 | project: function (latlng) { 34 | var point = this._proj.forward([latlng.lng, latlng.lat]); 35 | return new L.Point(point[0], point[1]); 36 | }, 37 | 38 | unproject: function (point, unbounded) { 39 | var point2 = this._proj.inverse([point.x, point.y]); 40 | return new L.LatLng(point2[1], point2[0], unbounded); 41 | }, 42 | 43 | _projFromCodeDef: function(code, def) { 44 | if (def) { 45 | proj4.defs(code, def); 46 | } else if (proj4.defs[code] === undefined) { 47 | var urn = code.split(':'); 48 | if (urn.length > 3) { 49 | code = urn[urn.length - 3] + ':' + urn[urn.length - 1]; 50 | } 51 | if (proj4.defs[code] === undefined) { 52 | throw 'No projection definition for code ' + code; 53 | } 54 | } 55 | 56 | return proj4(code); 57 | } 58 | }); 59 | 60 | L.Proj.CRS = L.Class.extend({ 61 | includes: L.CRS, 62 | 63 | options: { 64 | transformation: new L.Transformation(1, 0, -1, 0) 65 | }, 66 | 67 | initialize: function(a, b, c) { 68 | var code, 69 | proj, 70 | def, 71 | options; 72 | 73 | if (L.Proj._isProj4Obj(a)) { 74 | proj = a; 75 | code = proj.srsCode; 76 | options = b || {}; 77 | 78 | this.projection = new L.Proj.Projection(proj, options.bounds); 79 | } else { 80 | code = a; 81 | def = b; 82 | options = c || {}; 83 | this.projection = new L.Proj.Projection(code, def, options.bounds); 84 | } 85 | 86 | L.Util.setOptions(this, options); 87 | this.code = code; 88 | this.transformation = this.options.transformation; 89 | 90 | if (this.options.origin) { 91 | this.transformation = 92 | new L.Transformation(1, -this.options.origin[0], 93 | -1, this.options.origin[1]); 94 | } 95 | 96 | if (this.options.scales) { 97 | this._scales = this.options.scales; 98 | } else if (this.options.resolutions) { 99 | this._scales = []; 100 | for (var i = this.options.resolutions.length - 1; i >= 0; i--) { 101 | if (this.options.resolutions[i]) { 102 | this._scales[i] = 1 / this.options.resolutions[i]; 103 | } 104 | } 105 | } 106 | 107 | this.infinite = !this.options.bounds; 108 | 109 | }, 110 | 111 | scale: function(zoom) { 112 | var iZoom = Math.floor(zoom), 113 | baseScale, 114 | nextScale, 115 | scaleDiff, 116 | zDiff; 117 | if (zoom === iZoom) { 118 | return this._scales[zoom]; 119 | } else { 120 | // Non-integer zoom, interpolate 121 | baseScale = this._scales[iZoom]; 122 | nextScale = this._scales[iZoom + 1]; 123 | scaleDiff = nextScale - baseScale; 124 | zDiff = (zoom - iZoom); 125 | return baseScale + scaleDiff * zDiff; 126 | } 127 | }, 128 | 129 | zoom: function(scale) { 130 | // Find closest number in this._scales, down 131 | var downScale = this._closestElement(this._scales, scale), 132 | downZoom = this._scales.indexOf(downScale), 133 | nextScale, 134 | nextZoom, 135 | scaleDiff; 136 | // Check if scale is downScale => return array index 137 | if (scale === downScale) { 138 | return downZoom; 139 | } 140 | // Interpolate 141 | nextZoom = downZoom + 1; 142 | nextScale = this._scales[nextZoom]; 143 | if (nextScale === undefined) { 144 | return Infinity; 145 | } 146 | scaleDiff = nextScale - downScale; 147 | return (scale - downScale) / scaleDiff + downZoom; 148 | }, 149 | 150 | distance: L.CRS.Earth.distance, 151 | 152 | R: L.CRS.Earth.R, 153 | 154 | /* Get the closest lowest element in an array */ 155 | _closestElement: function(array, element) { 156 | var low; 157 | for (var i = array.length; i--;) { 158 | if (array[i] <= element && (low === undefined || low < array[i])) { 159 | low = array[i]; 160 | } 161 | } 162 | return low; 163 | } 164 | }); 165 | 166 | L.Proj.GeoJSON = L.GeoJSON.extend({ 167 | initialize: function(geojson, options) { 168 | this._callLevel = 0; 169 | L.GeoJSON.prototype.initialize.call(this, geojson, options); 170 | }, 171 | 172 | addData: function(geojson) { 173 | var crs; 174 | 175 | if (geojson) { 176 | if (geojson.crs && geojson.crs.type === 'name') { 177 | crs = new L.Proj.CRS(geojson.crs.properties.name); 178 | } else if (geojson.crs && geojson.crs.type) { 179 | crs = new L.Proj.CRS(geojson.crs.type + ':' + geojson.crs.properties.code); 180 | } 181 | 182 | if (crs !== undefined) { 183 | this.options.coordsToLatLng = function(coords) { 184 | var point = L.point(coords[0], coords[1]); 185 | return crs.projection.unproject(point); 186 | }; 187 | } 188 | } 189 | 190 | // Base class' addData might call us recursively, but 191 | // CRS shouldn't be cleared in that case, since CRS applies 192 | // to the whole GeoJSON, inluding sub-features. 193 | this._callLevel++; 194 | try { 195 | L.GeoJSON.prototype.addData.call(this, geojson); 196 | } finally { 197 | this._callLevel--; 198 | if (this._callLevel === 0) { 199 | delete this.options.coordsToLatLng; 200 | } 201 | } 202 | } 203 | }); 204 | 205 | L.Proj.geoJson = function(geojson, options) { 206 | return new L.Proj.GeoJSON(geojson, options); 207 | }; 208 | 209 | L.Proj.ImageOverlay = L.ImageOverlay.extend({ 210 | initialize: function (url, bounds, options) { 211 | L.ImageOverlay.prototype.initialize.call(this, url, null, options); 212 | this._projectedBounds = bounds; 213 | }, 214 | 215 | // Danger ahead: Overriding internal methods in Leaflet. 216 | // Decided to do this rather than making a copy of L.ImageOverlay 217 | // and doing very tiny modifications to it. 218 | // Future will tell if this was wise or not. 219 | _animateZoom: function (event) { 220 | var scale = this._map.getZoomScale(event.zoom); 221 | var northWest = L.point(this._projectedBounds.min.x, this._projectedBounds.max.y); 222 | var offset = this._projectedToNewLayerPoint(northWest, event.zoom, event.center); 223 | 224 | L.DomUtil.setTransform(this._image, offset, scale); 225 | }, 226 | 227 | _reset: function () { 228 | var zoom = this._map.getZoom(); 229 | var pixelOrigin = this._map.getPixelOrigin(); 230 | var bounds = L.bounds( 231 | this._transform(this._projectedBounds.min, zoom)._subtract(pixelOrigin), 232 | this._transform(this._projectedBounds.max, zoom)._subtract(pixelOrigin) 233 | ); 234 | var size = bounds.getSize(); 235 | 236 | L.DomUtil.setPosition(this._image, bounds.min); 237 | this._image.style.width = size.x + 'px'; 238 | this._image.style.height = size.y + 'px'; 239 | }, 240 | 241 | _projectedToNewLayerPoint: function (point, zoom, center) { 242 | var viewHalf = this._map.getSize()._divideBy(2); 243 | var newTopLeft = this._map.project(center, zoom)._subtract(viewHalf)._round(); 244 | var topLeft = newTopLeft.add(this._map._getMapPanePos()); 245 | 246 | return this._transform(point, zoom)._subtract(topLeft); 247 | }, 248 | 249 | _transform: function (point, zoom) { 250 | var crs = this._map.options.crs; 251 | var transformation = crs.transformation; 252 | var scale = crs.scale(zoom); 253 | 254 | return transformation.transform(point, scale); 255 | } 256 | }); 257 | 258 | L.Proj.imageOverlay = function (url, bounds, options) { 259 | return new L.Proj.ImageOverlay(url, bounds, options); 260 | }; 261 | 262 | return L.Proj; 263 | })); 264 | -------------------------------------------------------------------------------- /OSMapsAPI/Leaflet/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | OS Maps API Demo 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 36 |
37 |
38 |

To connect to your mapping API:

39 |
    40 |
  1. Go to the OS Data Hub,
  2. 41 |
  3. Create a project,
  4. 42 |
  5. Add the OS Maps API to your project
  6. 43 |
  7. Copy the project API Key, and enter it into the box above.
  8. 44 |
45 | 46 | Note that this sample will allow you to zoom the map down into Premium data layers. 47 | If your API key only has access to OS OpenData layers then those requests will fail. 48 | 49 |
50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /OSMapsAPI/Leaflet/map.js: -------------------------------------------------------------------------------- 1 | // 2 | // Setup the EPSG:27700 (British National Grid) projection 3 | // 4 | var crs = new L.Proj.CRS( 5 | 'EPSG:27700', 6 | "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.999601 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894 +datum=OSGB36 +units=m +no_defs", 7 | { 8 | transformation: new L.Transformation(1, 238375, -1, 1376256), 9 | resolutions: [896.0, 448.0, 224.0, 112.0, 56.0, 28.0, 14.0, 7.0, 3.5, 1.75, 0.875, 0.4375, 0.21875, 0.109375], 10 | }); 11 | 12 | var map; 13 | function setupLayer() { 14 | if(map) { 15 | map.remove(); 16 | } 17 | 18 | var key = document.getElementById('keyInput').value; 19 | var message = document.getElementById('message'); 20 | var instructions = document.getElementById('instructions'); 21 | var style = document.getElementById('style').value; 22 | 23 | if(!key) { 24 | message.classList.add("warning"); 25 | message.textContent = 'To view the map, please enter a valid API key.'; 26 | instructions.classList.remove("hidden"); 27 | return; 28 | } 29 | message.classList.remove("warning"); 30 | message.textContent = 'To view the map, please enter a valid API key.'; 31 | instructions.classList.add("hidden"); 32 | 33 | // Set up default view options for EPSG:3857 34 | var tileMatrix = 'EPSG:3857'; 35 | var mapOptions = { 36 | maxZoom: 20, 37 | minZoom: 7, 38 | center: [51.507222, -0.1275], 39 | maxBounds: [[49, -6.5],[61, 2.3]], 40 | zoom: 10 41 | }; 42 | 43 | // Make some specific changes relevant to EPSG:27700 only 44 | if(style.indexOf('27700') !== -1) { 45 | tileMatrix = 'EPSG:27700'; 46 | mapOptions.crs = crs; 47 | mapOptions.maxZoom = 13; 48 | mapOptions.minZoom = 0; 49 | mapOptions.zoom = 4; 50 | } 51 | 52 | // Set up the main url parameters 53 | var url = 'https://api.os.uk/maps/raster/v1/wmts'; 54 | var parameters = { 55 | key: key, 56 | tileMatrixSet: encodeURI(tileMatrix), 57 | version: '1.0.0', 58 | style: 'default', 59 | layer: encodeURI(style), 60 | service: 'WMTS', 61 | request: 'GetTile', 62 | tileCol: '{x}', 63 | tileRow: '{y}', 64 | tileMatrix: '{z}', 65 | }; 66 | let parameterString = Object.keys(parameters) 67 | .map(function(key) { return key + '=' + parameters[key]; }) 68 | .join('&'); 69 | var layer = new L.TileLayer( 70 | url + '?' + parameterString, 71 | { 72 | // Add appropriate attribution 73 | attribution: '© Ordnance Survey', 74 | maxZoom: 20 75 | } 76 | ); 77 | 78 | // Add error handling in case the tile load fails 79 | layer.on('tileerror', function(event) { 80 | message.classList.add("warning"); 81 | message.textContent = 'Could not connect to the API. Ensure you are entering a project API key for a project that contains the OS Maps API'; 82 | instructions.classList.remove("hidden"); 83 | }); 84 | // Remove warning and hide instructions on tile load. This is so tileerror message does not persist when returning to a valid zoom level 85 | layer.on('tileloadstart', function(event) { 86 | message.classList.remove("warning"); 87 | message.textContent = 'To view the map, please enter a valid API key.'; 88 | instructions.classList.add("hidden"); 89 | }); 90 | mapOptions.layers = layer; 91 | // Create the map object and connect it to the 'map' element in the html 92 | map = L.map('map', mapOptions); 93 | } 94 | -------------------------------------------------------------------------------- /OSMapsAPI/OpenLayers/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | OS Maps API Demo 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 38 |
39 |
40 |

To connect to your mapping API:

41 |
    42 |
  1. Go to the OS Data Hub,
  2. 43 |
  3. Create a project,
  4. 44 |
  5. Add the OS Maps API to your project
  6. 45 |
  7. Copy the project API Key, and enter it into the box above.
  8. 46 |
47 | 48 | Note that this sample will allow you to zoom the map down into Premium data layers. 49 | If your API key only has access to OS OpenData layers then those requests will fail. 50 | 51 |
52 | 53 | 54 | -------------------------------------------------------------------------------- /OSMapsAPI/OpenLayers/map.js: -------------------------------------------------------------------------------- 1 | // 2 | // Setup the EPSG:27700 (British National Grid) projection 3 | // 4 | proj4.defs("EPSG:27700", "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.999601 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894 +datum=OSGB36 +units=m +no_defs"); 5 | ol.proj.proj4.register(proj4); 6 | var bng = ol.proj.get('EPSG:27700'); 7 | bng.setExtent([-238375.0,0,700000,1300000]); 8 | 9 | var map; 10 | function setupLayer() { 11 | if(map) { 12 | map.setTarget(null); 13 | } 14 | 15 | var key = document.getElementById('keyInput').value; 16 | var message = document.getElementById('message'); 17 | var instructions = document.getElementById('instructions'); 18 | var style = document.getElementById('style'); 19 | 20 | if(!key) { 21 | message.classList.add("warning"); 22 | message.textContent = 'To view the map, please enter a valid API key.'; 23 | instructions.classList.remove("hidden"); 24 | return; 25 | } 26 | message.classList.remove("warning"); 27 | message.textContent = 'To view the map, please enter a valid API key.'; 28 | instructions.classList.add("hidden"); 29 | 30 | var url = 'https://api.os.uk/maps/raster/v1/wmts?service=wmts&request=GetCapabilities&key=' + key; 31 | fetch(url) 32 | .then(response => response.text()) 33 | .then(text => { 34 | // OpenLayers allows us to get the service information directly from the GetCapabilites document instead of hard coding it. 35 | var parser = new ol.format.WMTSCapabilities(); 36 | var result = parser.read(text); 37 | 38 | var options = ol.source.WMTS.optionsFromCapabilities(result, { 39 | layer: style.value 40 | }); 41 | if(!options) { 42 | message.classList.add("warning"); 43 | message.textContent = 'Failed to find the selected mapping style! Try selecting an alternative mapping style.'; 44 | instructions.classList.remove("hidden"); 45 | return; 46 | } 47 | // Set correct attribution for the data layer. 48 | options.attributions = '© Ordnance Survey'; 49 | 50 | var source = new ol.source.WMTS(options); 51 | var layer = new ol.layer.Tile({ source: source }); 52 | 53 | // Error handling should the tiles fail to load. This can be extended to catch specific errors. 54 | source.on('tileloaderror', function(event) { 55 | message.classList.add("warning"); 56 | message.textContent = 'Could not load a map tile. You may be attempting to access Premium data with an API key that only has access to OS OpenData.'; 57 | instructions.classList.remove("hidden"); 58 | }); 59 | 60 | // Set up the view options, center of map, zoom level and projection information 61 | var viewOptions = { 62 | projection: options.projection, 63 | center: [-121099, 7161610], 64 | resolutions: options.tileGrid.getResolutions(), 65 | zoom: 8 66 | }; 67 | 68 | // If we are using a layer in British National Grid (EPSG:27700), then tranform the center point from 69 | // EPSG:3857 into BNG, and adjust the zoom level. 70 | if(options.projection === bng) { 71 | var point = new ol.geom.Point(viewOptions.center); 72 | point.transform('EPSG:3857', bng); 73 | viewOptions.center = point.getCoordinates(); 74 | viewOptions.zoom = 3; 75 | } 76 | 77 | // Create the map object and connect it to the 'map' element in the html 78 | map = new ol.Map({ 79 | target: 'map', 80 | layers: [layer], 81 | view: new ol.View(viewOptions) 82 | }); 83 | 84 | // Expand the attribution control, so that the the copyright message is visible 85 | map.getControls().forEach(control => { 86 | if(control instanceof ol.control.Attribution) { 87 | control.setCollapsed(false); 88 | } 89 | }); 90 | }) 91 | .catch(error => { 92 | message.classList.add("warning"); 93 | message.textContent = 'Got an error from GetCapabilities! Check your network connection, or try another API key.'; 94 | instructions.classList.remove("hidden"); 95 | }); 96 | } 97 | -------------------------------------------------------------------------------- /OSMapsAPI/style.css: -------------------------------------------------------------------------------- 1 | /* Set the document to use flexbox layout */ 2 | body { 3 | margin: 0; 4 | height: 100vh; 5 | display: flex; 6 | flex-direction: column; 7 | } 8 | /* ensure the map fills as much of the screen as possible */ 9 | #map { 10 | flex: 1 0 auto; 11 | } 12 | 13 | 14 | /* 15 | NOTE: 16 | The CSS following this comment is for *styling purposes only* and is not essential for this demo to run 17 | - strip out the styles below if you want cleaner code 18 | */ 19 | 20 | body { 21 | font-family: "Source Sans Pro", sans-serif; 22 | font-size:16px; 23 | color: #666666; 24 | min-width: 480px; 25 | } 26 | 27 | 28 | h1{ 29 | font-size: 32px; 30 | font-weight: normal; 31 | line-height: 1.4; 32 | letter-spacing: 0.7px; 33 | margin: 0 0 10px; 34 | color: #453c90; 35 | } 36 | 37 | p{ 38 | margin: 10px 0; 39 | } 40 | 41 | b{ 42 | font-weight:600; 43 | } 44 | label{ 45 | line-height: 1.7em; 46 | font-weight: 600; 47 | display: flex; 48 | flex-direction: column; 49 | } 50 | input, button{ 51 | font-size: 16px; 52 | 53 | } 54 | 55 | input[type="text"]{ 56 | height: 24px; 57 | border-radius: 3px 0 0 3px; 58 | border: solid 1px #dddddd; 59 | border-right: 0; 60 | padding: 12px 16px; 61 | background-color: #f5f5f5; 62 | color: #333333; 63 | font-size: 16px; 64 | margin:0; 65 | } 66 | 67 | select { 68 | height: 50px; 69 | background-color: #f5f5f5; 70 | color: #333333; 71 | font-size: 16px; 72 | padding: 12px 16px; 73 | border: 0; 74 | border-radius: 0; 75 | outline: solid 1px #dddddd; 76 | outline-offset: -1px; 77 | } 78 | 79 | button{ 80 | height: 50px; 81 | border-radius: 0 3px 3px 0; 82 | background-color: #453c90; 83 | color: #fff; 84 | font-family: "Source Sans Pro", sans-serif; 85 | padding: 4px 20px; 86 | border:0; 87 | 88 | } 89 | 90 | 91 | #header{ 92 | text-align: center; 93 | background-color: #ffffff; 94 | padding: 20px; 95 | border-bottom: 1px solid #dddddd; 96 | box-shadow: 0 2px 4px 1px rgba(0, 0, 0, 0.4); 97 | z-index:1000 98 | 99 | } 100 | 101 | 102 | #instructions{ 103 | position: fixed; 104 | background-color: #fff; 105 | padding: 10px 20px; 106 | top: 280px; 107 | width: 300px; 108 | left: calc(50% - 160px); 109 | z-index: 100; 110 | border-radius: 3px; 111 | box-shadow: 0 1px 4px 1px rgba(0, 0, 0, 0.4); 112 | } 113 | 114 | .hidden{ 115 | display:none; 116 | } 117 | .warning{ 118 | color:#d40058; 119 | font-weight:400; 120 | } 121 | form{ 122 | margin-top: 20px; 123 | text-align: left; 124 | display: flex; 125 | align-items: flex-end; 126 | } 127 | 128 | .stretch { 129 | flex: 1 0 auto 130 | } 131 | -------------------------------------------------------------------------------- /OSVectorTileAPI/ArcGIS/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | OS Vector Tile API Demo 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 22 |
23 |
24 |

To connect to your mapping API:

25 |
    26 |
  1. Go to the OS Data Hub,
  2. 27 |
  3. Create a project,
  4. 28 |
  5. Add the OS Vector Tile API to your project
  6. 29 |
  7. Copy the project API Key, and enter it into the box above.
  8. 30 |
31 | 32 | Note that this sample will allow you to zoom the map down into Premium data layers. 33 | If your API key only has access to OS OpenData layers then those requests will fail. 34 | 35 |
36 | 37 | 38 | -------------------------------------------------------------------------------- /OSVectorTileAPI/ArcGIS/map.js: -------------------------------------------------------------------------------- 1 | require( 2 | [ 3 | "esri/Map", 4 | "esri/views/MapView", 5 | "esri/layers/VectorTileLayer", 6 | "esri/geometry/Point", 7 | "esri/geometry/SpatialReference", 8 | "esri/config", 9 | "dojo/domReady!" 10 | ], 11 | function(Map, MapView, VectorTileLayer, Point, SpatialReference, esriConfig) { 12 | 13 | var vectorLayerUrl = "https://api.os.uk/maps/vector/v1/vts"; 14 | var key; 15 | 16 | // ArcGIS JS reads all required information directly from the main service URL 17 | esriConfig.request.interceptors.push({ 18 | urls: vectorLayerUrl, 19 | before: function(params) { 20 | if(!params.requestOptions.query) { 21 | params.requestOptions.query = {}; 22 | } 23 | if(params.url.indexOf("key=") === -1) { 24 | params.requestOptions.query.key = key; 25 | } 26 | } 27 | }); 28 | 29 | var map = new Map(); 30 | 31 | // Setting up the map view with default center, spatial reference, scale and zoom constraints 32 | new MapView({ 33 | map: map, 34 | container: "map", 35 | center: new Point({ 36 | x: 425168, 37 | y: 563779, 38 | spatialReference: new SpatialReference({wkid: 27700}) 39 | }), 40 | scale: 250000, 41 | constraints: { 42 | minScale: 390, 43 | maxScale: 1600000 44 | } 45 | }); 46 | 47 | window.setupLayer = function() { 48 | map.layers.removeAll(); 49 | 50 | // This sets up the API key input at the start 51 | key = document.getElementById('keyInput').value; 52 | var message = document.getElementById('message'); 53 | var instructions = document.getElementById('instructions'); 54 | 55 | if(!key) { 56 | message.classList.add("warning"); 57 | message.textContent = 'To view the map, please enter a valid API key.'; 58 | instructions.classList.remove("hidden"); 59 | return; 60 | } 61 | message.classList.remove("warning"); 62 | message.textContent = 'To view the map, please enter a valid API key.'; 63 | instructions.classList.add("hidden"); 64 | 65 | // This sets up the layer for the map 66 | var tileLayer = new VectorTileLayer({ 67 | url: vectorLayerUrl, 68 | copyright: '© Ordnance Survey' 69 | }); 70 | 71 | tileLayer.when(success => {}, error => { 72 | message.classList.add("warning"); 73 | message.textContent = 'Could not connect to the API. Ensure you are entering a project API key for a project that contains the OS Vector Tile API'; 74 | instructions.classList.remove("hidden"); 75 | }); 76 | 77 | map.layers.add(tileLayer); 78 | }; 79 | } 80 | ); 81 | -------------------------------------------------------------------------------- /OSVectorTileAPI/Leaflet/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | OS Vector Tile API Demo 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 25 |
26 |
27 |

To connect to your mapping API:

28 |
    29 |
  1. Go to the OS Data Hub,
  2. 30 |
  3. Create a project,
  4. 31 |
  5. Add the OS Vector Tile API to your project
  6. 32 |
  7. Copy the project API Key, and enter it into the box above.
  8. 33 |
34 |
35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /OSVectorTileAPI/Leaflet/map.js: -------------------------------------------------------------------------------- 1 | var map; 2 | 3 | function setupLayer() { 4 | if(map) { 5 | map.remove(); 6 | map = null; 7 | } 8 | 9 | // Setting up the initial API key input 10 | var key = document.getElementById('keyInput').value; 11 | var message = document.getElementById('message'); 12 | var instructions = document.getElementById('instructions'); 13 | 14 | if(!key) { 15 | message.classList.add("warning"); 16 | message.textContent = 'To view the map, please enter a valid API key.'; 17 | instructions.classList.remove("hidden"); 18 | return; 19 | } 20 | message.classList.remove("warning"); 21 | message.textContent = 'To view the map, please enter a valid API key.'; 22 | instructions.classList.add("hidden"); 23 | 24 | // This sets up the actual VTS layer 25 | // Center coordinates are defined in EPSG:3857 lon/lat and we are asking for srs=3857 in the "transformRequest" 26 | var serviceUrl = "https://api.os.uk/maps/vector/v1/vts" 27 | var map = L.map('map', { 28 | maxZoom: 15 29 | }).setView([54.968004, -1.608411], 9); 30 | var gl = L.mapboxGL({ 31 | accessToken: 'no-token', 32 | style: serviceUrl + '/resources/styles', 33 | transformRequest: url => { 34 | if(url.indexOf('?key=') === -1) { 35 | url += '?key=' + key; 36 | } 37 | url += '&srs=3857'; 38 | return { 39 | url: url 40 | } 41 | } 42 | }).addTo(map); 43 | 44 | map.attributionControl.addAttribution('© Ordnance Survey'); 45 | 46 | gl.getMapboxMap().on('error', error => { 47 | console.log(error); 48 | message.classList.add("warning"); 49 | message.textContent = 'Could not connect to the API. Ensure you are entering a project API key for a project that contains the OS Vector Tile API'; 50 | instructions.classList.remove("hidden"); 51 | }); 52 | } 53 | -------------------------------------------------------------------------------- /OSVectorTileAPI/MapboxGLJS/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | OS Vector Tile API Demo 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 22 |
23 |
24 |

To connect to your mapping API:

25 |
    26 |
  1. Go to the OS Data Hub,
  2. 27 |
  3. Create a project,
  4. 28 |
  5. Add the OS Vector Tile API to your project
  6. 29 |
  7. Copy the project API Key, and enter it into the box above.
  8. 30 |
31 |
32 | 33 | 34 | -------------------------------------------------------------------------------- /OSVectorTileAPI/MapboxGLJS/map.js: -------------------------------------------------------------------------------- 1 | var map; 2 | 3 | function setupLayer() { 4 | if(map) { 5 | map.remove(); 6 | map = null; 7 | } 8 | 9 | // Setting up the initial API key input 10 | var key = document.getElementById('keyInput').value; 11 | var message = document.getElementById('message'); 12 | var instructions = document.getElementById('instructions'); 13 | 14 | if(!key) { 15 | message.classList.add("warning"); 16 | message.textContent = 'To view the map, please enter a valid API key.'; 17 | instructions.classList.remove("hidden"); 18 | return; 19 | } 20 | message.classList.remove("warning"); 21 | message.textContent = 'To view the map, please enter a valid API key.'; 22 | instructions.classList.add("hidden"); 23 | 24 | // This sets up the actual VTS layer 25 | // Center coordinates are defined in EPSG:3857 lon/lat and we are asking for srs=3857 in the "transformRequest" 26 | var serviceUrl = "https://api.os.uk/maps/vector/v1/vts"; 27 | map = new mapboxgl.Map({ 28 | container: 'map', 29 | style: serviceUrl + '/resources/styles?key=' + key, 30 | center: [-1.608411, 54.968004], 31 | zoom: 9, 32 | maxZoom: 15, 33 | transformRequest: url => { 34 | url += '&srs=3857'; 35 | return { 36 | url: url 37 | } 38 | } 39 | }); 40 | 41 | map.addControl(new mapboxgl.AttributionControl({ 42 | customAttribution: '© Ordnance Survey' 43 | })); 44 | 45 | // Add zoom and rotation controls to the map. 46 | map.addControl(new mapboxgl.NavigationControl()); 47 | 48 | map.on('error', error => { 49 | console.log(error); 50 | message.classList.add("warning"); 51 | message.textContent = 'Could not connect to the API. Ensure you are entering a project API key for a project that contains the OS Vector Tile API'; 52 | instructions.classList.remove("hidden"); 53 | }); 54 | } 55 | -------------------------------------------------------------------------------- /OSVectorTileAPI/OpenLayers/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | OS Vector Tile API Demo 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 24 |
25 |
26 |

To connect to your mapping API:

27 |
    28 |
  1. Go to the OS Data Hub,
  2. 29 |
  3. Create a project,
  4. 30 |
  5. Add the OS Vector Tile API to your project
  6. 31 |
  7. Copy the project API Key, and enter it into the box above.
  8. 32 |
33 | 34 | Note that this sample will allow you to zoom the map down into Premium data layers. 35 | If your API key only has access to OS OpenData layers then those requests will fail. 36 | 37 |
38 | 39 | 40 | -------------------------------------------------------------------------------- /OSVectorTileAPI/OpenLayers/map.js: -------------------------------------------------------------------------------- 1 | // 2 | // Setup the EPSG:27700 (British National Grid) projection 3 | // 4 | proj4.defs("EPSG:27700", "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.999601 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894 +datum=OSGB36 +units=m +no_defs"); 5 | ol.proj.proj4.register(proj4); 6 | var bng = ol.proj.get('EPSG:27700'); 7 | bng.setExtent([-238375.0,0,700000,1300000]); 8 | 9 | var map; 10 | var url = 'https://api.os.uk/maps/vector/v1/vts'; 11 | 12 | function setupLayer() { 13 | if(map) { 14 | map.setTarget(null); 15 | } 16 | 17 | var key = document.getElementById('keyInput').value; 18 | var message = document.getElementById('message'); 19 | var instructions = document.getElementById('instructions'); 20 | 21 | if(!key) { 22 | message.classList.add("warning"); 23 | message.textContent = 'To view the map, please enter a valid API key.'; 24 | instructions.classList.remove("hidden"); 25 | return; 26 | } 27 | message.classList.remove("warning"); 28 | message.textContent = 'To view the map, please enter a valid API key.'; 29 | instructions.classList.add("hidden"); 30 | 31 | // This example requires the style URL (The default one in this case). From the returned style.JSON it will 32 | // derive the URLS needed for the Capabilities URL, Service URL, Sprite.JSON URL/Sprite.PNG URL 33 | var styleUrl = fetch(url + '/resources/styles?key=' + key).then(response => response.json()); 34 | 35 | Promise.resolve(styleUrl) 36 | .then(result => { 37 | var styleJson = result; 38 | 39 | // Read URLS for sprites.json and sprites.png from styles.json 40 | var spritesJsonUrl = fetch(styleJson.sprite.replace("?key=", ".json?key=")).then(response => response.json()); 41 | var spritesPngUrl = styleJson.sprite.replace("?key=", ".png?key="); 42 | 43 | // Fetch the service JSON 44 | var serviceUrl = fetch(styleJson.sources.esri.url).then(response => response.json()); 45 | 46 | Promise.all([serviceUrl, spritesJsonUrl]).then(results => { 47 | 48 | var serviceJson = results[0]; 49 | var spritesJson = results[1]; 50 | 51 | // Read the tile grid dimensions from the service.json 52 | var extent = [serviceJson.fullExtent.xmin, serviceJson.fullExtent.ymin, serviceJson.fullExtent.xmax, serviceJson.fullExtent.ymax]; 53 | var origin = [serviceJson.tileInfo.origin.x, serviceJson.tileInfo.origin.y]; 54 | var resolutions = serviceJson.tileInfo.lods.map(l => l.resolution).slice(0, 16); 55 | var tileSize = serviceJson.tileInfo.rows; 56 | var tiles = serviceJson.tiles[0]; 57 | var wkid = serviceJson.tileInfo.spatialReference.latestWkid; 58 | 59 | // Set up the options required for the VTS source in OpenLayers 60 | var options = { 61 | format: new ol.format.MVT(), 62 | url: tiles, 63 | attributions: '© Ordnance Survey', 64 | projection: 'EPSG:' + wkid, 65 | tileGrid: new ol.tilegrid.TileGrid({ 66 | extent, 67 | origin, 68 | resolutions, 69 | tileSize 70 | }) 71 | }; 72 | var source = new ol.source.VectorTile(options); 73 | var layer = new ol.layer.VectorTile({ source: source }); 74 | 75 | // ol-mapbox-style doesn't like the 0 opacity for the icon colours, so we replace them here 76 | styleJson.layers.forEach(layer => { 77 | if(layer.paint && layer.paint['icon-color']) { 78 | layer.paint['icon-color'] = layer.paint['icon-color'].replace(',0)', ',1)'); 79 | } 80 | }); 81 | 82 | // Setup the styling for the vector tile layer. 83 | // We use the default style fetched in the promise here, though "style" can be any JSON VTS style 84 | olms.stylefunction(layer, styleJson, 'esri', resolutions, spritesJson, spritesPngUrl); 85 | 86 | source.on('tileloaderror', function(event) { 87 | message.classList.add("warning"); 88 | message.textContent = 'Could not connect to the API. Ensure you are entering a project API key for a project that contains the OS Vector Tile API'; 89 | }); 90 | 91 | // Set the default center of the map view 92 | var center = [-121099, 7161610]; 93 | if(wkid === 27700) { 94 | var point = new ol.geom.Point(center); 95 | point.transform('EPSG:3857', 'EPSG:27700'); 96 | center = point.getCoordinates(); 97 | } 98 | 99 | // Create the map object and connect it to the 'map' element in the html 100 | map = new ol.Map({ 101 | target: 'map', 102 | layers: [layer], 103 | view: new ol.View({ 104 | projection: 'EPSG:' + wkid, 105 | center: center, 106 | zoom: Math.floor(resolutions.length / 2) 107 | }) 108 | }); 109 | // Expand the attribution control, so that the the copyright message is visible 110 | map.getControls().forEach(control => { 111 | if(control instanceof ol.control.Attribution) { 112 | control.setCollapsed(false); 113 | } 114 | }); 115 | }) 116 | 117 | }) 118 | .catch(error => { 119 | message.classList.add("warning"); 120 | message.textContent = 'Could not connect to the API. Ensure you are entering a project API key for a project that contains the OS Vector Tile API'; 121 | instructions.classList.remove("hidden"); 122 | }); 123 | } 124 | -------------------------------------------------------------------------------- /OSVectorTileAPI/OpenLayers/ol-mapbox-style/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2016-present ol-mapbox-style contributors 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this 7 | list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 14 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 17 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 19 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 20 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 21 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | -------------------------------------------------------------------------------- /OSVectorTileAPI/StylingVTS/Adapting/README.md: -------------------------------------------------------------------------------- 1 | # Adapting the pre-defined style 2 | 3 | This method is particularly useful if you are aiming to highlight a feature in the existing style or wish to change a small number of elements. Since the method is manipulating the existing style on-the-fly it is taking browser resources to do so and may feel slow on low spec devices depending on the amount of change. 4 | 5 | For this example we have changed the colour of all roads to bright red. 6 | 7 | * In our original demo code we are already changing the styling due to a quirk in the styling package for OpenLayers. 8 | ``` 9 | style.layers.forEach(layer => { 10 | if(layer.paint && layer.paint['icon-color']) { 11 | layer.paint['icon-color'] = layer.paint['icon-color'].replace(',0)', ',1)'); 12 | } 13 | }); 14 | ``` 15 | This code loops through all layers defined in the style and makes some minor changes. All we need to do is adapt this code to allow us to change the colour of the roads. 16 | 17 | * To make our style changes we include the following directly before the final `});` : 18 | ``` 19 | if (layer['source-layer'].startsWith('road')) { 20 | layer.paint['line-color'] = '#FF0000'; 21 | } 22 | ``` 23 | This will check each layer source name to see whether it is beginning with "road". If the source layer begins with "road" the colour of the line will be changed to #FF0000 (bright red). 24 | 25 | This method works well if you are making small changes to a defined style. 26 | 27 | If you want to make complex changes or indeed create your own style this method can quickly become cumbersome and require a lot of code. In these cases you may find it easier to create your own style file or to include the JSON for the style directly in the code. -------------------------------------------------------------------------------- /OSVectorTileAPI/StylingVTS/Adapting/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | OS Vector Tile API Demo 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 24 |
25 |
26 |

To connect to your mapping API:

27 |
    28 |
  1. Go to the OS Data Hub,
  2. 29 |
  3. Create a project,
  4. 30 |
  5. Add the OS Vector Tile API to your project
  6. 31 |
  7. Copy the project API Key, and enter it into the box above.
  8. 32 |
33 | 34 | Note that this sample will allow you to zoom the map down into Premium data layers. 35 | If your API key only has access to OS OpenData layers then those requests will fail. 36 | 37 |
38 | 39 | 40 | -------------------------------------------------------------------------------- /OSVectorTileAPI/StylingVTS/Adapting/map.js: -------------------------------------------------------------------------------- 1 | // 2 | // Setup the EPSG:27700 (British National Grid) projection 3 | // 4 | proj4.defs("EPSG:27700", "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.999601 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894 +datum=OSGB36 +units=m +no_defs"); 5 | ol.proj.proj4.register(proj4); 6 | var bng = ol.proj.get('EPSG:27700'); 7 | bng.setExtent([-238375.0,0,700000,1300000]); 8 | 9 | var map; 10 | var serviceUrl = "https://api.os.uk/maps/vector/v1/vts"; 11 | 12 | function setupLayer() { 13 | if(map) { 14 | map.setTarget(null); 15 | } 16 | 17 | var key = document.getElementById('keyInput').value; 18 | var message = document.getElementById('message'); 19 | var instructions = document.getElementById('instructions'); 20 | 21 | if(!key) { 22 | message.classList.add("warning"); 23 | message.textContent = 'To view the map, please enter a valid API key.'; 24 | instructions.classList.remove("hidden"); 25 | return; 26 | } 27 | message.classList.remove("warning"); 28 | message.textContent = 'To view the map, please enter a valid API key.'; 29 | instructions.classList.add("hidden"); 30 | 31 | // This example requires the main Capabilities url, the style (our default one in this case), and due to the 32 | // style elements used in the the default style we also need the sprite file. 33 | // If you define your own style you may only need the main Capabilities url 34 | var capabilityPromise = fetch(serviceUrl + '?key=' + key).then(response => response.json()); 35 | var stylePromise = fetch(serviceUrl + '/resources/styles?key=' + key).then(response => response.json()); 36 | var spritePromise = fetch(serviceUrl + '/resources/sprites/sprite.json?key=' + key).then(response => response.json()); 37 | var spriteImageUrl = serviceUrl + '/resources/sprites/sprite.png?key=' + key; 38 | 39 | Promise.all([capabilityPromise, stylePromise, spritePromise]) 40 | .then(results => { 41 | var service = results[0]; 42 | var style = results[1]; 43 | var sprite = results[2]; 44 | 45 | // Read the tile grid dimensions from the service meta-data 46 | var extent = [service.fullExtent.xmin, service.fullExtent.ymin, service.fullExtent.xmax, service.fullExtent.ymax]; 47 | var origin = [service.tileInfo.origin.x, service.tileInfo.origin.y]; 48 | var resolutions = service.tileInfo.lods.map(l => l.resolution).slice(0, 16); 49 | var tileSize = service.tileInfo.rows; 50 | var tiles = service.tiles[0]; 51 | var wkid = service.tileInfo.spatialReference.latestWkid; 52 | 53 | // Set up the options required for the VTS source in OpenLayers 54 | var options = { 55 | format: new ol.format.MVT(), 56 | url: tiles, 57 | attributions: '© Ordnance Survey', 58 | projection: 'EPSG:' + wkid, 59 | tileGrid: new ol.tilegrid.TileGrid({ 60 | extent, 61 | origin, 62 | resolutions, 63 | tileSize 64 | }) 65 | }; 66 | var source = new ol.source.VectorTile(options); 67 | var layer = new ol.layer.VectorTile({ source: source }); 68 | 69 | // ol-mapbox-style doesn't like the 0 opacity for the icon colours, so we replace them here 70 | style.layers.forEach(layer => { 71 | if(layer.paint && layer.paint['icon-color']) { 72 | layer.paint['icon-color'] = layer.paint['icon-color'].replace(',0)', ',1)'); 73 | } 74 | // Customise the road features, painting them red 75 | if (layer['source-layer'].startsWith('road')) { 76 | layer.paint['line-color'] = '#FF0000'; 77 | } 78 | }); 79 | 80 | // Setup the styling for the vector tile layer. 81 | // We use the default style fetched in the promise here, though "style" can be any JSON VTS style 82 | olms.stylefunction(layer, style, 'esri', resolutions, sprite, spriteImageUrl); 83 | 84 | source.on('tileloaderror', function(event) { 85 | message.classList.add("warning"); 86 | message.textContent = 'Could not load a map tile. You may be attempting to access Premium data with an API key that only has access to OS OpenData.'; 87 | instructions.classList.remove("hidden"); 88 | }); 89 | 90 | // Set the default center of the map view 91 | var center = [-121099, 7161610]; 92 | if(wkid === 27700) { 93 | var point = new ol.geom.Point(center); 94 | point.transform('EPSG:3857', 'EPSG:27700'); 95 | center = point.getCoordinates(); 96 | } 97 | 98 | // Create the map object and connect it to the 'map' element in the html 99 | map = new ol.Map({ 100 | target: 'map', 101 | layers: [layer], 102 | view: new ol.View({ 103 | projection: 'EPSG:' + wkid, 104 | center: center, 105 | zoom: 7 106 | }) 107 | }); 108 | // Expand the attribution control, so that the the copyright message is visible 109 | map.getControls().forEach(control => { 110 | if(control instanceof ol.control.Attribution) { 111 | control.setCollapsed(false); 112 | } 113 | }); 114 | }) 115 | .catch(error => { 116 | message.classList.add("warning"); 117 | message.textContent = 'Could not connect to the API. Ensure you are entering a project API key for a project that contains the OS Vector Tile API'; 118 | instructions.classList.remove("hidden"); 119 | }); 120 | } 121 | -------------------------------------------------------------------------------- /OSVectorTileAPI/StylingVTS/InCode/README.md: -------------------------------------------------------------------------------- 1 | # Creating your own style within the code 2 | 3 | Especially suited to cases where you only require a small number of available features to be displayed. For example only buildings or (as in our example) national parks. There is no hard and fast rule when to use this method or when to use a separate file for the style, this is largely personal preference. 4 | 5 | For this example we will only load the styles relating to the national parks and a very faint representation of the landmass of GB. 6 | 7 | * We remove the line beginning with `var promise2 =` and remove `promise2, ` from the following section: 8 | ``` 9 | Promise.all([promise1, promise2, promise3]) 10 | ``` 11 | 12 | * We replace `var style = results[1];` with: 13 | ``` 14 | var style = {}; 15 | ``` 16 | This disables the automatic loading of the pre-defined style and sets up our in-line style variable. 17 | 18 | * Between the `{}` of the `var style = {};` we have just inserted we must now build the style JSON. 19 | We start with: 20 | ``` 21 | "version": 8, 22 | "sprite": "https://api.os.uk/maps/vector/v1/vts/resources/sprites/sprite", 23 | "glyphs": "https://api.os.uk/maps/vector/v1/vts/resources/fonts/{fontstack}/{range}.pbf", 24 | "sources": { 25 | "esri": { 26 | "type": "vector", 27 | "url": "https://api.os.uk/maps/vector/v1/vts/" 28 | } 29 | }, 30 | "layers": [] 31 | ``` 32 | This is identical to the starting definition of the pre-defined style. We leave the version number as it is when we check the original style file. In our current case this is 8. 33 | "sprite" and "glyphs" are design elements (symbol collections and text typeface). If you have your own this is where you would replace ours. For our demo we will continue to include the pre-defined ones. 34 | "sources" describes the source of the service and is best left as it currently is. 35 | Our main focus will be on the "layers" section. 36 | 37 | * Between the `[]` of `"layers": []` we can now include the various elements we want to style. 38 | To demonstrate this let's add the background colour for GB: 39 | ``` 40 | { 41 | "id": "OS Open Zoomstack - Road/land", 42 | "type": "fill", 43 | "source": "esri", 44 | "source-layer": "land", 45 | "layout": {}, 46 | "paint": { 47 | "fill-color": "#fefefe", 48 | "fill-outline-color": "#fefefe" 49 | } 50 | } 51 | ``` 52 | This will give GB a very faint eggshell white background. 53 | 54 | * We add the remaining layers and their definitions in the same manner. Each individual section as described above is separated with a comma. Here is our full example for the "layers" attribute: 55 | ``` 56 | "layers": [ 57 | { 58 | "id": "OS Open Zoomstack - Road/land", 59 | "type": "fill", 60 | "source": "esri", 61 | "source-layer": "land", 62 | "layout": {}, 63 | "paint": { 64 | "fill-color": "#fefefe", 65 | "fill-outline-color": "#fefefe" 66 | } 67 | }, 68 | { 69 | "id": "OS Open Zoomstack - Road/national_parks", 70 | "type": "fill", 71 | "source": "esri", 72 | "source-layer": "national_parks", 73 | "maxzoom": 11.85, 74 | "layout": {}, 75 | "paint": { 76 | "fill-color": "#E5F5CC", 77 | "fill-opacity": 0.5 78 | } 79 | }, 80 | { 81 | "id": "OS Open Zoomstack - Road/national parks", 82 | "type": "symbol", 83 | "source": "esri", 84 | "source-layer": "national parks", 85 | "minzoom": 6.53, 86 | "layout": { 87 | "icon-image": "OS Open Zoomstack - Road/national parks", 88 | "icon-allow-overlap": true, 89 | "text-font": [ 90 | "Arial Bold" 91 | ], 92 | "text-size": 10.6667, 93 | "text-anchor": "center", 94 | "text-field": "{_name}", 95 | "text-optional": true 96 | }, 97 | "paint": { 98 | "icon-color": "rgba(240,240,240,0)", 99 | "text-color": "#44913B", 100 | "text-halo-color": "#F4F4EE", 101 | "text-halo-width": 1.51181 102 | } 103 | } 104 | ] 105 | ``` 106 | This will provide the faint background for GB and also display national parks and their labels in the same style of the original style. 107 | 108 | * Finally we replace `var sprite = results[2];` with `var sprite = results[1];`, this is due to us removing one argument from the promise statement earlier. 109 | 110 | * To ensure the demo opens in an area where we have national parks we change the center from `var center = [-121099, 7161610];` to `var center = [-343282, 7259502];`. 111 | 112 | While you could change the style on-the-fly as in the very first example, this method is a little easier to maintain. If for some reason the style we pre-define changes it will not have any impact on your styling as you have "hard-coded" the style. -------------------------------------------------------------------------------- /OSVectorTileAPI/StylingVTS/InCode/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | OS Vector Tile API Demo 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 24 |
25 |
26 |

To connect to your mapping API:

27 |
    28 |
  1. Go to the OS Data Hub,
  2. 29 |
  3. Create a project,
  4. 30 |
  5. Add the OS Vector Tile API to your project
  6. 31 |
  7. Copy the project API Key, and enter it into the box above.
  8. 32 |
33 | 34 | Note that this sample will allow you to zoom the map down into Premium data layers. 35 | If your API key only has access to OS OpenData layers then those requests will fail. 36 | 37 |
38 | 39 | 40 | -------------------------------------------------------------------------------- /OSVectorTileAPI/StylingVTS/InCode/map.js: -------------------------------------------------------------------------------- 1 | // 2 | // Setup the EPSG:27700 (British National Grid) projection 3 | // 4 | proj4.defs("EPSG:27700", "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.999601 +x_0=400000 +y_0=-100000 +ellps=airy +towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894 +datum=OSGB36 +units=m +no_defs"); 5 | ol.proj.proj4.register(proj4); 6 | var bng = ol.proj.get('EPSG:27700'); 7 | bng.setExtent([-238375.0,0,700000,1300000]); 8 | 9 | var map; 10 | var serviceUrl = "https://api.os.uk/maps/vector/v1/vts"; 11 | 12 | function setupLayer() { 13 | if(map) { 14 | map.setTarget(null); 15 | } 16 | 17 | var key = document.getElementById('keyInput').value; 18 | var message = document.getElementById('message'); 19 | var instructions = document.getElementById('instructions'); 20 | 21 | if(!key) { 22 | message.classList.add("warning"); 23 | message.textContent = 'To view the map, please enter a valid API key.'; 24 | instructions.classList.remove("hidden"); 25 | return; 26 | } 27 | message.classList.remove("warning"); 28 | message.textContent = 'To view the map, please enter a valid API key.'; 29 | instructions.classList.add("hidden"); 30 | 31 | // This example requires the main Capabilities url, and the default sprite file. We define our own style, rather 32 | // then loading the default style from the service. 33 | var capabilityPromise = fetch(serviceUrl + '?key=' + key).then(response => response.json()); 34 | var spritePromise = fetch(serviceUrl + '/resources/sprites/sprite.json?key=' + key).then(response => response.json()); 35 | var spriteImageUrl = serviceUrl + '/resources/sprites/sprite.png?key=' + key; 36 | 37 | Promise.all([capabilityPromise, spritePromise]) 38 | .then(results => { 39 | var service = results[0]; 40 | var sprite = results[1]; 41 | var style = { 42 | "version": 8, 43 | "sprite": "https://api.os.uk/maps/vector/v1/vts/resources/sprites/sprite", 44 | "glyphs": "https://api.os.uk/maps/vector/v1/vts/resources/fonts/{fontstack}/{range}.pbf", 45 | "sources": { 46 | "esri": { 47 | "type": "vector", 48 | "url": "https://api.os.uk/maps/vector/v1/vts/" 49 | } 50 | }, 51 | "layers": [ 52 | { 53 | "id": "OS Open Zoomstack - Road/land", 54 | "type": "fill", 55 | "source": "esri", 56 | "source-layer": "land", 57 | "layout": {}, 58 | "paint": { 59 | "fill-color": "#fefefe", 60 | "fill-outline-color": "#fefefe" 61 | } 62 | }, 63 | { 64 | "id": "OS Open Zoomstack - Road/national_parks", 65 | "type": "fill", 66 | "source": "esri", 67 | "source-layer": "national_parks", 68 | "maxzoom": 11.85, 69 | "layout": {}, 70 | "paint": { 71 | "fill-color": "#E5F5CC", 72 | "fill-opacity": 0.5 73 | } 74 | }, 75 | { 76 | "id": "OS Open Zoomstack - Road/national parks", 77 | "type": "symbol", 78 | "source": "esri", 79 | "source-layer": "national parks", 80 | "minzoom": 6.53, 81 | "layout": { 82 | "icon-image": "OS Open Zoomstack - Road/national parks", 83 | "icon-allow-overlap": true, 84 | "text-font": [ 85 | "Arial Bold" 86 | ], 87 | "text-size": 10.6667, 88 | "text-anchor": "center", 89 | "text-field": "{_name}", 90 | "text-optional": true 91 | }, 92 | "paint": { 93 | "icon-color": "rgba(240,240,240,0)", 94 | "text-color": "#44913B", 95 | "text-halo-color": "#F4F4EE", 96 | "text-halo-width": 1.51181 97 | } 98 | } 99 | ] 100 | }; 101 | 102 | 103 | // Read the tile grid dimensions from the service meta-data 104 | var extent = [service.fullExtent.xmin, service.fullExtent.ymin, service.fullExtent.xmax, service.fullExtent.ymax]; 105 | var origin = [service.tileInfo.origin.x, service.tileInfo.origin.y]; 106 | var resolutions = service.tileInfo.lods.map(l => l.resolution).slice(0, 16); 107 | var tileSize = service.tileInfo.rows; 108 | var tiles = service.tiles[0]; 109 | var wkid = service.tileInfo.spatialReference.latestWkid; 110 | 111 | // Set up the options required for the VTS source in OpenLayers 112 | var options = { 113 | format: new ol.format.MVT(), 114 | url: tiles + '?key=' + key, 115 | attributions: '© Ordnance Survey', 116 | projection: 'EPSG:' + wkid, 117 | tileGrid: new ol.tilegrid.TileGrid({ 118 | extent, 119 | origin, 120 | resolutions, 121 | tileSize 122 | }) 123 | }; 124 | var source = new ol.source.VectorTile(options); 125 | var layer = new ol.layer.VectorTile({ source: source }); 126 | 127 | // ol-mapbox-style doesn't like the 0 opacity for the icon colours, so we replace them here 128 | style.layers.forEach(layer => { 129 | if(layer.paint && layer.paint['icon-color']) { 130 | layer.paint['icon-color'] = layer.paint['icon-color'].replace(',0)', ',1)'); 131 | } 132 | }); 133 | 134 | // Setup the styling for the vector tile layer. 135 | // We use the custom style that we defined earlier 136 | olms.stylefunction(layer, style, 'esri', resolutions, sprite, spriteImageUrl); 137 | 138 | source.on('tileloaderror', function(event) { 139 | message.classList.add("warning"); 140 | message.textContent = 'Could not load a map tile. You may be attempting to access Premium data with an API key that only has access to OS OpenData.'; 141 | instructions.classList.remove("hidden"); 142 | }); 143 | 144 | // Set the default center of the map view 145 | // This example is centered on the Lake District, which is one of the national parks within the zoomstack data 146 | var center = [-343282, 7259502]; 147 | if(wkid === 27700) { 148 | var point = new ol.geom.Point(center); 149 | point.transform('EPSG:3857', 'EPSG:27700'); 150 | center = point.getCoordinates(); 151 | } 152 | 153 | // Create the map object and connect it to the 'map' element in the html 154 | map = new ol.Map({ 155 | target: 'map', 156 | layers: [layer], 157 | view: new ol.View({ 158 | projection: 'EPSG:' + wkid, 159 | center: center, 160 | zoom: 7 161 | }) 162 | }); 163 | // Expand the attribution control, so that the the copyright message is visible 164 | map.getControls().forEach(control => { 165 | if(control instanceof ol.control.Attribution) { 166 | control.setCollapsed(false); 167 | } 168 | }); 169 | }) 170 | .catch(error => { 171 | message.classList.add("warning"); 172 | message.textContent = 'Could not connect to the API. Ensure you are entering a project API key for a project that contains the OS Vector Tile API'; 173 | instructions.classList.remove("hidden"); 174 | }); 175 | } 176 | -------------------------------------------------------------------------------- /OSVectorTileAPI/StylingVTS/README.md: -------------------------------------------------------------------------------- 1 | # VTS styling 2 | 3 | Our Vector Tile Service provides a readily usable style, based on the available features. If you wish to adapt the existing style or create your own, you can easily do so. 4 | 5 | We will explain two options: 6 | * Dynamically adapting the pre-defined style 7 | * Creating your own style within the code 8 | 9 | We will explain both for OpenLayers, the principles are similar for MapBoxGL JS and Arc JS. 10 | 11 | It is also possible to create your own style from scratch and to host this locally on your server. This example has been omitted for the time being and will be added at a later date. 12 | 13 | Before we start please ensure you have a working version of the OS Data Hub VTS Demo for OpenLayers. You can find out how to get this in the Getting Started Guide. 14 | 15 | We recommend you take a look at the currently pre-defined styling for the service. You can get a copy of the pre-defined style directly from our VTS service by calling https://api.os.uk/maps/vector/v1/vts/resources/styles/?key={YourKey} in your browser. 16 | 17 | The result is [minified](https://en.wikipedia.org/wiki/Minification_(programming)) to keep the file size as small as possible, rendering it difficult to read for humans. Search online for a "JSON pretty print" converter which will turn the minified JSON data you received back into a more readable format. 18 | 19 | Take a look at this to get a better understanding of the structure. You will notice that each element contains a combination of defining attributes and style attributes. We can access, filter and change all of these, much like any other JSON data object. 20 | -------------------------------------------------------------------------------- /OSVectorTileAPI/style.css: -------------------------------------------------------------------------------- 1 | /* Set the document to use flexbox layout */ 2 | body { 3 | margin: 0; 4 | height: 100vh; 5 | display: flex; 6 | flex-direction: column; 7 | } 8 | /* ensure the map fills as much of the screen as possible */ 9 | #map { 10 | flex: 1 0 auto; 11 | } 12 | 13 | 14 | /* 15 | NOTE: 16 | The CSS following this comment is for *styling purposes only* and is not essential for this demo to run 17 | - strip out the styles below if you want cleaner code 18 | */ 19 | 20 | body { 21 | font-family: "Source Sans Pro", sans-serif; 22 | font-size:16px; 23 | color: #666666; 24 | min-width: 480px; 25 | } 26 | 27 | 28 | h1{ 29 | font-size: 32px; 30 | font-weight: normal; 31 | line-height: 1.4; 32 | letter-spacing: 0.7px; 33 | margin: 0 0 10px; 34 | color: #453c90; 35 | } 36 | 37 | p{ 38 | margin: 10px 0; 39 | } 40 | 41 | b{ 42 | font-weight:600; 43 | } 44 | label{ 45 | line-height: 1.7em; 46 | font-weight: 600; 47 | } 48 | input, button{ 49 | font-size: 16px; 50 | 51 | } 52 | 53 | input[type="text"]{ 54 | height: 24px; 55 | border-radius: 3px 0 0 3px; 56 | border: solid 1px #dddddd; 57 | padding: 12px 16px; 58 | width: calc(100% - 145px); 59 | background-color: #f5f5f5; 60 | color: #333333; 61 | font-size: 16px; 62 | margin: 0; 63 | 64 | } 65 | button{ 66 | height: 50px; 67 | border-radius: 0 3px 3px 0; 68 | background-color: #453c90; 69 | color: #fff; 70 | font-family: "Source Sans Pro", sans-serif; 71 | padding: 4px 20px; 72 | border:0; 73 | 74 | } 75 | 76 | 77 | #header{ 78 | text-align: center; 79 | background-color: #ffffff; 80 | padding: 20px; 81 | border-bottom: 1px solid #dddddd; 82 | box-shadow: 0 2px 4px 1px rgba(0, 0, 0, 0.4); 83 | z-index:1000 84 | 85 | } 86 | 87 | 88 | #instructions{ 89 | position: fixed; 90 | background-color: #fff; 91 | padding: 10px 20px; 92 | top: 280px; 93 | width: 300px; 94 | left: calc(50% - 160px); 95 | z-index: 100; 96 | border-radius: 3px; 97 | box-shadow: 0 1px 4px 1px rgba(0, 0, 0, 0.4); 98 | } 99 | 100 | .hidden{ 101 | display:none; 102 | } 103 | .warning{ 104 | color:#d40058; 105 | font-weight:400; 106 | } 107 | form{ 108 | margin-top: 20px; 109 | text-align: left; 110 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OS Data Hub API Demos 2 | 3 | This repo contains working examples of how to use some of the products provided by the [OS Data Hub](https://osdatahub.os.uk/). 4 | The OS Data Hub is a service providing access to Ordnance Survey data as part of the [Open MasterMap Implementation Programme](https://www.ordnancesurvey.co.uk/business-and-government/products/open-mastermap.html). 5 | 6 | *Please note that the OS Maps API provided by the OS Data Hub is separate from the [OS Maps API for Enterprise](https://developer.ordnancesurvey.co.uk/os-maps-api-enterprise). 7 | For help with OS Maps API for Enterprise see the separate [API docs](https://apidocs.os.uk/docs/os-maps-overview) and [demos](https://github.com/OrdnanceSurvey/OS-Maps-API).* 8 | 9 | ## Software requirements 10 | 11 | All of the examples work with current web browsers. Internet Explorer is not supported. 12 | 13 | The airports examples also require [Node.JS](https://nodejs.org). 14 | 15 | ## Using the demos 16 | 17 | Each of the demos needs an API key to access the OS Data Hub APIs. 18 | 19 | Register for API keys using the [OS Data Hub](https://osdatahub.os.uk/): 20 | - Sign up to the OS Data Hub, and create a project 21 | - Add the OS Maps API, OS Features API, OS Vector Tile API and the OS Linked Identifiers API to your project 22 | - Copy the API key from the project page 23 | 24 | Note that some of the demos will allow you to zoom in to Premium data levels. 25 | If your OS Data Hub account is on the OS OpenData plan then these Premium Data requests will fail. 26 | To gain Premium data access, please refer to the [API Plans & Pricing page in the OS Data Hub](https://osdatahub.os.uk/plans). 27 | 28 | ### OS Features API, OS Maps API, OS Vector Tile API and OS Linked Identifiers API examples 29 | 30 | These examples are relatively simple, and are a good place to start understanding how to integrate the OS Data Hub APIs into a web application. 31 | 32 | These examples use plain HTML, CSS and JavaScript. You can run them by opening the index.html in each folder, or you can serve the examples using a web server, for example [live-server](https://www.npmjs.com/package/live-server). 33 | 34 | ### Airports examples 35 | 36 | The airports examples are a little more complex. 37 | Each displays a map provided by the OS Maps API, and overlays the map with features loaded from the OS Features API. 38 | We search for features that are airports within the current extent of the map, and draw the feature geometry on top of the map. 39 | Each airport is clickable, allowing you to see the additional feature properties that were returned from the WFS query. 40 | 41 | These examples demonstate two approaches for providing OS Data Hub API access to a web application, without sharing your API key with the browser. 42 | 43 | #### Airports-APIKey 44 | The Airports API Key example uses a small server to serve the web application and to act as a proxy for the OS Data Hub APIs. 45 | This proxy allows you to embed an API key into the server without exposing the API key to the end users of the application. 46 | To run the sample, install [Node.JS](https://nodejs.org) and then run the following commands from the `Airports-APIKey` directory: 47 | 48 |
49 | npm install
50 | npm start <API key>
51 | 
52 | 53 | Note: A production application would need to add extra protection to the server, to ensure that the only people able 54 | to make API calls through the proxy are legitimate users of your application. Failure to do so would allow malicious 55 | users to make API requests with your API key, even though they do not have direct access to it. 56 | 57 | #### Airports-OAuth 58 | The Airports OAuth example uses a small server to serve the web application and to provide access to an access token for the OS Data Hub APIs. 59 | This approach allows you to embed an API key and secret into the server without exposing them the end users of the application. 60 | To run the sample, install [Node.JS](https://nodejs.org) and then run the following commands from the `Airports-OAuth` directory: 61 | 62 |
63 | npm install
64 | npm start <API key> <API secret>
65 | 
66 | 67 | Note: A production application would need to add extra protection to the server, to ensure that the only people able 68 | to get the access token are legitimate users of your application. Failure to do so would allow malicious users to make 69 | API requests with the token, even though they do not have direct access to the API key and secret. 70 | 71 | 72 | ## License 73 | 74 | These demos are released under the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0.html) 75 | --------------------------------------------------------------------------------