Skip to content

Commit

Permalink
Merge pull request #1297 from matkoniecz/feature/1281-1284-global-tiles
Browse files Browse the repository at this point in the history
Allow easier change of map tiles and attribution, use tiles with global coverage
  • Loading branch information
matkoniecz authored Jan 10, 2024
2 parents c271a14 + 7ef7fed commit 7f33c94
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
5 changes: 4 additions & 1 deletion app/src/cc-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
"postcode": "Postcode",
"energy_rating": "Building Research Establishment Environmental Assessment Method (BREEAM) rating [<a href='https://bregroup.com/products/breeam/how-breeam-works'>More info</a>]",

"bbox": [-61149.622628, 6667754.851372, 37183, 6744803.375884]
"bbox": [-61149.622628, 6667754.851372, 37183, 6744803.375884],

"basemapTileUrl": "https://tile.openstreetmap.org/{z}/{x}/{y}.png",
"baseAttribution": "Building attribute data is © Colouring Cities contributors. Basemap © <a href=https://www.openstreetmap.org/copyright>OpenStreetMap contributors</a>. Building © MODIFY TO PROVIDE RELEVANT INFO"
}
2 changes: 2 additions & 0 deletions app/src/cc-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

14 changes: 4 additions & 10 deletions app/src/frontend/map/layers/city-base-map-layer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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. <a href=/ordnance-survey-licence.html>OS licence</a>`;
const baseUrl = config.basemapTileUrl;
const attribution = config.baseAttribution;

return <TileLayer
url={baseUrl}
Expand Down
6 changes: 4 additions & 2 deletions docs/configuring-colouring-cities.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:

Expand Down Expand Up @@ -57,4 +59,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.*

0 comments on commit 7f33c94

Please sign in to comment.