Open Infrastructure Map, a view of infrastructure data in OpenStreetMap
Add other pipelines layer
Russ Garrett58794cc9dd01
diff --git a/web/locales/en/translation.json b/web/locales/en/translation.jsonindex a1a76c9..406aaf4 100644--- a/web/locales/en/translation.json+++ b/web/locales/en/translation.json@@ -74,6 +74,9 @@"petroleum-intermediate": "Petroleum intermediate","fuel": "Fuel","hydrogen": "Hydrogen",+ "nitrogen": "Nitrogen",+ "oxygen": "Oxygen",+ "beer": "Beer","co2": "CO<sub>2</sub>","fresh-water": "Fresh water","hot-water": "Hot water",@@ -190,10 +193,11 @@"power": "Power","heatmap": "Solar Generation","telecoms": "Telecoms",- "petroleum": "Oil & Gas",+ "petroleum": "Oil & Natural Gas","water": "Water","labels": "Labels",- "title": "Layers"+ "title": "Layers",+ "other_pipelines": "Other Pipelines"},"construction": "under construction","disused": "disused"diff --git a/web/package-lock.json b/web/package-lock.jsonindex 07ec249..86a63f5 100644--- a/web/package-lock.json+++ b/web/package-lock.json@@ -3503,6 +3503,7 @@"resolved": "https://registry.npmjs.org/i18next-parser/-/i18next-parser-9.0.2.tgz","integrity": "sha512-Q1yTZljBp1DcVAQD7LxduEqFRpjIeZc+5VnQ+gU8qG9WvY3U5rqK0IVONRWNtngh3orb197bfy1Sz4wlwcplxg==","dev": true,+ "license": "MIT","dependencies": {"@babel/runtime": "^7.23.2","broccoli-plugin": "^4.0.7",diff --git a/web/package.json b/web/package.jsonindex 9fccafa..4a23703 100644--- a/web/package.json+++ b/web/package.json@@ -7,7 +7,8 @@"start": "vite","dev": "vite","build": "vite build",- "test": "eslint ."+ "test": "eslint .",+ "extract": "i18next-parser 'src/**/*.{ts,tsx}' --output 'src/locales/{{locale}}/{{ns}}.json' --keep"},"repository": {"type": "git",@@ -25,7 +26,6 @@"@typescript-eslint/parser": "^8.18.0","eslint-config-prettier": "^9.1.0","eslint-plugin-prettier": "^5.1.2",- "i18next-parser": "^9.0.2","prettier": "^3.1.1","typescript": "^5.5.4","vite": "^6.0.3",diff --git a/web/src/friendlynames.ts b/web/src/friendlynames.tsindex 44a5da1..0bec2bf 100644--- a/web/src/friendlynames.ts+++ b/web/src/friendlynames.ts@@ -33,6 +33,8 @@ export default function friendlyNames(): { [key: string]: string } {water_treatment_plant: t('names.water.treatment-plant', 'Water treatment plant'),water_pumping_station: t('names.water.pumping-station', 'Pumping station'),water_well: t('names.water.well', 'Water well'),- water_reservoir: t('names.water.reservoir', 'Water reservoir')+ water_reservoir: t('names.water.reservoir', 'Water reservoir'),+ pipeline_inner: t('names.pipeline_other', 'Other Pipeline'),+ pipeline_case: t('names.pipeline_other', 'Other Pipeline')}}diff --git a/web/src/index.ts b/web/src/index.tsindex c1be500..5dea266 100644--- a/web/src/index.ts+++ b/web/src/index.ts@@ -29,7 +29,8 @@ await i18next.use(LanguageDetector).init({'zh','zh-Hans','ja',- 'id'+ 'id',+ 'ta'],resources: resources,debug: import.meta.env.DEV,diff --git a/web/src/key/key.ts b/web/src/key/key.tsindex e97133c..53ce375 100644--- a/web/src/key/key.ts+++ b/web/src/key/key.ts@@ -9,10 +9,15 @@ import {colour_gas,colour_fuel,colour_intermediate,- colour_hydrogen,- colour_co2,- colour_unknown+ colour_hydrogen} from '../style/style_oim_petroleum.js'+import {+ colour_beer,+ colour_co2,+ colour_nitrogen,+ colour_other_pipeline_unknown,+ colour_oxygen+} from '../style/style_oim_other_pipelines.js'import {colour_freshwater,colour_wastewater,@@ -126,6 +131,8 @@ class KeyControl implements IControl {mount(pane, this.petroleumTable())pane.appendChild(el('h3', t('key.water', 'Water')))mount(pane, await this.waterTable())+ pane.appendChild(el('h3', t('key.other_pipelines', 'Other Pipelines')))+ mount(pane, this.otherPipelineTable())this._pane = panemount(this._container, pane)@@ -263,8 +270,6 @@ class KeyControl implements IControl {],[t('names.substance.fuel', 'Fuel'), svgLine(colour_fuel, line_thickness)],[t('names.substance.hydrogen', 'Hydrogen'), svgLine(colour_hydrogen, line_thickness)],- [t('names.substance.co2', 'CO<sub>2</sub>'), svgLine(colour_co2, line_thickness)],- [t('other', 'Other'), svgLine(colour_unknown, line_thickness)],[t('names.petroleum.facility', 'Petroleum facility'),svgRectFromLayer(petroleum_layers(), 'petroleum_site')@@ -275,6 +280,19 @@ class KeyControl implements IControl {return table}+ otherPipelineTable() {+ const rows = [+ [t('names.substance.oxygen', 'Oxygen'), svgLine(colour_oxygen, line_thickness)],+ [t('names.substance.co2', 'CO<sub>2</sub>'), svgLine(colour_co2, line_thickness)],+ [t('names.substance.nitrogen', 'Nitrogen'), svgLine(colour_nitrogen, line_thickness)],+ [t('names.substance.beer', 'Beer'), svgLine(colour_beer, line_thickness)],+ [t('other', 'Other'), svgLine(colour_other_pipeline_unknown, line_thickness)]+ ]+ const table = list('table', Tr)+ table.update(rows)+ return table+ }+async waterTable() {const rows = [[t('names.substance.fresh-water', 'Fresh water'), svgLine(colour_freshwater, line_thickness)],diff --git a/web/src/openinframap.ts b/web/src/openinframap.tsindex 25c8e23..c7cc666 100644--- a/web/src/openinframap.ts+++ b/web/src/openinframap.ts@@ -18,6 +18,7 @@ import style_oim_power_heatmap from './style/style_oim_power_heatmap.js'import style_oim_telecoms from './style/style_oim_telecoms.js'import style_oim_petroleum from './style/style_oim_petroleum.js'import style_oim_water from './style/style_oim_water.js'+import style_oim_other_pipelines from './style/style_oim_other_pipelines.js'import { LayerSpecificationWithZIndex } from './style/types.js'import { manifest } from 'virtual:render-svg'@@ -71,7 +72,8 @@ export default class OpenInfraMap {...style_oim_power_heatmap,...style_oim_petroleum(),...style_oim_telecoms(),- ...style_oim_water()+ ...style_oim_water(),+ ...style_oim_other_pipelines()]oim_layers.sort((a, b) => {@@ -90,6 +92,7 @@ export default class OpenInfraMap {new Layer('S', t('layers.heatmap', 'Solar Generation'), 'heatmap_', false),new Layer('T', t('layers.telecoms', 'Telecoms'), 'telecoms_', false),new Layer('O', t('layers.petroleum', 'Oil & Gas'), 'petroleum_', false),+ new Layer('I', t('layers.other_pipelines', 'Other Pipelines'), 'pipeline_', false),new Layer('W', t('layers.water', 'Water'), 'water_', false),new Layer('L', t('layers.labels', 'Labels'), 'place_', true)],diff --git a/web/src/style/common.ts b/web/src/style/common.tsindex 3344d57..ff9e137 100644--- a/web/src/style/common.ts+++ b/web/src/style/common.ts@@ -1,7 +1,7 @@import { ExpressionSpecification, FilterSpecification } from 'maplibre-gl'import { LayerSpecificationWithZIndex } from './types.ts'import { local_name_tags } from '../l10n.ts'-import { step, interpolate, get, has, all, any, concat, case_ } from './stylehelpers.ts'+import { step, interpolate, get, has, all, any, concat, case_, coalesce } from './stylehelpers.ts'export function get_local_name(): ExpressionSpecification {return (['coalesce'] as any).concat(local_name_tags().map((tag) => get(tag))) as ExpressionSpecification@@ -122,3 +122,4 @@ export function oimSymbol(options: OIMSymbolOptions): LayerSpecificationWithZInd}}}+export const substance: ExpressionSpecification = coalesce(get('substance'), get('type'), '')diff --git a/web/src/style/style.ts b/web/src/style/style.tsindex 69844dd..ab65589 100644--- a/web/src/style/style.ts+++ b/web/src/style/style.ts@@ -67,6 +67,12 @@ const style: StyleSpecification = {tiles: ['https://openinframap.org/map/solar_heatmap/{z}/{x}/{y}.pbf'],maxzoom: 17,attribution: oim_attribution+ },+ other_pipeline: {+ type: 'vector',+ tiles: ['https://openinframap.org/map/other_pipeline/{z}/{x}/{y}.pbf'],+ maxzoom: 17,+ attribution: oim_attribution}},glyphs: '/fonts/{fontstack}/{range}.pbf',diff --git a/web/src/style/style_oim_other_pipelines.ts b/web/src/style/style_oim_other_pipelines.tsnew file mode 100644index 0000000..5edf5d3--- /dev/null+++ b/web/src/style/style_oim_other_pipelines.ts@@ -0,0 +1,79 @@+import { ColorSpecification, ExpressionSpecification } from '@maplibre/maplibre-gl-style-spec'+import { font, substance, text_paint } from './common.ts'+import { pipeline_label } from './style_oim_petroleum.ts'+import { get, interpolate, match, zoom } from './stylehelpers.ts'+import { LayerSpecificationWithZIndex } from './types.ts'++export const colour_oxygen: ColorSpecification = '#61F4FF'+export const colour_co2: ColorSpecification = '#7885CC'+export const colour_nitrogen: ColorSpecification = '#5F1385'+export const colour_beer: ColorSpecification = '#BA7449'+export const colour_other_pipeline_unknown: ColorSpecification = '#FCB512'++const other_pipeline_colour: ExpressionSpecification = match(+ substance,+ [+ ['oxygen', colour_oxygen],+ ['carbon_dioxide', colour_co2],+ ['nitrogen', colour_nitrogen],+ ['beer', colour_beer]+ ],+ colour_other_pipeline_unknown+)++export default function layers(): LayerSpecificationWithZIndex[] {+ return [+ {+ zorder: 1,+ id: 'pipeline_case',+ type: 'line',+ source: 'other_pipeline',+ minzoom: 7,+ 'source-layer': 'other_pipeline',+ paint: {+ 'line-color': '#666666',+ 'line-width': interpolate(zoom, [+ [8, 1.5],+ [16, ['match', get('usage'), 'transmission', 4, 1.5]]+ ])+ },+ layout: {+ 'line-cap': 'round',+ 'line-join': 'round'+ }+ },+ {+ zorder: 3,+ id: 'pipeline_inner',+ type: 'line',+ source: 'other_pipeline',+ minzoom: 2,+ 'source-layer': 'other_pipeline',+ paint: {+ 'line-color': other_pipeline_colour,+ 'line-width': interpolate(zoom, [+ [3, 1],+ [16, ['match', get('usage'), 'transmission', 2, 1]]+ ])+ }+ },+ {+ zorder: 500,+ id: 'other_pipeline_label',+ type: 'symbol',+ source: 'other_pipeline',+ 'source-layer': 'other_pipeline',+ minzoom: 12,+ paint: text_paint,+ layout: {+ 'text-field': pipeline_label(),+ 'text-font': font,+ 'symbol-placement': 'line',+ 'symbol-spacing': 400,+ 'text-size': 10,+ 'text-offset': [0, 1],+ 'text-max-angle': 10+ }+ }+ ]+}diff --git a/web/src/style/style_oim_petroleum.ts b/web/src/style/style_oim_petroleum.tsindex ce15e56..df655f2 100644--- a/web/src/style/style_oim_petroleum.ts+++ b/web/src/style/style_oim_petroleum.ts@@ -1,19 +1,16 @@import { t } from 'i18next'import { ColorSpecification, ExpressionSpecification } from 'maplibre-gl'-import { text_paint, font, get_local_name } from './common.js'+import { text_paint, font, get_local_name, substance } from './common.js'import { LayerSpecificationWithZIndex } from './types.ts'-import { interpolate, match, coalesce, get, has, concat, if_, zoom, any, all } from './stylehelpers.ts'+import { interpolate, match, get, has, concat, if_, zoom, any, all } from './stylehelpers.ts'const colour_gas: ColorSpecification = '#BFBC6B'const colour_oil: ColorSpecification = '#6B6B6B'const colour_fuel: ColorSpecification = '#CC9F83'const colour_intermediate: ColorSpecification = '#78CC9E'const colour_hydrogen: ColorSpecification = '#CC78AB'-const colour_co2: ColorSpecification = '#7885CC'const colour_unknown: ColorSpecification = '#BABABA'-const substance: ExpressionSpecification = coalesce(get('substance'), get('type'), '')-const pipeline_colour: ExpressionSpecification = match(substance,[@@ -21,8 +18,7 @@ const pipeline_colour: ExpressionSpecification = match(['oil', colour_oil],['fuel', colour_fuel],[['ngl', 'y-grade', 'hydrocarbons', 'condensate', 'naphtha'], colour_intermediate],- ['hydrogen', colour_hydrogen],- ['carbon_dioxide', colour_co2]+ ['hydrogen', colour_hydrogen]],colour_unknown)@@ -182,6 +178,6 @@ export {colour_fuel,colour_intermediate,colour_hydrogen,- colour_co2,- colour_unknown+ colour_unknown,+ pipeline_label}