@india-boundary-corrector/service-worker 0.0.5 → 0.1.0
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.
- package/README.md +4 -3
- package/dist/index.global.js +93 -98
- package/dist/index.global.js.map +1 -1
- package/dist/india_boundary_corrections.pmtiles +0 -0
- package/dist/india_boundary_corrections.pmtiles.gz +0 -0
- package/dist/worker.global.js +615 -128
- package/dist/worker.global.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -75,8 +75,9 @@ await sw.addLayerConfig(new LayerConfig({
|
|
|
75
75
|
tileUrlTemplates: ['https://tile.openstreetmap.de/{z}/{x}/{y}.png'],
|
|
76
76
|
lineWidthStops: { 1: 0.5, 2: 0.6, 3: 0.7, 4: 1.0, 10: 3.75 },
|
|
77
77
|
lineStyles: [
|
|
78
|
-
|
|
79
|
-
{ color: 'rgb(
|
|
78
|
+
// layerSuffix determines which PMTiles layer to use
|
|
79
|
+
{ color: 'rgb(180, 200, 180)', layerSuffix: 'osm' },
|
|
80
|
+
{ color: 'rgb(121, 146, 127)', layerSuffix: 'osm', widthFraction: 1/3, dashArray: [30, 2, 8, 2] },
|
|
80
81
|
],
|
|
81
82
|
}));
|
|
82
83
|
```
|
|
@@ -126,7 +127,7 @@ importScripts('https://cdn.jsdelivr.net/npm/@india-boundary-corrector/service-wo
|
|
|
126
127
|
await sw.addLayerConfig(new LayerConfig({
|
|
127
128
|
id: 'my-tiles',
|
|
128
129
|
tileUrlTemplates: ['https://mytiles.example.com/{z}/{x}/{y}.png'],
|
|
129
|
-
lineStyles: [{ color: 'rgb(165, 180, 165)' }],
|
|
130
|
+
lineStyles: [{ color: 'rgb(165, 180, 165)', layerSuffix: 'osm' }],
|
|
130
131
|
}));
|
|
131
132
|
});
|
|
132
133
|
</script>
|
package/dist/index.global.js
CHANGED
|
@@ -33,7 +33,6 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
33
33
|
var configs_default = [
|
|
34
34
|
{
|
|
35
35
|
id: "cartodb-dark",
|
|
36
|
-
zoomThreshold: 5,
|
|
37
36
|
tileUrlTemplates: [
|
|
38
37
|
"https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png",
|
|
39
38
|
"https://basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png",
|
|
@@ -42,15 +41,17 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
42
41
|
"https://basemaps.cartocdn.com/dark_nolabels/{z}/{x}/{y}{r}.png",
|
|
43
42
|
"https://cartodb-basemaps-{s}.global.ssl.fastly.net/dark_nolabels/{z}/{x}/{y}{r}.png"
|
|
44
43
|
],
|
|
45
|
-
lineWidthStops: { "1":
|
|
44
|
+
lineWidthStops: { "0": 1, "2": 1, "3": 1, "10": 2.5 },
|
|
46
45
|
lineStyles: [
|
|
47
|
-
{ color: "rgb(40, 40, 40)" }
|
|
46
|
+
{ color: "rgb(40, 40, 40)", layerSuffix: "ne", endZoom: 4 },
|
|
47
|
+
{ color: "rgb(40, 40, 40)", layerSuffix: "ne-disp", endZoom: 4 },
|
|
48
|
+
{ color: "rgb(40, 40, 40)", layerSuffix: "osm", startZoom: 5 },
|
|
49
|
+
{ color: "rgb(40, 40, 40)", layerSuffix: "osm-disp", startZoom: 5 },
|
|
50
|
+
{ color: "rgb(40, 40, 40)", layerSuffix: "osm-internal", startZoom: 4, widthFraction: 0.3, dashArray: [2, 2] }
|
|
48
51
|
]
|
|
49
52
|
},
|
|
50
53
|
{
|
|
51
54
|
id: "cartodb-light",
|
|
52
|
-
startZoom: 0,
|
|
53
|
-
zoomThreshold: 5,
|
|
54
55
|
tileUrlTemplates: [
|
|
55
56
|
"https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png",
|
|
56
57
|
"https://basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png",
|
|
@@ -65,56 +66,62 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
65
66
|
"https://{s}.basemaps.cartocdn.com/rastertiles/voyager_labels_under/{z}/{x}/{y}{r}.png",
|
|
66
67
|
"https://basemaps.cartocdn.com/rastertiles/voyager_labels_under/{z}/{x}/{y}{r}.png"
|
|
67
68
|
],
|
|
68
|
-
lineWidthStops: { "1": 0.
|
|
69
|
+
lineWidthStops: { "1": 0.5, "2": 0.5, "3": 0.5, "4": 1, "5": 1.25, "7": 1.5, "16": 2.5 },
|
|
69
70
|
lineStyles: [
|
|
70
|
-
{ color: "rgb(235, 214, 214)",
|
|
71
|
-
{ color: "rgb(235, 214, 214)" }
|
|
71
|
+
{ color: "rgb(235, 214, 214)", layerSuffix: "ne", endZoom: 4, lineExtensionFactor: 0.1, delWidthFactor: 2 },
|
|
72
|
+
{ color: "rgb(235, 214, 214)", layerSuffix: "ne-disp", endZoom: 4, lineExtensionFactor: 0 },
|
|
73
|
+
{ color: "rgb(235, 214, 214)", layerSuffix: "osm", alpha: 0.2, startZoom: 6, widthFraction: 3, lineExtensionFactor: 0.1 },
|
|
74
|
+
{ color: "rgb(235, 214, 214)", layerSuffix: "osm", startZoom: 5, lineExtensionFactor: 0.1 },
|
|
75
|
+
{ color: "rgb(235, 214, 214)", layerSuffix: "osm-disp", alpha: 0.2, startZoom: 6, widthFraction: 3, lineExtensionFactor: 0 },
|
|
76
|
+
{ color: "rgb(235, 214, 214)", layerSuffix: "osm-disp", startZoom: 5, lineExtensionFactor: 0 },
|
|
77
|
+
{ color: "rgb(235, 214, 214)", layerSuffix: "osm-internal", startZoom: 4, widthFraction: 0.75, dashArray: [2, 2], delWidthFactor: 2 }
|
|
72
78
|
]
|
|
73
79
|
},
|
|
74
80
|
{
|
|
75
81
|
id: "open-topo",
|
|
76
|
-
startZoom: 4,
|
|
77
|
-
zoomThreshold: 4,
|
|
78
82
|
tileUrlTemplates: [
|
|
79
83
|
"https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png",
|
|
80
84
|
"https://tile.opentopomap.org/{z}/{x}/{y}.png"
|
|
81
85
|
],
|
|
82
86
|
lineWidthStops: { "4": 0.75, "5": 1, "6": 1.25, "7": 1.5, "8": 1.75, "9": 1.25, "10": 1.25, "13": 1.5 },
|
|
83
87
|
lineStyles: [
|
|
84
|
-
{ color: "rgb(83, 83, 83)",
|
|
85
|
-
{ color: "rgb(
|
|
86
|
-
{ color: "rgb(
|
|
87
|
-
{ color: "rgb(
|
|
88
|
+
{ color: "rgb(83, 83, 83)", layerSuffix: "ne", startZoom: 4, endZoom: 6 },
|
|
89
|
+
{ color: "rgb(173, 173, 173)", layerSuffix: "osm", startZoom: 7, endZoom: 8, alpha: 0.5, widthFraction: 4 },
|
|
90
|
+
{ color: "rgb(83, 83, 83)", layerSuffix: "osm", startZoom: 7, endZoom: 8 },
|
|
91
|
+
{ color: "rgb(199, 158, 204)", layerSuffix: "osm", startZoom: 9, widthFraction: 7, alpha: 0.6, lineExtensionFactor: 0.2 },
|
|
92
|
+
{ color: "rgb(175, 41, 203)", layerSuffix: "osm", startZoom: 9, lineExtensionFactor: 0.2 }
|
|
88
93
|
]
|
|
89
94
|
},
|
|
90
95
|
{
|
|
91
96
|
id: "osm-carto",
|
|
92
|
-
startZoom: 1,
|
|
93
|
-
zoomThreshold: 1,
|
|
94
97
|
tileUrlTemplates: [
|
|
95
98
|
"https://tile.openstreetmap.org/{z}/{x}/{y}.png",
|
|
96
99
|
"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
|
97
100
|
],
|
|
98
101
|
lineWidthStops: { "1": 0.5, "2": 0.6, "3": 0.7, "4": 1, "10": 3.75 },
|
|
99
102
|
lineStyles: [
|
|
100
|
-
{ color: "rgb(200, 180, 200)" },
|
|
101
|
-
{ color: "rgb(
|
|
103
|
+
{ color: "rgb(200, 180, 200)", layerSuffix: "osm", startZoom: 1, endZoom: 3, delWidthFactor: 2.5, widthFraction: 1.5 },
|
|
104
|
+
{ color: "rgb(200, 180, 200)", layerSuffix: "osm", startZoom: 4 },
|
|
105
|
+
{ color: "rgb(160, 120, 160)", layerSuffix: "osm", startZoom: 4, widthFraction: 0.333, dashArray: [30, 2, 8, 2] },
|
|
106
|
+
{ color: "rgb(200, 180, 200)", layerSuffix: "osm-internal", startZoom: 4, widthFraction: 0.45 },
|
|
107
|
+
{ color: "rgb(160, 120, 160)", layerSuffix: "osm-internal", startZoom: 4, widthFraction: 0.15, dashArray: [4, 2, 10] }
|
|
102
108
|
]
|
|
103
109
|
},
|
|
104
110
|
{
|
|
105
111
|
id: "osm-hot",
|
|
106
|
-
startZoom: 2,
|
|
107
|
-
zoomThreshold: 2,
|
|
108
112
|
tileUrlTemplates: [
|
|
109
|
-
"https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png"
|
|
113
|
+
"https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png",
|
|
114
|
+
"https://tile.openstreetmap.fr/hot/{z}/{x}/{y}.png"
|
|
110
115
|
],
|
|
111
116
|
lineWidthStops: { "2": 3, "3": 3, "7": 3, "8": 3.5, "9": 3.5 },
|
|
112
117
|
lineStyles: [
|
|
113
|
-
{ color: "rgb(149, 175, 180)" },
|
|
114
|
-
{ color: "rgb(89, 117, 123)", widthFraction: 0.33 }
|
|
118
|
+
{ color: "rgb(149, 175, 180)", layerSuffix: "osm", lineExtensionFactor: 0.25, startZoom: 2 },
|
|
119
|
+
{ color: "rgb(89, 117, 123)", layerSuffix: "osm", widthFraction: 0.33, lineExtensionFactor: 0.25, startZoom: 2 },
|
|
120
|
+
{ color: "rgb(172, 163, 163)", layerSuffix: "osm-internal", widthFraction: 0.33, startZoom: 4, dashArray: [7, 7, 7] }
|
|
115
121
|
]
|
|
116
122
|
}
|
|
117
123
|
];
|
|
124
|
+
var INFINITY = -1;
|
|
118
125
|
function templateToRegex(template) {
|
|
119
126
|
const groups = [];
|
|
120
127
|
let pattern = template.replace(/[.*+?^${}()|[\]\\]/g, (char) => {
|
|
@@ -181,6 +188,9 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
181
188
|
if (!isValidColor(obj.color)) {
|
|
182
189
|
throw new Error(`${prefix}: color "${obj.color}" is not a valid CSS color`);
|
|
183
190
|
}
|
|
191
|
+
if (!obj.layerSuffix || typeof obj.layerSuffix !== "string") {
|
|
192
|
+
throw new Error(`${prefix}: layerSuffix must be a non-empty string`);
|
|
193
|
+
}
|
|
184
194
|
if (obj.widthFraction !== void 0 && (typeof obj.widthFraction !== "number" || obj.widthFraction <= 0)) {
|
|
185
195
|
throw new Error(`${prefix}: widthFraction must be a positive number`);
|
|
186
196
|
}
|
|
@@ -193,26 +203,38 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
193
203
|
if (obj.startZoom !== void 0 && (typeof obj.startZoom !== "number" || obj.startZoom < 0)) {
|
|
194
204
|
throw new Error(`${prefix}: startZoom must be a non-negative number`);
|
|
195
205
|
}
|
|
196
|
-
if (obj.endZoom !== void 0 && (typeof obj.endZoom !== "number" || obj.endZoom < 0)) {
|
|
197
|
-
throw new Error(`${prefix}: endZoom must be a non-negative number`);
|
|
206
|
+
if (obj.endZoom !== void 0 && (typeof obj.endZoom !== "number" || obj.endZoom < 0 && obj.endZoom !== INFINITY)) {
|
|
207
|
+
throw new Error(`${prefix}: endZoom must be a non-negative number or INFINITY (${INFINITY})`);
|
|
208
|
+
}
|
|
209
|
+
if (obj.lineExtensionFactor !== void 0 && (typeof obj.lineExtensionFactor !== "number" || obj.lineExtensionFactor < 0)) {
|
|
210
|
+
throw new Error(`${prefix}: lineExtensionFactor must be a non-negative number`);
|
|
211
|
+
}
|
|
212
|
+
if (obj.delWidthFactor !== void 0 && (typeof obj.delWidthFactor !== "number" || obj.delWidthFactor < 0)) {
|
|
213
|
+
throw new Error(`${prefix}: delWidthFactor must be a non-negative number`);
|
|
198
214
|
}
|
|
199
215
|
}
|
|
200
216
|
/**
|
|
201
217
|
* @param {Object} options
|
|
202
218
|
* @param {string} options.color - CSS color string
|
|
219
|
+
* @param {string} options.layerSuffix - Layer suffix (e.g., 'osm', 'ne', 'osm-disp')
|
|
203
220
|
* @param {number} [options.widthFraction=1.0] - Multiplier for base line width
|
|
204
221
|
* @param {number[]} [options.dashArray] - Dash pattern for dashed lines
|
|
205
222
|
* @param {number} [options.alpha=1.0] - Opacity (0-1)
|
|
206
|
-
* @param {number} [options.startZoom] - Minimum zoom level for this style
|
|
207
|
-
* @param {number} [options.endZoom=
|
|
223
|
+
* @param {number} [options.startZoom=0] - Minimum zoom level for this style
|
|
224
|
+
* @param {number} [options.endZoom=INFINITY] - Maximum zoom level for this style (INFINITY means no limit)
|
|
225
|
+
* @param {number} [options.lineExtensionFactor=0.5] - Factor to extend lines by (multiplied by deletion line width)
|
|
226
|
+
* @param {number} [options.delWidthFactor=1.5] - Factor to multiply line width for deletion blur
|
|
208
227
|
*/
|
|
209
|
-
constructor({ color, widthFraction = 1, dashArray, alpha = 1, startZoom, endZoom =
|
|
228
|
+
constructor({ color, layerSuffix, widthFraction = 1, dashArray, alpha = 1, startZoom = 0, endZoom = INFINITY, lineExtensionFactor = 0.5, delWidthFactor = 1.5 }) {
|
|
210
229
|
this.color = color;
|
|
230
|
+
this.layerSuffix = layerSuffix;
|
|
211
231
|
this.widthFraction = widthFraction;
|
|
212
232
|
this.dashArray = dashArray;
|
|
213
233
|
this.alpha = alpha;
|
|
214
234
|
this.startZoom = startZoom;
|
|
215
235
|
this.endZoom = endZoom;
|
|
236
|
+
this.lineExtensionFactor = lineExtensionFactor;
|
|
237
|
+
this.delWidthFactor = delWidthFactor;
|
|
216
238
|
}
|
|
217
239
|
/**
|
|
218
240
|
* Check if this style is active at the given zoom level.
|
|
@@ -220,34 +242,34 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
220
242
|
* @returns {boolean}
|
|
221
243
|
*/
|
|
222
244
|
isActiveAtZoom(z) {
|
|
223
|
-
return z >= this.startZoom && z <= this.endZoom;
|
|
245
|
+
return z >= this.startZoom && (this.endZoom === INFINITY || z <= this.endZoom);
|
|
224
246
|
}
|
|
225
247
|
/**
|
|
226
248
|
* Serialize to plain object.
|
|
227
249
|
* @returns {Object}
|
|
228
250
|
*/
|
|
229
251
|
toJSON() {
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
252
|
+
return {
|
|
253
|
+
color: this.color,
|
|
254
|
+
layerSuffix: this.layerSuffix,
|
|
255
|
+
widthFraction: this.widthFraction,
|
|
256
|
+
dashArray: this.dashArray,
|
|
257
|
+
alpha: this.alpha,
|
|
258
|
+
startZoom: this.startZoom,
|
|
259
|
+
endZoom: this.endZoom,
|
|
260
|
+
lineExtensionFactor: this.lineExtensionFactor,
|
|
261
|
+
delWidthFactor: this.delWidthFactor
|
|
262
|
+
};
|
|
237
263
|
}
|
|
238
264
|
/**
|
|
239
265
|
* Create from plain object with validation.
|
|
240
266
|
* @param {Object} obj
|
|
241
|
-
* @param {number} [defaultStartZoom=0] - Default startZoom if not specified
|
|
242
267
|
* @param {number} [index] - Optional index for error messages
|
|
243
268
|
* @returns {LineStyle}
|
|
244
269
|
*/
|
|
245
|
-
static fromJSON(obj,
|
|
270
|
+
static fromJSON(obj, index) {
|
|
246
271
|
_LineStyle.validateJSON(obj, index);
|
|
247
|
-
return new _LineStyle(
|
|
248
|
-
...obj,
|
|
249
|
-
startZoom: obj.startZoom ?? defaultStartZoom
|
|
250
|
-
});
|
|
272
|
+
return new _LineStyle(obj);
|
|
251
273
|
}
|
|
252
274
|
};
|
|
253
275
|
var LayerConfig = class _LayerConfig {
|
|
@@ -268,17 +290,6 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
268
290
|
throw new Error(`LayerConfig: id cannot contain slashes: "${obj.id}"`);
|
|
269
291
|
}
|
|
270
292
|
const id = obj.id;
|
|
271
|
-
if (obj.startZoom !== void 0 && (typeof obj.startZoom !== "number" || obj.startZoom < 0)) {
|
|
272
|
-
throw new Error(`LayerConfig "${id}": startZoom must be a non-negative number`);
|
|
273
|
-
}
|
|
274
|
-
if (obj.zoomThreshold !== void 0 && (typeof obj.zoomThreshold !== "number" || obj.zoomThreshold < 0)) {
|
|
275
|
-
throw new Error(`LayerConfig "${id}": zoomThreshold must be a non-negative number`);
|
|
276
|
-
}
|
|
277
|
-
const startZoom = obj.startZoom ?? 0;
|
|
278
|
-
const zoomThreshold = obj.zoomThreshold ?? 5;
|
|
279
|
-
if (startZoom > zoomThreshold) {
|
|
280
|
-
throw new Error(`LayerConfig "${id}": startZoom (${startZoom}) must be <= zoomThreshold (${zoomThreshold})`);
|
|
281
|
-
}
|
|
282
293
|
if (obj.lineWidthStops !== void 0) {
|
|
283
294
|
if (!obj.lineWidthStops || typeof obj.lineWidthStops !== "object" || Array.isArray(obj.lineWidthStops)) {
|
|
284
295
|
throw new Error(`LayerConfig "${id}": lineWidthStops must be an object`);
|
|
@@ -297,59 +308,35 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
297
308
|
}
|
|
298
309
|
}
|
|
299
310
|
}
|
|
300
|
-
if (obj.lineStyles
|
|
301
|
-
|
|
302
|
-
throw new Error(`LayerConfig "${id}": lineStyles must be a non-empty array`);
|
|
303
|
-
}
|
|
304
|
-
for (let i = 0; i < obj.lineStyles.length; i++) {
|
|
305
|
-
LineStyle.validateJSON(obj.lineStyles[i], i);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
if (obj.delWidthFactor !== void 0 && (typeof obj.delWidthFactor !== "number" || obj.delWidthFactor <= 0)) {
|
|
309
|
-
throw new Error(`LayerConfig "${id}": delWidthFactor must be a positive number`);
|
|
311
|
+
if (!Array.isArray(obj.lineStyles) || obj.lineStyles.length === 0) {
|
|
312
|
+
throw new Error(`LayerConfig "${id}": lineStyles must be a non-empty array`);
|
|
310
313
|
}
|
|
311
|
-
|
|
312
|
-
|
|
314
|
+
for (let i = 0; i < obj.lineStyles.length; i++) {
|
|
315
|
+
LineStyle.validateJSON(obj.lineStyles[i], i);
|
|
313
316
|
}
|
|
314
317
|
}
|
|
315
318
|
constructor({
|
|
316
319
|
id,
|
|
317
|
-
startZoom = 0,
|
|
318
|
-
zoomThreshold = 5,
|
|
319
320
|
// Tile URL templates for matching (e.g., "https://{s}.tile.example.com/{z}/{x}/{y}.png")
|
|
320
321
|
tileUrlTemplates = [],
|
|
321
322
|
// Line width stops: map of zoom level to line width (at least 2 entries)
|
|
322
323
|
// Note: interpolated/extrapolated line width is capped at a minimum of 0.5
|
|
323
324
|
lineWidthStops = { 1: 0.5, 10: 2.5 },
|
|
324
|
-
// Line styles array - each element describes a line to draw
|
|
325
|
-
// { color: string, widthFraction?: number, dashArray?: number[],
|
|
326
|
-
//
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
// Higher values leave gaps where wiped lines meet existing lines
|
|
330
|
-
// Lower values mean wiped lines show through
|
|
331
|
-
delWidthFactor = 1.5,
|
|
332
|
-
// Factor to extend add lines by (multiplied by deletion line width)
|
|
333
|
-
// Helps cover gaps where deleted lines meet the new boundary
|
|
334
|
-
// Set to 0 to disable extension
|
|
335
|
-
lineExtensionFactor = 0.5
|
|
325
|
+
// Line styles array - each element describes a line to draw from a specific layer
|
|
326
|
+
// { color: string, layerSuffix: string, widthFraction?: number, dashArray?: number[],
|
|
327
|
+
// startZoom?: number, endZoom?: number, lineExtensionFactor?: number, delWidthFactor?: number }
|
|
328
|
+
// Lines are drawn in array order. layerSuffix determines which PMTiles layer to use.
|
|
329
|
+
lineStyles
|
|
336
330
|
}) {
|
|
337
331
|
this.id = id;
|
|
338
|
-
this.startZoom = startZoom;
|
|
339
|
-
this.zoomThreshold = zoomThreshold;
|
|
340
332
|
const templates = Array.isArray(tileUrlTemplates) ? tileUrlTemplates : tileUrlTemplates ? [tileUrlTemplates] : [];
|
|
341
333
|
this.tileUrlTemplates = templates;
|
|
342
334
|
this._compiledPatterns = templates.map((t) => templateToRegex(t));
|
|
343
335
|
this._templatePatterns = templates.map((t) => templateToTemplateRegex(t));
|
|
344
336
|
this.lineWidthStops = lineWidthStops;
|
|
345
337
|
this.lineStyles = lineStyles.map(
|
|
346
|
-
(style) => style instanceof LineStyle ? style : new LineStyle(
|
|
347
|
-
...style,
|
|
348
|
-
startZoom: style.startZoom ?? startZoom
|
|
349
|
-
})
|
|
338
|
+
(style) => style instanceof LineStyle ? style : new LineStyle(style)
|
|
350
339
|
);
|
|
351
|
-
this.delWidthFactor = delWidthFactor;
|
|
352
|
-
this.lineExtensionFactor = lineExtensionFactor;
|
|
353
340
|
}
|
|
354
341
|
/**
|
|
355
342
|
* Get line styles active at a given zoom level
|
|
@@ -359,6 +346,15 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
359
346
|
getLineStylesForZoom(z) {
|
|
360
347
|
return this.lineStyles.filter((style) => style.isActiveAtZoom(z));
|
|
361
348
|
}
|
|
349
|
+
/**
|
|
350
|
+
* Get unique layer suffixes from styles active at a given zoom level
|
|
351
|
+
* @param {number} z - Zoom level
|
|
352
|
+
* @returns {string[]}
|
|
353
|
+
*/
|
|
354
|
+
getLayerSuffixesForZoom(z) {
|
|
355
|
+
const activeStyles = this.getLineStylesForZoom(z);
|
|
356
|
+
return [...new Set(activeStyles.map((s) => s.layerSuffix))];
|
|
357
|
+
}
|
|
362
358
|
/**
|
|
363
359
|
* Check if this config matches the given template URLs (with {z}/{x}/{y} placeholders)
|
|
364
360
|
* @param {string | string[]} templates - Single template URL or array of template URLs
|
|
@@ -416,13 +412,9 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
416
412
|
toJSON() {
|
|
417
413
|
return {
|
|
418
414
|
id: this.id,
|
|
419
|
-
startZoom: this.startZoom,
|
|
420
|
-
zoomThreshold: this.zoomThreshold,
|
|
421
415
|
tileUrlTemplates: this.tileUrlTemplates,
|
|
422
416
|
lineWidthStops: this.lineWidthStops,
|
|
423
|
-
lineStyles: this.lineStyles.map((s) => s.toJSON())
|
|
424
|
-
delWidthFactor: this.delWidthFactor,
|
|
425
|
-
lineExtensionFactor: this.lineExtensionFactor
|
|
417
|
+
lineStyles: this.lineStyles.map((s) => s.toJSON())
|
|
426
418
|
};
|
|
427
419
|
}
|
|
428
420
|
/**
|
|
@@ -528,7 +520,7 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
528
520
|
}
|
|
529
521
|
|
|
530
522
|
// ../data/version.js
|
|
531
|
-
var packageVersion = "0.0
|
|
523
|
+
var packageVersion = "0.1.0";
|
|
532
524
|
|
|
533
525
|
// ../data/index.js
|
|
534
526
|
var import_meta = {};
|
|
@@ -549,14 +541,17 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
549
541
|
scriptUrl = CURRENT_SCRIPT_URL;
|
|
550
542
|
}
|
|
551
543
|
if (scriptUrl) {
|
|
552
|
-
|
|
553
|
-
if (FALLBACK_CDNS.has(moduleUrl.hostname)) {
|
|
554
|
-
return DEFAULT_CDN_URL;
|
|
555
|
-
}
|
|
556
|
-
return new URL(PMTILES_FILENAME, moduleUrl).href;
|
|
544
|
+
return resolvePmtilesUrl(scriptUrl);
|
|
557
545
|
}
|
|
558
546
|
return DEFAULT_CDN_URL;
|
|
559
547
|
}
|
|
548
|
+
function resolvePmtilesUrl(scriptUrl) {
|
|
549
|
+
const moduleUrl = new URL(".", scriptUrl);
|
|
550
|
+
if (FALLBACK_CDNS.has(moduleUrl.hostname)) {
|
|
551
|
+
return DEFAULT_CDN_URL;
|
|
552
|
+
}
|
|
553
|
+
return new URL(PMTILES_FILENAME, moduleUrl).href;
|
|
554
|
+
}
|
|
560
555
|
var cachedPmtilesUrl = null;
|
|
561
556
|
function getPmtilesUrl() {
|
|
562
557
|
if (cachedPmtilesUrl === null) {
|