Skip to content

Open Infrastructure Map, a view of infrastructure data in OpenStreetMap

add pipeline ref labels to petroleum pipelines

Jan Alexander9a8b3d526ec0
diff --git a/web/src/icons/power_line_ref.svg b/web/src/icons/line_ref.svg
similarity index 100%
rename from web/src/icons/power_line_ref.svg
rename to web/src/icons/line_ref.svg
diff --git a/web/src/key/key.ts b/web/src/key/key.ts
index 9c70076..e47805e 100644
--- a/web/src/key/key.ts
+++ b/web/src/key/key.ts
@@ -148,7 +148,7 @@ class KeyControl implements IControl {
rows = rows.map((row) => [row[0], svgLine(row[1], line_thickness)])
rows.push([t('location.underground', 'Underground'), svgLine('#7A7A85', line_thickness, '3 2')])
- rows.push([t('names.power.line-reference', 'Line reference'), await this.sprite('power_line_ref')])
+ rows.push([t('names.power.line-reference', 'Line reference'), await this.sprite('line_ref')])
const table = list('table', Tr)
table.update(rows)
diff --git a/web/src/style/style_oim_petroleum.ts b/web/src/style/style_oim_petroleum.ts
index ed1ae60..2015a65 100644
--- a/web/src/style/style_oim_petroleum.ts
+++ b/web/src/style/style_oim_petroleum.ts
@@ -2,7 +2,7 @@ import { t } from 'i18next'
import { ColorSpecification, ExpressionSpecification } from 'maplibre-gl'
import { text_paint, font, get_local_name, substance } from './common.js'
import { LayerSpecificationWithZIndex } from './types.ts'
-import { interpolate, match, get, has, concat, if_, zoom, any, all, case_ } from './stylehelpers.ts'
+import { interpolate, match, get, has, coalesce, concat, if_, zoom, any, all, case_ } from './stylehelpers.ts'
const colour_gas_transmission_large: ColorSpecification = '#8A3976'
const colour_gas_transmission_medium: ColorSpecification = '#E65757'
@@ -90,6 +90,12 @@ function pipeline_label(): ExpressionSpecification {
)
}
+const pipeline_ref_visible_p: ExpressionSpecification = any(all(transmission_p, ['>', zoom, 7]), [
+ '>',
+ zoom,
+ 11
+])
+
export default function layers(): LayerSpecificationWithZIndex[] {
return [
{
@@ -206,6 +212,27 @@ export default function layers(): LayerSpecificationWithZIndex[] {
'text-size': 10
},
paint: text_paint
+ },
+ {
+ zorder: 503,
+ id: 'petroleum_pipeline_ref',
+ type: 'symbol',
+ source: 'petroleum',
+ 'source-layer': 'petroleum_pipeline',
+ minzoom: 7,
+ filter: all(
+ pipeline_ref_visible_p,
+ ['!=', coalesce(get('ref'), ''), ''],
+ ['<', ['length', get('ref')], 5]
+ ),
+ layout: {
+ 'icon-image': 'line_ref',
+ 'text-field': '{ref}',
+ 'text-font': font,
+ 'symbol-placement': 'line-center',
+ 'text-size': 10,
+ 'text-max-angle': 10
+ }
}
]
}
diff --git a/web/src/style/style_oim_power.ts b/web/src/style/style_oim_power.ts
index 7aad133..ab17740 100644
--- a/web/src/style/style_oim_power.ts
+++ b/web/src/style/style_oim_power.ts
@@ -1054,7 +1054,7 @@ export default function layers(): LayerSpecificationWithZIndex[] {
'source-layer': 'power_line',
minzoom: 7,
layout: {
- 'icon-image': 'power_line_ref',
+ 'icon-image': 'line_ref',
'text-field': '{ref}',
'text-font': font,
'symbol-placement': 'line-center',