From a9dee9d8a351a9379c057cd094a1357c56688cf5 Mon Sep 17 00:00:00 2001 From: Mateusz Konieczny Date: Tue, 9 Jan 2024 11:26:45 +0100 Subject: [PATCH 1/3] Move basemap layer configuration to configuration. fixes #1284 --- app/src/cc-config.json | 5 ++++- app/src/cc-config.ts | 2 ++ .../frontend/map/layers/city-base-map-layer.tsx | 14 ++++---------- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/src/cc-config.json b/app/src/cc-config.json index 587d66a06..6723f2eb2 100644 --- a/app/src/cc-config.json +++ b/app/src/cc-config.json @@ -12,5 +12,8 @@ "postcode": "Postcode", "energy_rating": "Building Research Establishment Environmental Assessment Method (BREEAM) rating [More info]", - "bbox": [-61149.622628, 6667754.851372, 37183, 6744803.375884] + "bbox": [-61149.622628, 6667754.851372, 37183, 6744803.375884], + + "basemapTileUrl": "https://api.os.uk/maps/raster/v1/zxy/Light_3857/{z}/{x}/{y}.png?key=UVWEspgInusDKKYANE5bmyddoEmCSD4r", + "baseAttribution": "Building attribute data is © Colouring Cities contributors. Maps contain OS data © Crown copyright: OS Maps baselayers and building outlines. OS licence" } diff --git a/app/src/cc-config.ts b/app/src/cc-config.ts index 94815024b..579a0bc31 100644 --- a/app/src/cc-config.ts +++ b/app/src/cc-config.ts @@ -16,5 +16,7 @@ export interface CCConfig energy_rating: string; // Official Environmental Energy Rating (BREEAM Rating in UK) bbox: [number, number, number, number]; // Bounding box of generated tiles, in CRS epsg:3857 in form: [w, s, e, n] + basemapTileUrl: string; + baseAttribution: string; } diff --git a/app/src/frontend/map/layers/city-base-map-layer.tsx b/app/src/frontend/map/layers/city-base-map-layer.tsx index 40537b0cd..274919cb5 100644 --- a/app/src/frontend/map/layers/city-base-map-layer.tsx +++ b/app/src/frontend/map/layers/city-base-map-layer.tsx @@ -2,9 +2,8 @@ import * as React from 'react'; import { TileLayer } from 'react-leaflet'; import { MapTheme } from '../../config/map-config'; - -const OS_API_KEY = 'UVWEspgInusDKKYANE5bmyddoEmCSD4r'; - +import { CCConfig } from '../../../cc-config'; +let config: CCConfig = require('../../../cc-config.json') /** * Base raster layer for the map. * @param theme map theme @@ -15,16 +14,11 @@ export function CityBaseMapLayer({ theme }: { theme: MapTheme }) { * Ordnance Survey maps - UK / London specific * (replace with appropriate base map for other cities/countries) */ - const apiKey = OS_API_KEY; - - // Note that OS APIs does not provide dark theme - const layer = 'Light_3857'; - // In either theme case, we will use OS's light theme, but add our own filter const theme_class = theme === 'light' ? "light-theme" : "night-theme"; - const baseUrl = `https://api.os.uk/maps/raster/v1/zxy/${layer}/{z}/{x}/{y}.png?key=${apiKey}`; - const attribution = `Building attribute data is © Colouring Cities contributors. Maps contain OS data © Crown copyright: OS Maps baselayers and building outlines. OS licence`; + const baseUrl = config.basemapTileUrl; + const attribution = config.baseAttribution; return Date: Tue, 9 Jan 2024 14:43:23 +0100 Subject: [PATCH 2/3] generify documentation --- docs/configuring-colouring-cities.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/configuring-colouring-cities.md b/docs/configuring-colouring-cities.md index ce6f59f63..212639405 100644 --- a/docs/configuring-colouring-cities.md +++ b/docs/configuring-colouring-cities.md @@ -17,7 +17,7 @@ The configuration files are located here: ### > cc-config.json The JSON file contains the definition of the values of the variables. -Currently, these parameters are: +Currently, these parameters include: - **'cityName'** (string) - The name of the city/country. - **'projectBlurb'** (string) - A line of text describing the relationship of the project to the CCRP @@ -57,4 +57,4 @@ If you want to add additional parameters into the configuration framework, then **NOTE: Any additional project specific text strings and parameters should be added to this file and the JSON file.** -*REQUEST: If you find any Colouring London-specific text or values, please report them or create a pull request to move them into the configuration framework.* +*REQUEST: If you find any London-specific text or values, please report them or create a pull request to move them into the configuration framework.* From 7ef7fedc3a6fc74262c5c3a580d6d0fb139fd0b9 Mon Sep 17 00:00:00 2001 From: Mateusz Konieczny Date: Tue, 9 Jan 2024 15:28:19 +0100 Subject: [PATCH 3/3] Use OpenStreetMap tiles by default. More friendly to new partners outside UK, less configuration will be typically required. fixes #1281 --- app/src/cc-config.json | 4 ++-- docs/configuring-colouring-cities.md | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/cc-config.json b/app/src/cc-config.json index 6723f2eb2..631c6bdc0 100644 --- a/app/src/cc-config.json +++ b/app/src/cc-config.json @@ -14,6 +14,6 @@ "bbox": [-61149.622628, 6667754.851372, 37183, 6744803.375884], - "basemapTileUrl": "https://api.os.uk/maps/raster/v1/zxy/Light_3857/{z}/{x}/{y}.png?key=UVWEspgInusDKKYANE5bmyddoEmCSD4r", - "baseAttribution": "Building attribute data is © Colouring Cities contributors. Maps contain OS data © Crown copyright: OS Maps baselayers and building outlines. OS licence" + "basemapTileUrl": "https://tile.openstreetmap.org/{z}/{x}/{y}.png", + "baseAttribution": "Building attribute data is © Colouring Cities contributors. Basemap © OpenStreetMap contributors. Building © MODIFY TO PROVIDE RELEVANT INFO" } diff --git a/docs/configuring-colouring-cities.md b/docs/configuring-colouring-cities.md index 212639405..c81ac369c 100644 --- a/docs/configuring-colouring-cities.md +++ b/docs/configuring-colouring-cities.md @@ -30,6 +30,8 @@ There are also some other values to customise the behaviour of the application: - **'initialMapPosition'** (string) - The default latitude and longitude of the map when the page loads. - **'initialZoomLevel'** (string) - The default zoom level when the map loads. +- **'basemapTileUrl'** (string) - URL of basemap, in format accepted by Leaflet, shown under any displayed features. Note that default one is using external servers with own [Usage Policy](https://operations.osmfoundation.org/policies/tiles/) - please review it. +- **'baseAttribution'** (string) - basic attribution, in format accepted by Leaflet, should include basemap attribution, attribution for work of Colouring platform contributors and likely also attribute source of building geometries. Default `baseAttribution` always needs to be edited, though it contains part of required attribution for attribute data and default basemap. For example, the [JSON file for Colouring London](https://github.com/colouring-cities/colouring-london/blob/master/app/src/cc-config.json) looks like this: