@elastic/ems-client 8.2.0 → 8.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,122 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0; you may not use this file except in compliance with the Elastic License
5
+ * 2.0.
6
+ */
7
+
8
+ import { LayerSpecification } from 'maplibre-gl';
9
+ import { TMSService } from '../src';
10
+ import { mlLayerTypes } from './ems_client_util';
11
+
12
+ describe('Support for languages', () => {
13
+ it('should return undefined for non symbol layers', () => {
14
+ mlLayerTypes
15
+ .filter((l) => l !== 'symbol')
16
+ .forEach((type) => {
17
+ const layer = {
18
+ id: 'aLayer',
19
+ type,
20
+ } as LayerSpecification;
21
+
22
+ expect(TMSService.transformLanguageProperty(layer, 'en')).toBeUndefined();
23
+ });
24
+ });
25
+
26
+ it('should return undefined for non layers without a layout', () => {
27
+ const layer = {
28
+ id: 'aLayer',
29
+ type: 'symbol',
30
+ } as LayerSpecification;
31
+
32
+ expect(TMSService.transformLanguageProperty(layer, 'en')).toBeUndefined();
33
+ });
34
+
35
+ it('should return nothing for inexistent languages', () => {
36
+ const enDashLayer = {
37
+ id: 'sampLayer',
38
+ type: 'symbol',
39
+ layout: {
40
+ 'text-field': '{name_en}',
41
+ },
42
+ } as LayerSpecification;
43
+ const invalidLang = 'I_DONT_EXIST';
44
+
45
+ expect(TMSService.transformLanguageProperty(enDashLayer, invalidLang)).toBeUndefined();
46
+ });
47
+
48
+ it('should handle {name_XX} and {name:XX} definitions', () => {
49
+ const enDashLayer = {
50
+ id: 'sampLayer',
51
+ type: 'symbol',
52
+ layout: {
53
+ 'text-field': '{name_en}',
54
+ },
55
+ } as LayerSpecification;
56
+
57
+ const transformLangEn = TMSService.transformLanguageProperty(enDashLayer, 'en');
58
+
59
+ expect(transformLangEn).toEqual(['coalesce', ['get', 'name:en'], ['get', 'name_en']]);
60
+ const enColonLayer = {
61
+ id: 'sampLayer',
62
+ type: 'symbol',
63
+ layout: {
64
+ 'text-field': '{name:en}',
65
+ },
66
+ } as LayerSpecification;
67
+
68
+ const transformLangJa = TMSService.transformLanguageProperty(enColonLayer, 'ja-jp');
69
+
70
+ expect(transformLangJa).toEqual(['coalesce', ['get', 'name:ja'], ['get', 'name:en']]);
71
+ });
72
+
73
+ it('should handle {name:latin}\\n{name:nonlatin} definitions', () => {
74
+ const layer = {
75
+ id: 'sampLayer',
76
+ type: 'symbol',
77
+ layout: {
78
+ 'text-field': '{name:latin}\n{name:nonlatin}',
79
+ },
80
+ } as LayerSpecification;
81
+
82
+ const transform = TMSService.transformLanguageProperty(layer, 'ja-jp');
83
+
84
+ expect(transform).toEqual([
85
+ 'coalesce',
86
+ ['get', 'name:ja'],
87
+ ['concat', ['get', 'name:latin'], '\n', ['get', 'name:nonlatin']],
88
+ ]);
89
+ });
90
+
91
+ it('should handle {name:latin} {name:nonlatin} definitions', () => {
92
+ const layer = {
93
+ id: 'sampLayer',
94
+ type: 'symbol',
95
+ layout: {
96
+ 'text-field': '{name:latin} {name:nonlatin}',
97
+ },
98
+ } as LayerSpecification;
99
+
100
+ const transform = TMSService.transformLanguageProperty(layer, 'ja-jp');
101
+
102
+ expect(transform).toEqual([
103
+ 'coalesce',
104
+ ['get', 'name:ja'],
105
+ ['concat', ['get', 'name:latin'], '\n', ['get', 'name:nonlatin']],
106
+ ]);
107
+ });
108
+
109
+ it('should handle text field properties that are not translated', () => {
110
+ const layer = {
111
+ id: 'sampLayer',
112
+ type: 'symbol',
113
+ layout: {
114
+ 'text-field': '{ref}',
115
+ },
116
+ } as LayerSpecification;
117
+
118
+ const transform = TMSService.transformLanguageProperty(layer, 'ja-jp');
119
+
120
+ expect(transform).toBe('{ref}');
121
+ });
122
+ });
@@ -94,3 +94,15 @@ export function getEMSClient(options = {}) {
94
94
  });
95
95
  return { emsClient, getManifestMock };
96
96
  }
97
+
98
+ export const mlLayerTypes = [
99
+ 'background',
100
+ 'circle',
101
+ 'fill-extrusion',
102
+ 'fill',
103
+ 'heatmap',
104
+ 'hillshade',
105
+ 'line',
106
+ 'raster',
107
+ 'symbol',
108
+ ];
@@ -19,8 +19,8 @@
19
19
  4
20
20
  ],
21
21
  "description": "A tileset showcasing all layers in OpenMapTiles. https://openmaptiles.org",
22
- "maxzoom": 10,
23
- "minzoom": 0,
22
+ "maxzoom": 15,
23
+ "minzoom": 3,
24
24
  "pixel_scale": "256",
25
25
  "vector_layers": [
26
26
  {