Skip to content

Open Infrastructure Map, a view of infrastructure data in OpenStreetMap

Improvements to telecoms styles

Russ Garrettb41c5fb1d4b9
diff --git a/web/src/friendlynames.ts b/web/src/friendlynames.ts
index 349e94f..f70e9be 100644
--- a/web/src/friendlynames.ts
+++ b/web/src/friendlynames.ts
@@ -20,6 +20,8 @@ const friendlyNames: { [key: string]: string } = {
telecoms_communication_line: 'Telecoms line',
telecoms_mast: 'Telecoms mast',
telecoms_data_center: 'Telecoms building',
+ telecoms_exchange: 'Telephone exchange',
+ telecoms_cabinet: 'Telecoms cabinet',
petroleum_pipeline: 'Pipeline',
petroleum_well: 'Well',
water_pipeline: 'Water pipeline',
diff --git a/web/src/icons/cabinet.svg b/web/src/icons/cabinet.svg
new file mode 100644
index 0000000..0ce4048
--- /dev/null
+++ b/web/src/icons/cabinet.svg
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg width="100%" height="100%" viewBox="0 0 100 70" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;">
+ <g transform="matrix(0.89149,0,0,0.632698,5.36502,3.43722)">
+ <rect x="3.834" y="3.653" width="92.467" height="92.467" style="fill:white;stroke:black;stroke-width:4.04px;"/>
+ </g>
+ <g transform="matrix(1,0,0,1,0,-7.3509)">
+ <path d="M50,13.099L50,71.603" style="fill:none;stroke:black;stroke-width:2.08px;"/>
+ </g>
+ <g transform="matrix(1.34462,0,0,1.34462,-15.4305,-19.3279)">
+ <path d="M57.383,39.43C57.383,38.893 56.947,38.457 56.41,38.457L54.184,38.457C53.646,38.457 53.21,38.893 53.21,39.43L53.21,41.377C53.21,41.915 53.646,42.351 54.184,42.351L56.41,42.351C56.947,42.351 57.383,41.915 57.383,41.377L57.383,39.43Z" style="stroke:white;stroke-width:0.74px;"/>
+ </g>
+</svg>
diff --git a/web/src/icons/telecom_datacenter.svg b/web/src/icons/telecom_datacenter.svg
new file mode 100644
index 0000000..d1983e9
--- /dev/null
+++ b/web/src/icons/telecom_datacenter.svg
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg width="100%" height="100%" viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;">
+ <g transform="matrix(1,0,0,1,0.94368,0.0504566)">
+ <path d="M96.149,25.668C96.149,12.673 85.598,2.122 72.602,2.122L25.51,2.122C12.515,2.122 1.964,12.673 1.964,25.668L1.964,74.231C1.964,87.226 12.515,97.777 25.51,97.777L72.602,97.777C85.598,97.777 96.149,87.226 96.149,74.231L96.149,25.668Z" style="fill:rgb(235,235,235);stroke:black;stroke-width:2.5px;"/>
+ </g>
+ <g transform="matrix(1,0,0,1,7.31699,-2.25527)">
+ <rect x="18.748" y="17.848" width="47.871" height="68.815" style="fill:rgb(235,235,235);stroke:black;stroke-width:2.5px;"/>
+ </g>
+ <g transform="matrix(1,0,0,1,0.00099,6.15514)">
+ <path d="M26.065,21.47L73.935,21.47" style="fill:none;stroke:black;stroke-width:2px;"/>
+ </g>
+ <g transform="matrix(1,0,0,1,0.00099,20.1551)">
+ <path d="M26.065,21.47L73.935,21.47" style="fill:none;stroke:black;stroke-width:2px;"/>
+ </g>
+ <g transform="matrix(1,0,0,1,0.00099,34.1551)">
+ <path d="M26.065,21.47L73.935,21.47" style="fill:none;stroke:black;stroke-width:2px;"/>
+ </g>
+ <g transform="matrix(1,0,0,1,0.00099,48.1551)">
+ <path d="M26.065,21.47L73.935,21.47" style="fill:none;stroke:black;stroke-width:2px;"/>
+ </g>
+</svg>
diff --git a/web/src/icons/telecom_exchange.svg b/web/src/icons/telecom_exchange.svg
new file mode 100644
index 0000000..9aa0be6
--- /dev/null
+++ b/web/src/icons/telecom_exchange.svg
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg width="100%" height="100%" viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;">
+ <g transform="matrix(1,0,0,1,0.94368,0.0504566)">
+ <path d="M96.149,25.668C96.149,12.673 85.598,2.122 72.602,2.122L25.51,2.122C12.515,2.122 1.964,12.673 1.964,25.668L1.964,74.231C1.964,87.226 12.515,97.777 25.51,97.777L72.602,97.777C85.598,97.777 96.149,87.226 96.149,74.231L96.149,25.668Z" style="fill:rgb(235,235,235);stroke:black;stroke-width:2.5px;"/>
+ </g>
+ <g id="path6910" transform="matrix(0.135307,0,0,0.135307,-0.0428584,0.658894)">
+ <path d="M159.966,140.09C139.076,160.664 86.264,264.455 238.869,461.963C399.711,670.098 522.112,643.719 544.813,624.965L436.909,488.884C417.904,503.954 397.635,486.273 359.421,447.016C334.192,420.961 305.631,386.823 281.75,349.063C265.149,322.599 250.73,295.244 270.652,279.447L159.955,140.08L159.955,140.08L159.966,140.09Z" style="fill-rule:nonzero;"/>
+ </g>
+ <g id="path6912" transform="matrix(0.135307,0,0,0.135307,-0.0428584,0.658894)">
+ <path d="M598.404,580.125C607.272,573.082 607.828,560.978 601.422,552.911L601.446,552.706C601.446,552.706 517.225,446.891 517.138,446.781C510.459,438.371 498.426,437.198 490.13,443.786L451.568,474.411L559.841,610.747C559.841,610.747 598.379,580.328 598.288,580.214L598.403,580.123L598.404,580.125Z" style="fill-rule:nonzero;"/>
+ </g>
+ <g id="path6914" transform="matrix(0.135307,0,0,0.135307,-0.0428584,0.658894)">
+ <path d="M325.902,234.984C334.731,227.891 335.219,215.784 328.767,207.753L328.881,207.662C328.881,207.662 241.558,99.194 241.464,99.078C234.737,90.705 222.698,89.599 214.438,96.234L176.049,127.074L287.515,265.827L325.882,235.192L325.904,234.987L325.902,234.984Z" style="fill-rule:nonzero;"/>
+ </g>
+</svg>
diff --git a/web/src/key/key.ts b/web/src/key/key.ts
index 486e83d..b7f49eb 100644
--- a/web/src/key/key.ts
+++ b/web/src/key/key.ts
@@ -210,7 +210,9 @@ class KeyControl implements IControl {
const rows = [
['Cable', svgLineFromLayer(comms_layers, 'telecoms_line')],
['Tower/Mast', await this.sprite('comms_tower')],
- ['Datacenter/Exchange', svgRectFromLayer(comms_layers, 'telecoms_data_center')]
+ ['Datacenter', await this.sprite('telecom_datacenter')],
+ ['Exchange', await this.sprite('telecom_exchange')],
+ ['Cabinet', await this.sprite('cabinet')]
]
const table = list('table', Tr)
table.update(rows)
diff --git a/web/src/style/common.ts b/web/src/style/common.ts
index 174b070..d1e4ff2 100644
--- a/web/src/style/common.ts
+++ b/web/src/style/common.ts
@@ -1,17 +1,18 @@
-import { ExpressionSpecification } from 'maplibre-gl'
+import { ExpressionSpecification, FilterSpecification } from 'maplibre-gl'
+import { LayerSpecificationWithZIndex } from './types.ts'
import { local_name_tags } from '../l10n.ts'
export const local_name: ExpressionSpecification = (['coalesce'] as any).concat(
local_name_tags.map((tag) => ['get', tag])
) as ExpressionSpecification
-const text_paint = {
+export const text_paint = {
'text-halo-width': 4,
'text-halo-blur': 2,
'text-halo-color': 'rgba(230, 230, 230, 1)'
}
-const operator_text: ExpressionSpecification = [
+export const operator_text: ExpressionSpecification = [
'step',
['zoom'],
['get', 'name'],
@@ -19,7 +20,7 @@ const operator_text: ExpressionSpecification = [
['case', ['has', 'operator'], ['concat', ['get', 'name'], ' (', ['get', 'operator'], ')'], ['get', 'name']]
]
-const underground_p: ExpressionSpecification = [
+export const underground_p: ExpressionSpecification = [
'any',
['==', ['get', 'location'], 'underground'],
['==', ['get', 'location'], 'underwater'],
@@ -31,6 +32,80 @@ const underground_p: ExpressionSpecification = [
]
]
-const font = ['Noto Sans Regular']
+export const font = ['Noto Sans Regular']
-export { text_paint, operator_text, underground_p, font }
+export type OIMSymbolOptions = {
+ id: string
+ zorder: number
+ source: string
+ sourceLayer: string
+ filter?: FilterSpecification
+ minZoom: number
+ textField: ExpressionSpecification
+ textSize?: number
+ iconImage: string
+ iconScale?: number
+ textMinZoom: number
+ iconMaxZoom?: number
+ textOffset?: number
+}
+
+/**
+ * Generate a text+icon symbol style with the following properties:
+ *
+ * - The icon appears at minZoom and disappears at iconMaxZoom.
+ * - The text appears at textMinZoom.
+ * - Icon scaling, text scaling, and text offsets are managed automatically.
+ */
+export function oimSymbol(options: OIMSymbolOptions): LayerSpecificationWithZIndex {
+ const iconScale = options.iconScale || 1
+ const textSize = options.textSize || 12
+ const textOffset = options.textOffset || 1.4
+ const iconMaxZoom = options.iconMaxZoom || 21
+ return {
+ id: options.id,
+ zorder: options.zorder,
+ type: 'symbol',
+ source: options.source,
+ 'source-layer': options.sourceLayer,
+ filter: options.filter || ['literal', true],
+ minzoom: options.minZoom,
+ paint: {
+ ...text_paint,
+ // Control visibility using the opacity property.
+ // We can't use a step function on the 'text-field' property, because only one zoom-based
+ // function can be used per expression, and we might need to use a zoom-based expression
+ // to define text.
+ 'text-opacity': ['step', ['zoom'], 0, options.textMinZoom, 1]
+ },
+ layout: {
+ 'icon-image': ['step', ['zoom'], options.iconImage, iconMaxZoom, ''],
+ 'icon-size': [
+ 'interpolate',
+ ['linear'],
+ ['zoom'],
+ options.minZoom,
+ iconScale * 0.8,
+ iconMaxZoom,
+ iconScale
+ ],
+ 'text-field': options.textField,
+ 'text-font': font,
+ 'text-size': ['interpolate', ['linear'], ['zoom'], options.textMinZoom, textSize * 0.7, 18, textSize],
+ 'text-anchor': 'top',
+ 'text-offset': [
+ 'interpolate',
+ ['linear'],
+ ['zoom'],
+ options.textMinZoom,
+ ['literal', [0, textOffset * 0.8]],
+ iconMaxZoom,
+ ['literal', [0, textOffset]],
+ iconMaxZoom + 2,
+ ['literal', [0, 0]]
+ ],
+ 'text-optional': true,
+ 'icon-allow-overlap': true
+ }
+ }
+}
diff --git a/web/src/style/style_oim_telecoms.ts b/web/src/style/style_oim_telecoms.ts
index 13143da..29b1a32 100644
--- a/web/src/style/style_oim_telecoms.ts
+++ b/web/src/style/style_oim_telecoms.ts
@@ -1,5 +1,5 @@
import { LayerSpecificationWithZIndex } from './types.ts'
-import { text_paint, operator_text, font } from './common.js'
+import { text_paint, operator_text, font, oimSymbol } from './common.js'
import { local_name } from './common.ts'
const layers: LayerSpecificationWithZIndex[] = [
@@ -29,42 +29,55 @@ const layers: LayerSpecificationWithZIndex[] = [
'fill-outline-color': 'rgba(0, 0, 0, 1)'
}
},
- {
- zorder: 141,
+ oimSymbol({
+ zorder: 560,
+ id: 'telecoms_cabinet',
+ source: 'telecoms',
+ sourceLayer: 'telecoms_cabinet',
+ minZoom: 14,
+ textField: operator_text,
+ iconImage: 'cabinet',
+ iconScale: 0.4,
+ textMinZoom: 16
+ }),
+ oimSymbol({
+ zorder: 561,
id: 'telecoms_mast',
- type: 'symbol',
source: 'telecoms',
- minzoom: 10,
- 'source-layer': 'telecoms_mast',
- paint: text_paint,
- layout: {
- 'icon-image': 'comms_tower',
- 'icon-anchor': 'bottom',
- 'icon-size': ['interpolate', ['linear'], ['zoom'], 10, 0.6, 14, 1],
- 'text-field': operator_text,
- 'text-font': font,
- 'text-size': ['interpolate', ['linear'], ['zoom'], 11, 0, 12, 0, 12.01, 10],
- 'text-anchor': 'top',
- 'text-offset': ['interpolate', ['linear'], ['zoom'], 11, ['literal', [0, 1]], 16, ['literal', [0, 2]]],
- 'text-optional': true
- }
- },
- {
+ sourceLayer: 'telecoms_mast',
+ minZoom: 10,
+ textField: operator_text,
+ iconImage: 'comms_tower',
+ iconMaxZoom: 21,
+ textMinZoom: 12
+ }),
+ oimSymbol({
+ zorder: 562,
+ id: 'telecoms_exchange_symbol',
+ source: 'telecoms',
+ sourceLayer: 'telecoms_data_center_point',
+ filter: ['in', 'type', 'exchange', 'telephone_office', 'telephone_exchange', 'central_office'],
+ minZoom: 6,
+ textField: operator_text,
+ iconImage: 'telecom_exchange',
+ iconScale: 0.2,
+ textMinZoom: 11,
+ iconMaxZoom: 13.5
+ }),
+ oimSymbol({
zorder: 563,
id: 'telecoms_data_center_symbol',
- type: 'symbol',
source: 'telecoms',
- minzoom: 11,
- 'source-layer': 'telecoms_data_center',
- paint: text_paint,
- layout: {
- 'text-field': operator_text,
- 'text-font': font,
- 'text-size': ['interpolate', ['linear'], ['zoom'], 11, 0, 13, 0, 13.01, 10],
- 'text-offset': [0, 1],
- 'text-anchor': 'top'
- }
- },
+ sourceLayer: 'telecoms_data_center_point',
+ filter: ['in', 'type', 'data_center', 'data_centre'],
+ minZoom: 5,
+ textField: operator_text,
+ iconImage: 'telecom_datacenter',
+ iconScale: 0.3,
+ textMinZoom: 8,
+ iconMaxZoom: 13.5,
+ textOffset: 1.7
+ }),
{
zorder: 564,
id: 'telecoms_line_label',