@india-boundary-corrector/openlayers-layer 0.2.0 → 0.2.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.
- package/dist/index.global.js +191 -118
- package/dist/index.global.js.map +1 -1
- package/package.json +4 -4
package/dist/index.global.js
CHANGED
|
@@ -12052,7 +12052,7 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
12052
12052
|
var ImageTile_default2 = ImageTileSource;
|
|
12053
12053
|
|
|
12054
12054
|
// ../data/version.js
|
|
12055
|
-
var packageVersion = "0.2.
|
|
12055
|
+
var packageVersion = "0.2.2";
|
|
12056
12056
|
|
|
12057
12057
|
// ../data/index.js
|
|
12058
12058
|
var import_meta = {};
|
|
@@ -12150,12 +12150,11 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
12150
12150
|
"https://{s}.basemaps.cartocdn.com/rastertiles/voyager_labels_under/{z}/{x}/{y}.png",
|
|
12151
12151
|
"https://basemaps.cartocdn.com/rastertiles/voyager_labels_under/{z}/{x}/{y}.png"
|
|
12152
12152
|
],
|
|
12153
|
-
lineWidthStops: { "1": 0.5, "2": 0.75, "3": 0.75, "4": 1, "5": 1, "7": 1.
|
|
12153
|
+
lineWidthStops: { "1": 0.5, "2": 0.75, "3": 0.75, "4": 1, "5": 1, "7": 1.75, "16": 2.5 },
|
|
12154
12154
|
lineStyles: [
|
|
12155
12155
|
{ color: "rgb(235, 214, 214)", layerSuffix: "ne", endZoom: 4, lineExtensionFactor: 0.1, delWidthFactor: 2.5 },
|
|
12156
12156
|
{ color: "rgb(235, 214, 214)", layerSuffix: "ne-disp", endZoom: 4, delWidthFactor: 0 },
|
|
12157
|
-
{ color: "rgb(235, 214, 214)", layerSuffix: "osm", alpha: 0.
|
|
12158
|
-
{ color: "rgb(235, 214, 214)", layerSuffix: "osm", alpha: 0.2, startZoom: 12, widthFraction: 4, lineExtensionFactor: 0.1 },
|
|
12157
|
+
{ color: "rgb(235, 214, 214)", layerSuffix: "osm", alpha: 0.1, startZoom: 6, lineWidthStops: { "6": 9, "10": 8, "14": 8 }, lineExtensionFactor: 0.1 },
|
|
12159
12158
|
{ color: "rgb(235, 214, 214)", layerSuffix: "osm", startZoom: 5, lineExtensionFactor: 0.1 },
|
|
12160
12159
|
{ color: "rgb(235, 214, 214)", layerSuffix: "osm-disp", startZoom: 5, delWidthFactor: 0 },
|
|
12161
12160
|
{ color: "rgb(235, 214, 214)", layerSuffix: "osm-internal", startZoom: 5, widthFraction: 0.5, dashArray: [2, 2], delWidthFactor: 2 },
|
|
@@ -12178,12 +12177,11 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
12178
12177
|
"https://{s}.basemaps.cartocdn.com/rastertiles/voyager_labels_under/{z}/{x}/{y}{r}.png",
|
|
12179
12178
|
"https://basemaps.cartocdn.com/rastertiles/voyager_labels_under/{z}/{x}/{y}{r}.png"
|
|
12180
12179
|
],
|
|
12181
|
-
lineWidthStops: { "1":
|
|
12180
|
+
lineWidthStops: { "1": 1, "3": 1, "4": 2, "5": 2, "6": 2.5, "7": 3, "8": 3, "10": 4, "11": 4, "12": 4 },
|
|
12182
12181
|
lineStyles: [
|
|
12183
12182
|
{ color: "rgb(235, 214, 214)", layerSuffix: "ne", endZoom: 4, lineExtensionFactor: 0.1, delWidthFactor: 2.5 },
|
|
12184
12183
|
{ color: "rgb(235, 214, 214)", layerSuffix: "ne-disp", endZoom: 4, delWidthFactor: 0 },
|
|
12185
|
-
{ color: "rgb(235, 214, 214)", layerSuffix: "osm", alpha: 0.1, startZoom: 6,
|
|
12186
|
-
{ color: "rgb(235, 214, 214)", layerSuffix: "osm", alpha: 0.1, startZoom: 12, widthFraction: 4, lineExtensionFactor: 0.1 },
|
|
12184
|
+
{ color: "rgb(235, 214, 214)", layerSuffix: "osm", alpha: 0.1, startZoom: 6, lineWidthStops: { "6": 20, "8": 19, "10": 18, "12": 17 }, lineExtensionFactor: 0.1 },
|
|
12187
12185
|
{ color: "rgb(235, 214, 214)", layerSuffix: "osm", startZoom: 5, lineExtensionFactor: 0.1 },
|
|
12188
12186
|
{ color: "rgb(235, 214, 214)", layerSuffix: "osm-disp", startZoom: 5, delWidthFactor: 0 },
|
|
12189
12187
|
{ color: "rgb(235, 214, 214)", layerSuffix: "osm-internal", startZoom: 5, widthFraction: 0.5, dashArray: [4, 4], delWidthFactor: 2 },
|
|
@@ -12194,15 +12192,20 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
12194
12192
|
id: "open-topo",
|
|
12195
12193
|
tileUrlTemplates: [
|
|
12196
12194
|
"https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png",
|
|
12197
|
-
"https://tile.opentopomap.org/{z}/{x}/{y}.png"
|
|
12195
|
+
"https://tile.opentopomap.org/{z}/{x}/{y}.png",
|
|
12196
|
+
"https://{s}.tile.top-o-map.de/{z}/{x}/{y}.png",
|
|
12197
|
+
"https://tile.top-o-map.de/{z}/{x}/{y}.png"
|
|
12198
12198
|
],
|
|
12199
12199
|
lineWidthStops: { "4": 0.75, "5": 1, "6": 1.25, "7": 1.5, "8": 1.75, "9": 1.25, "10": 1.25, "13": 1.5 },
|
|
12200
12200
|
lineStyles: [
|
|
12201
12201
|
{ color: "rgb(83, 83, 83)", layerSuffix: "ne", startZoom: 4, endZoom: 6 },
|
|
12202
12202
|
{ color: "rgb(173, 173, 173)", layerSuffix: "osm", startZoom: 7, endZoom: 8, alpha: 0.5, widthFraction: 4 },
|
|
12203
12203
|
{ color: "rgb(83, 83, 83)", layerSuffix: "osm", startZoom: 7, endZoom: 8 },
|
|
12204
|
+
{ color: "rgb(83, 83, 83)", layerSuffix: "osm-internal", widthFraction: 0.75, startZoom: 7, endZoom: 8 },
|
|
12204
12205
|
{ color: "rgb(199, 158, 204)", layerSuffix: "osm", startZoom: 9, widthFraction: 7, alpha: 0.6, lineExtensionFactor: 0.2 },
|
|
12205
|
-
{ color: "rgb(175, 41, 203)", layerSuffix: "osm", startZoom: 9, lineExtensionFactor: 0.2 }
|
|
12206
|
+
{ color: "rgb(175, 41, 203)", layerSuffix: "osm", startZoom: 9, lineExtensionFactor: 0.2 },
|
|
12207
|
+
{ color: "rgb(199, 158, 204)", layerSuffix: "osm-internal", startZoom: 9, widthFraction: 2.25, alpha: 0.6, lineExtensionFactor: 0.2 },
|
|
12208
|
+
{ color: "rgb(175, 41, 203)", layerSuffix: "osm-internal", startZoom: 9, widthFactor: 0.75, lineExtensionFactor: 0.2 }
|
|
12206
12209
|
]
|
|
12207
12210
|
},
|
|
12208
12211
|
{
|
|
@@ -12211,9 +12214,8 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
12211
12214
|
"https://tile.openstreetmap.org/{z}/{x}/{y}.png",
|
|
12212
12215
|
"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
|
12213
12216
|
],
|
|
12214
|
-
lineWidthStops: { "
|
|
12217
|
+
lineWidthStops: { "3": 0.7, "4": 1, "10": 3.75 },
|
|
12215
12218
|
lineStyles: [
|
|
12216
|
-
{ color: "rgb(200, 180, 200)", layerSuffix: "osm", startZoom: 1, endZoom: 3, delWidthFactor: 2.5, widthFraction: 1.5 },
|
|
12217
12219
|
{ color: "rgb(200, 180, 200)", layerSuffix: "osm", startZoom: 4, delWidthFactor: 1.5 },
|
|
12218
12220
|
{ color: "rgb(160, 120, 160)", layerSuffix: "osm", startZoom: 4, widthFraction: 0.333, dashArray: [30, 2, 8, 2], delWidthFactor: 0 },
|
|
12219
12221
|
{ color: "rgb(200, 180, 200)", layerSuffix: "osm-internal", startZoom: 4, widthFraction: 0.45 },
|
|
@@ -12237,6 +12239,39 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
12237
12239
|
var INFINITY = -1;
|
|
12238
12240
|
var MIN_LINE_WIDTH = 0.1;
|
|
12239
12241
|
var DEFAULT_LINE_WIDTH = 1;
|
|
12242
|
+
function interpolateLineWidth(zoom, lineWidthStops) {
|
|
12243
|
+
const zooms = Object.keys(lineWidthStops).map(Number).sort((a, b2) => a - b2);
|
|
12244
|
+
if (lineWidthStops[zoom] !== void 0) {
|
|
12245
|
+
return lineWidthStops[zoom];
|
|
12246
|
+
}
|
|
12247
|
+
if (zoom < zooms[0]) {
|
|
12248
|
+
const z1 = zooms[0];
|
|
12249
|
+
const z2 = zooms[1];
|
|
12250
|
+
const w1 = lineWidthStops[z1];
|
|
12251
|
+
const w2 = lineWidthStops[z2];
|
|
12252
|
+
const slope = (w2 - w1) / (z2 - z1);
|
|
12253
|
+
return Math.max(MIN_LINE_WIDTH, w1 + slope * (zoom - z1));
|
|
12254
|
+
}
|
|
12255
|
+
if (zoom > zooms[zooms.length - 1]) {
|
|
12256
|
+
const z1 = zooms[zooms.length - 2];
|
|
12257
|
+
const z2 = zooms[zooms.length - 1];
|
|
12258
|
+
const w1 = lineWidthStops[z1];
|
|
12259
|
+
const w2 = lineWidthStops[z2];
|
|
12260
|
+
const slope = (w2 - w1) / (z2 - z1);
|
|
12261
|
+
return Math.max(MIN_LINE_WIDTH, w2 + slope * (zoom - z2));
|
|
12262
|
+
}
|
|
12263
|
+
for (let i2 = 0; i2 < zooms.length - 1; i2++) {
|
|
12264
|
+
if (zoom > zooms[i2] && zoom < zooms[i2 + 1]) {
|
|
12265
|
+
const z1 = zooms[i2];
|
|
12266
|
+
const z2 = zooms[i2 + 1];
|
|
12267
|
+
const w1 = lineWidthStops[z1];
|
|
12268
|
+
const w2 = lineWidthStops[z2];
|
|
12269
|
+
const t = (zoom - z1) / (z2 - z1);
|
|
12270
|
+
return w1 + t * (w2 - w1);
|
|
12271
|
+
}
|
|
12272
|
+
}
|
|
12273
|
+
return DEFAULT_LINE_WIDTH;
|
|
12274
|
+
}
|
|
12240
12275
|
function templateToRegex(template) {
|
|
12241
12276
|
const groups = [];
|
|
12242
12277
|
const hasRetina = template.includes("{r}");
|
|
@@ -12303,14 +12338,33 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
12303
12338
|
if (/^[a-z]+$/.test(trimmed)) return true;
|
|
12304
12339
|
return false;
|
|
12305
12340
|
}
|
|
12341
|
+
function validateLineWidthStops(lineWidthStops, prefix) {
|
|
12342
|
+
if (!lineWidthStops || typeof lineWidthStops !== "object" || Array.isArray(lineWidthStops)) {
|
|
12343
|
+
throw new Error(`${prefix}: lineWidthStops must be an object`);
|
|
12344
|
+
}
|
|
12345
|
+
const stopKeys = Object.keys(lineWidthStops);
|
|
12346
|
+
if (stopKeys.length < 2) {
|
|
12347
|
+
throw new Error(`${prefix}: lineWidthStops must have at least 2 entries`);
|
|
12348
|
+
}
|
|
12349
|
+
for (const key of stopKeys) {
|
|
12350
|
+
const zoom = Number(key);
|
|
12351
|
+
if (!Number.isInteger(zoom) || zoom < 0) {
|
|
12352
|
+
throw new Error(`${prefix}: lineWidthStops keys must be non-negative integers, got "${key}"`);
|
|
12353
|
+
}
|
|
12354
|
+
if (typeof lineWidthStops[key] !== "number" || lineWidthStops[key] <= 0) {
|
|
12355
|
+
throw new Error(`${prefix}: lineWidthStops values must be positive numbers`);
|
|
12356
|
+
}
|
|
12357
|
+
}
|
|
12358
|
+
}
|
|
12306
12359
|
var LineStyle = class _LineStyle {
|
|
12307
12360
|
/**
|
|
12308
12361
|
* Validate a LineStyle configuration object.
|
|
12309
12362
|
* @param {Object} obj - The object to validate
|
|
12310
12363
|
* @param {number} [index] - Optional index for error messages (when validating in an array)
|
|
12364
|
+
* @param {boolean} [requireLineWidthStops=false] - Whether lineWidthStops is required
|
|
12311
12365
|
* @throws {Error} If validation fails
|
|
12312
12366
|
*/
|
|
12313
|
-
static validateJSON(obj, index) {
|
|
12367
|
+
static validateJSON(obj, index, requireLineWidthStops = false) {
|
|
12314
12368
|
const prefix = index !== void 0 ? `lineStyles[${index}]` : "LineStyle";
|
|
12315
12369
|
if (!obj || typeof obj !== "object") {
|
|
12316
12370
|
throw new Error(`${prefix}: must be an object`);
|
|
@@ -12345,22 +12399,30 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
12345
12399
|
if (obj.delWidthFactor !== void 0 && (typeof obj.delWidthFactor !== "number" || obj.delWidthFactor < 0)) {
|
|
12346
12400
|
throw new Error(`${prefix}: delWidthFactor must be a non-negative number`);
|
|
12347
12401
|
}
|
|
12402
|
+
if (requireLineWidthStops && obj.lineWidthStops === void 0) {
|
|
12403
|
+
throw new Error(`${prefix}: lineWidthStops is required`);
|
|
12404
|
+
}
|
|
12405
|
+
if (obj.lineWidthStops !== void 0) {
|
|
12406
|
+
validateLineWidthStops(obj.lineWidthStops, prefix);
|
|
12407
|
+
}
|
|
12348
12408
|
}
|
|
12349
12409
|
/**
|
|
12350
12410
|
* @param {Object} options
|
|
12351
12411
|
* @param {string} options.color - CSS color string
|
|
12352
12412
|
* @param {string} options.layerSuffix - Layer suffix (e.g., 'osm', 'ne', 'osm-disp')
|
|
12413
|
+
* @param {Object<number, number>} options.lineWidthStops - Line width stops for this style
|
|
12353
12414
|
* @param {number} [options.widthFraction=1.0] - Multiplier for base line width
|
|
12354
12415
|
* @param {number[]} [options.dashArray] - Dash pattern for dashed lines
|
|
12355
12416
|
* @param {number} [options.alpha=1.0] - Opacity (0-1)
|
|
12356
12417
|
* @param {number} [options.startZoom=0] - Minimum zoom level for this style
|
|
12357
12418
|
* @param {number} [options.endZoom=INFINITY] - Maximum zoom level for this style (INFINITY means no limit)
|
|
12358
|
-
* @param {number} [options.lineExtensionFactor=0.
|
|
12419
|
+
* @param {number} [options.lineExtensionFactor=0.0] - Factor to extend lines by (multiplied by deletion line width)
|
|
12359
12420
|
* @param {number} [options.delWidthFactor=1.5] - Factor to multiply line width for deletion blur
|
|
12360
12421
|
*/
|
|
12361
|
-
constructor({ color, layerSuffix, widthFraction = 1, dashArray, alpha = 1, startZoom = 0, endZoom = INFINITY, lineExtensionFactor = 0, delWidthFactor = 1.5 }) {
|
|
12422
|
+
constructor({ color, layerSuffix, lineWidthStops, widthFraction = 1, dashArray, alpha = 1, startZoom = 0, endZoom = INFINITY, lineExtensionFactor = 0, delWidthFactor = 1.5 }) {
|
|
12362
12423
|
this.color = color;
|
|
12363
12424
|
this.layerSuffix = layerSuffix;
|
|
12425
|
+
this.lineWidthStops = lineWidthStops;
|
|
12364
12426
|
this.widthFraction = widthFraction;
|
|
12365
12427
|
this.dashArray = dashArray;
|
|
12366
12428
|
this.alpha = alpha;
|
|
@@ -12369,6 +12431,14 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
12369
12431
|
this.lineExtensionFactor = lineExtensionFactor;
|
|
12370
12432
|
this.delWidthFactor = delWidthFactor;
|
|
12371
12433
|
}
|
|
12434
|
+
/**
|
|
12435
|
+
* Get base line width for this style at a given zoom level.
|
|
12436
|
+
* @param {number} zoom - Zoom level
|
|
12437
|
+
* @returns {number}
|
|
12438
|
+
*/
|
|
12439
|
+
getLineWidth(zoom) {
|
|
12440
|
+
return interpolateLineWidth(zoom, this.lineWidthStops);
|
|
12441
|
+
}
|
|
12372
12442
|
/**
|
|
12373
12443
|
* Check if this style is active at the given zoom level.
|
|
12374
12444
|
* @param {number} z - Zoom level
|
|
@@ -12385,6 +12455,7 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
12385
12455
|
return {
|
|
12386
12456
|
color: this.color,
|
|
12387
12457
|
layerSuffix: this.layerSuffix,
|
|
12458
|
+
lineWidthStops: this.lineWidthStops,
|
|
12388
12459
|
widthFraction: this.widthFraction,
|
|
12389
12460
|
dashArray: this.dashArray,
|
|
12390
12461
|
alpha: this.alpha,
|
|
@@ -12401,7 +12472,7 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
12401
12472
|
* @returns {LineStyle}
|
|
12402
12473
|
*/
|
|
12403
12474
|
static fromJSON(obj, index) {
|
|
12404
|
-
_LineStyle.validateJSON(obj, index);
|
|
12475
|
+
_LineStyle.validateJSON(obj, index, true);
|
|
12405
12476
|
return new _LineStyle(obj);
|
|
12406
12477
|
}
|
|
12407
12478
|
};
|
|
@@ -12467,9 +12538,13 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
12467
12538
|
this._compiledPatterns = templates.map((t) => templateToRegex(t));
|
|
12468
12539
|
this._templatePatterns = templates.map((t) => templateToTemplateRegex(t));
|
|
12469
12540
|
this.lineWidthStops = lineWidthStops;
|
|
12470
|
-
this.lineStyles = lineStyles.map(
|
|
12471
|
-
(style
|
|
12472
|
-
|
|
12541
|
+
this.lineStyles = lineStyles.map((style) => {
|
|
12542
|
+
if (style instanceof LineStyle) {
|
|
12543
|
+
return style;
|
|
12544
|
+
}
|
|
12545
|
+
const styleWithStops = style.lineWidthStops ? style : { ...style, lineWidthStops };
|
|
12546
|
+
return new LineStyle(styleWithStops);
|
|
12547
|
+
});
|
|
12473
12548
|
}
|
|
12474
12549
|
/**
|
|
12475
12550
|
* Get line styles active at a given zoom level
|
|
@@ -12488,45 +12563,6 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
12488
12563
|
const activeStyles = this.getLineStylesForZoom(z2);
|
|
12489
12564
|
return [...new Set(activeStyles.map((s) => s.layerSuffix))];
|
|
12490
12565
|
}
|
|
12491
|
-
/**
|
|
12492
|
-
* Interpolate or extrapolate line width for a given zoom level.
|
|
12493
|
-
* Uses the lineWidthStops map to calculate the appropriate width.
|
|
12494
|
-
* @param {number} zoom - Zoom level
|
|
12495
|
-
* @returns {number}
|
|
12496
|
-
*/
|
|
12497
|
-
getLineWidth(zoom) {
|
|
12498
|
-
const zooms = Object.keys(this.lineWidthStops).map(Number).sort((a, b2) => a - b2);
|
|
12499
|
-
if (this.lineWidthStops[zoom] !== void 0) {
|
|
12500
|
-
return this.lineWidthStops[zoom];
|
|
12501
|
-
}
|
|
12502
|
-
if (zoom < zooms[0]) {
|
|
12503
|
-
const z1 = zooms[0];
|
|
12504
|
-
const z2 = zooms[1];
|
|
12505
|
-
const w1 = this.lineWidthStops[z1];
|
|
12506
|
-
const w2 = this.lineWidthStops[z2];
|
|
12507
|
-
const slope = (w2 - w1) / (z2 - z1);
|
|
12508
|
-
return Math.max(MIN_LINE_WIDTH, w1 + slope * (zoom - z1));
|
|
12509
|
-
}
|
|
12510
|
-
if (zoom > zooms[zooms.length - 1]) {
|
|
12511
|
-
const z1 = zooms[zooms.length - 2];
|
|
12512
|
-
const z2 = zooms[zooms.length - 1];
|
|
12513
|
-
const w1 = this.lineWidthStops[z1];
|
|
12514
|
-
const w2 = this.lineWidthStops[z2];
|
|
12515
|
-
const slope = (w2 - w1) / (z2 - z1);
|
|
12516
|
-
return Math.max(MIN_LINE_WIDTH, w2 + slope * (zoom - z2));
|
|
12517
|
-
}
|
|
12518
|
-
for (let i2 = 0; i2 < zooms.length - 1; i2++) {
|
|
12519
|
-
if (zoom > zooms[i2] && zoom < zooms[i2 + 1]) {
|
|
12520
|
-
const z1 = zooms[i2];
|
|
12521
|
-
const z2 = zooms[i2 + 1];
|
|
12522
|
-
const w1 = this.lineWidthStops[z1];
|
|
12523
|
-
const w2 = this.lineWidthStops[z2];
|
|
12524
|
-
const t = (zoom - z1) / (z2 - z1);
|
|
12525
|
-
return w1 + t * (w2 - w1);
|
|
12526
|
-
}
|
|
12527
|
-
}
|
|
12528
|
-
return DEFAULT_LINE_WIDTH;
|
|
12529
|
-
}
|
|
12530
12566
|
/**
|
|
12531
12567
|
* Check if this config matches the given template URLs (with {z}/{x}/{y} placeholders)
|
|
12532
12568
|
* @param {string | string[]} templates - Single template URL or array of template URLs
|
|
@@ -14980,12 +15016,11 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
14980
15016
|
"https://{s}.basemaps.cartocdn.com/rastertiles/voyager_labels_under/{z}/{x}/{y}.png",
|
|
14981
15017
|
"https://basemaps.cartocdn.com/rastertiles/voyager_labels_under/{z}/{x}/{y}.png"
|
|
14982
15018
|
],
|
|
14983
|
-
lineWidthStops: { "1": 0.5, "2": 0.75, "3": 0.75, "4": 1, "5": 1, "7": 1.
|
|
15019
|
+
lineWidthStops: { "1": 0.5, "2": 0.75, "3": 0.75, "4": 1, "5": 1, "7": 1.75, "16": 2.5 },
|
|
14984
15020
|
lineStyles: [
|
|
14985
15021
|
{ color: "rgb(235, 214, 214)", layerSuffix: "ne", endZoom: 4, lineExtensionFactor: 0.1, delWidthFactor: 2.5 },
|
|
14986
15022
|
{ color: "rgb(235, 214, 214)", layerSuffix: "ne-disp", endZoom: 4, delWidthFactor: 0 },
|
|
14987
|
-
{ color: "rgb(235, 214, 214)", layerSuffix: "osm", alpha: 0.
|
|
14988
|
-
{ color: "rgb(235, 214, 214)", layerSuffix: "osm", alpha: 0.2, startZoom: 12, widthFraction: 4, lineExtensionFactor: 0.1 },
|
|
15023
|
+
{ color: "rgb(235, 214, 214)", layerSuffix: "osm", alpha: 0.1, startZoom: 6, lineWidthStops: { "6": 9, "10": 8, "14": 8 }, lineExtensionFactor: 0.1 },
|
|
14989
15024
|
{ color: "rgb(235, 214, 214)", layerSuffix: "osm", startZoom: 5, lineExtensionFactor: 0.1 },
|
|
14990
15025
|
{ color: "rgb(235, 214, 214)", layerSuffix: "osm-disp", startZoom: 5, delWidthFactor: 0 },
|
|
14991
15026
|
{ color: "rgb(235, 214, 214)", layerSuffix: "osm-internal", startZoom: 5, widthFraction: 0.5, dashArray: [2, 2], delWidthFactor: 2 },
|
|
@@ -15008,12 +15043,11 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
15008
15043
|
"https://{s}.basemaps.cartocdn.com/rastertiles/voyager_labels_under/{z}/{x}/{y}{r}.png",
|
|
15009
15044
|
"https://basemaps.cartocdn.com/rastertiles/voyager_labels_under/{z}/{x}/{y}{r}.png"
|
|
15010
15045
|
],
|
|
15011
|
-
lineWidthStops: { "1":
|
|
15046
|
+
lineWidthStops: { "1": 1, "3": 1, "4": 2, "5": 2, "6": 2.5, "7": 3, "8": 3, "10": 4, "11": 4, "12": 4 },
|
|
15012
15047
|
lineStyles: [
|
|
15013
15048
|
{ color: "rgb(235, 214, 214)", layerSuffix: "ne", endZoom: 4, lineExtensionFactor: 0.1, delWidthFactor: 2.5 },
|
|
15014
15049
|
{ color: "rgb(235, 214, 214)", layerSuffix: "ne-disp", endZoom: 4, delWidthFactor: 0 },
|
|
15015
|
-
{ color: "rgb(235, 214, 214)", layerSuffix: "osm", alpha: 0.1, startZoom: 6,
|
|
15016
|
-
{ color: "rgb(235, 214, 214)", layerSuffix: "osm", alpha: 0.1, startZoom: 12, widthFraction: 4, lineExtensionFactor: 0.1 },
|
|
15050
|
+
{ color: "rgb(235, 214, 214)", layerSuffix: "osm", alpha: 0.1, startZoom: 6, lineWidthStops: { "6": 20, "8": 19, "10": 18, "12": 17 }, lineExtensionFactor: 0.1 },
|
|
15017
15051
|
{ color: "rgb(235, 214, 214)", layerSuffix: "osm", startZoom: 5, lineExtensionFactor: 0.1 },
|
|
15018
15052
|
{ color: "rgb(235, 214, 214)", layerSuffix: "osm-disp", startZoom: 5, delWidthFactor: 0 },
|
|
15019
15053
|
{ color: "rgb(235, 214, 214)", layerSuffix: "osm-internal", startZoom: 5, widthFraction: 0.5, dashArray: [4, 4], delWidthFactor: 2 },
|
|
@@ -15024,15 +15058,20 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
15024
15058
|
id: "open-topo",
|
|
15025
15059
|
tileUrlTemplates: [
|
|
15026
15060
|
"https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png",
|
|
15027
|
-
"https://tile.opentopomap.org/{z}/{x}/{y}.png"
|
|
15061
|
+
"https://tile.opentopomap.org/{z}/{x}/{y}.png",
|
|
15062
|
+
"https://{s}.tile.top-o-map.de/{z}/{x}/{y}.png",
|
|
15063
|
+
"https://tile.top-o-map.de/{z}/{x}/{y}.png"
|
|
15028
15064
|
],
|
|
15029
15065
|
lineWidthStops: { "4": 0.75, "5": 1, "6": 1.25, "7": 1.5, "8": 1.75, "9": 1.25, "10": 1.25, "13": 1.5 },
|
|
15030
15066
|
lineStyles: [
|
|
15031
15067
|
{ color: "rgb(83, 83, 83)", layerSuffix: "ne", startZoom: 4, endZoom: 6 },
|
|
15032
15068
|
{ color: "rgb(173, 173, 173)", layerSuffix: "osm", startZoom: 7, endZoom: 8, alpha: 0.5, widthFraction: 4 },
|
|
15033
15069
|
{ color: "rgb(83, 83, 83)", layerSuffix: "osm", startZoom: 7, endZoom: 8 },
|
|
15070
|
+
{ color: "rgb(83, 83, 83)", layerSuffix: "osm-internal", widthFraction: 0.75, startZoom: 7, endZoom: 8 },
|
|
15034
15071
|
{ color: "rgb(199, 158, 204)", layerSuffix: "osm", startZoom: 9, widthFraction: 7, alpha: 0.6, lineExtensionFactor: 0.2 },
|
|
15035
|
-
{ color: "rgb(175, 41, 203)", layerSuffix: "osm", startZoom: 9, lineExtensionFactor: 0.2 }
|
|
15072
|
+
{ color: "rgb(175, 41, 203)", layerSuffix: "osm", startZoom: 9, lineExtensionFactor: 0.2 },
|
|
15073
|
+
{ color: "rgb(199, 158, 204)", layerSuffix: "osm-internal", startZoom: 9, widthFraction: 2.25, alpha: 0.6, lineExtensionFactor: 0.2 },
|
|
15074
|
+
{ color: "rgb(175, 41, 203)", layerSuffix: "osm-internal", startZoom: 9, widthFactor: 0.75, lineExtensionFactor: 0.2 }
|
|
15036
15075
|
]
|
|
15037
15076
|
},
|
|
15038
15077
|
{
|
|
@@ -15041,9 +15080,8 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
15041
15080
|
"https://tile.openstreetmap.org/{z}/{x}/{y}.png",
|
|
15042
15081
|
"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
|
15043
15082
|
],
|
|
15044
|
-
lineWidthStops: { "
|
|
15083
|
+
lineWidthStops: { "3": 0.7, "4": 1, "10": 3.75 },
|
|
15045
15084
|
lineStyles: [
|
|
15046
|
-
{ color: "rgb(200, 180, 200)", layerSuffix: "osm", startZoom: 1, endZoom: 3, delWidthFactor: 2.5, widthFraction: 1.5 },
|
|
15047
15085
|
{ color: "rgb(200, 180, 200)", layerSuffix: "osm", startZoom: 4, delWidthFactor: 1.5 },
|
|
15048
15086
|
{ color: "rgb(160, 120, 160)", layerSuffix: "osm", startZoom: 4, widthFraction: 0.333, dashArray: [30, 2, 8, 2], delWidthFactor: 0 },
|
|
15049
15087
|
{ color: "rgb(200, 180, 200)", layerSuffix: "osm-internal", startZoom: 4, widthFraction: 0.45 },
|
|
@@ -15067,6 +15105,39 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
15067
15105
|
var INFINITY2 = -1;
|
|
15068
15106
|
var MIN_LINE_WIDTH2 = 0.1;
|
|
15069
15107
|
var DEFAULT_LINE_WIDTH2 = 1;
|
|
15108
|
+
function interpolateLineWidth2(zoom, lineWidthStops) {
|
|
15109
|
+
const zooms = Object.keys(lineWidthStops).map(Number).sort((a, b2) => a - b2);
|
|
15110
|
+
if (lineWidthStops[zoom] !== void 0) {
|
|
15111
|
+
return lineWidthStops[zoom];
|
|
15112
|
+
}
|
|
15113
|
+
if (zoom < zooms[0]) {
|
|
15114
|
+
const z1 = zooms[0];
|
|
15115
|
+
const z2 = zooms[1];
|
|
15116
|
+
const w1 = lineWidthStops[z1];
|
|
15117
|
+
const w2 = lineWidthStops[z2];
|
|
15118
|
+
const slope = (w2 - w1) / (z2 - z1);
|
|
15119
|
+
return Math.max(MIN_LINE_WIDTH2, w1 + slope * (zoom - z1));
|
|
15120
|
+
}
|
|
15121
|
+
if (zoom > zooms[zooms.length - 1]) {
|
|
15122
|
+
const z1 = zooms[zooms.length - 2];
|
|
15123
|
+
const z2 = zooms[zooms.length - 1];
|
|
15124
|
+
const w1 = lineWidthStops[z1];
|
|
15125
|
+
const w2 = lineWidthStops[z2];
|
|
15126
|
+
const slope = (w2 - w1) / (z2 - z1);
|
|
15127
|
+
return Math.max(MIN_LINE_WIDTH2, w2 + slope * (zoom - z2));
|
|
15128
|
+
}
|
|
15129
|
+
for (let i2 = 0; i2 < zooms.length - 1; i2++) {
|
|
15130
|
+
if (zoom > zooms[i2] && zoom < zooms[i2 + 1]) {
|
|
15131
|
+
const z1 = zooms[i2];
|
|
15132
|
+
const z2 = zooms[i2 + 1];
|
|
15133
|
+
const w1 = lineWidthStops[z1];
|
|
15134
|
+
const w2 = lineWidthStops[z2];
|
|
15135
|
+
const t = (zoom - z1) / (z2 - z1);
|
|
15136
|
+
return w1 + t * (w2 - w1);
|
|
15137
|
+
}
|
|
15138
|
+
}
|
|
15139
|
+
return DEFAULT_LINE_WIDTH2;
|
|
15140
|
+
}
|
|
15070
15141
|
function templateToRegex2(template) {
|
|
15071
15142
|
const groups = [];
|
|
15072
15143
|
const hasRetina = template.includes("{r}");
|
|
@@ -15133,14 +15204,33 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
15133
15204
|
if (/^[a-z]+$/.test(trimmed)) return true;
|
|
15134
15205
|
return false;
|
|
15135
15206
|
}
|
|
15207
|
+
function validateLineWidthStops2(lineWidthStops, prefix) {
|
|
15208
|
+
if (!lineWidthStops || typeof lineWidthStops !== "object" || Array.isArray(lineWidthStops)) {
|
|
15209
|
+
throw new Error(`${prefix}: lineWidthStops must be an object`);
|
|
15210
|
+
}
|
|
15211
|
+
const stopKeys = Object.keys(lineWidthStops);
|
|
15212
|
+
if (stopKeys.length < 2) {
|
|
15213
|
+
throw new Error(`${prefix}: lineWidthStops must have at least 2 entries`);
|
|
15214
|
+
}
|
|
15215
|
+
for (const key of stopKeys) {
|
|
15216
|
+
const zoom = Number(key);
|
|
15217
|
+
if (!Number.isInteger(zoom) || zoom < 0) {
|
|
15218
|
+
throw new Error(`${prefix}: lineWidthStops keys must be non-negative integers, got "${key}"`);
|
|
15219
|
+
}
|
|
15220
|
+
if (typeof lineWidthStops[key] !== "number" || lineWidthStops[key] <= 0) {
|
|
15221
|
+
throw new Error(`${prefix}: lineWidthStops values must be positive numbers`);
|
|
15222
|
+
}
|
|
15223
|
+
}
|
|
15224
|
+
}
|
|
15136
15225
|
var LineStyle2 = class _LineStyle2 {
|
|
15137
15226
|
/**
|
|
15138
15227
|
* Validate a LineStyle configuration object.
|
|
15139
15228
|
* @param {Object} obj - The object to validate
|
|
15140
15229
|
* @param {number} [index] - Optional index for error messages (when validating in an array)
|
|
15230
|
+
* @param {boolean} [requireLineWidthStops=false] - Whether lineWidthStops is required
|
|
15141
15231
|
* @throws {Error} If validation fails
|
|
15142
15232
|
*/
|
|
15143
|
-
static validateJSON(obj, index) {
|
|
15233
|
+
static validateJSON(obj, index, requireLineWidthStops = false) {
|
|
15144
15234
|
const prefix = index !== void 0 ? `lineStyles[${index}]` : "LineStyle";
|
|
15145
15235
|
if (!obj || typeof obj !== "object") {
|
|
15146
15236
|
throw new Error(`${prefix}: must be an object`);
|
|
@@ -15175,22 +15265,30 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
15175
15265
|
if (obj.delWidthFactor !== void 0 && (typeof obj.delWidthFactor !== "number" || obj.delWidthFactor < 0)) {
|
|
15176
15266
|
throw new Error(`${prefix}: delWidthFactor must be a non-negative number`);
|
|
15177
15267
|
}
|
|
15268
|
+
if (requireLineWidthStops && obj.lineWidthStops === void 0) {
|
|
15269
|
+
throw new Error(`${prefix}: lineWidthStops is required`);
|
|
15270
|
+
}
|
|
15271
|
+
if (obj.lineWidthStops !== void 0) {
|
|
15272
|
+
validateLineWidthStops2(obj.lineWidthStops, prefix);
|
|
15273
|
+
}
|
|
15178
15274
|
}
|
|
15179
15275
|
/**
|
|
15180
15276
|
* @param {Object} options
|
|
15181
15277
|
* @param {string} options.color - CSS color string
|
|
15182
15278
|
* @param {string} options.layerSuffix - Layer suffix (e.g., 'osm', 'ne', 'osm-disp')
|
|
15279
|
+
* @param {Object<number, number>} options.lineWidthStops - Line width stops for this style
|
|
15183
15280
|
* @param {number} [options.widthFraction=1.0] - Multiplier for base line width
|
|
15184
15281
|
* @param {number[]} [options.dashArray] - Dash pattern for dashed lines
|
|
15185
15282
|
* @param {number} [options.alpha=1.0] - Opacity (0-1)
|
|
15186
15283
|
* @param {number} [options.startZoom=0] - Minimum zoom level for this style
|
|
15187
15284
|
* @param {number} [options.endZoom=INFINITY] - Maximum zoom level for this style (INFINITY means no limit)
|
|
15188
|
-
* @param {number} [options.lineExtensionFactor=0.
|
|
15285
|
+
* @param {number} [options.lineExtensionFactor=0.0] - Factor to extend lines by (multiplied by deletion line width)
|
|
15189
15286
|
* @param {number} [options.delWidthFactor=1.5] - Factor to multiply line width for deletion blur
|
|
15190
15287
|
*/
|
|
15191
|
-
constructor({ color, layerSuffix, widthFraction = 1, dashArray, alpha = 1, startZoom = 0, endZoom = INFINITY2, lineExtensionFactor = 0, delWidthFactor = 1.5 }) {
|
|
15288
|
+
constructor({ color, layerSuffix, lineWidthStops, widthFraction = 1, dashArray, alpha = 1, startZoom = 0, endZoom = INFINITY2, lineExtensionFactor = 0, delWidthFactor = 1.5 }) {
|
|
15192
15289
|
this.color = color;
|
|
15193
15290
|
this.layerSuffix = layerSuffix;
|
|
15291
|
+
this.lineWidthStops = lineWidthStops;
|
|
15194
15292
|
this.widthFraction = widthFraction;
|
|
15195
15293
|
this.dashArray = dashArray;
|
|
15196
15294
|
this.alpha = alpha;
|
|
@@ -15199,6 +15297,14 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
15199
15297
|
this.lineExtensionFactor = lineExtensionFactor;
|
|
15200
15298
|
this.delWidthFactor = delWidthFactor;
|
|
15201
15299
|
}
|
|
15300
|
+
/**
|
|
15301
|
+
* Get base line width for this style at a given zoom level.
|
|
15302
|
+
* @param {number} zoom - Zoom level
|
|
15303
|
+
* @returns {number}
|
|
15304
|
+
*/
|
|
15305
|
+
getLineWidth(zoom) {
|
|
15306
|
+
return interpolateLineWidth2(zoom, this.lineWidthStops);
|
|
15307
|
+
}
|
|
15202
15308
|
/**
|
|
15203
15309
|
* Check if this style is active at the given zoom level.
|
|
15204
15310
|
* @param {number} z - Zoom level
|
|
@@ -15215,6 +15321,7 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
15215
15321
|
return {
|
|
15216
15322
|
color: this.color,
|
|
15217
15323
|
layerSuffix: this.layerSuffix,
|
|
15324
|
+
lineWidthStops: this.lineWidthStops,
|
|
15218
15325
|
widthFraction: this.widthFraction,
|
|
15219
15326
|
dashArray: this.dashArray,
|
|
15220
15327
|
alpha: this.alpha,
|
|
@@ -15231,7 +15338,7 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
15231
15338
|
* @returns {LineStyle}
|
|
15232
15339
|
*/
|
|
15233
15340
|
static fromJSON(obj, index) {
|
|
15234
|
-
_LineStyle2.validateJSON(obj, index);
|
|
15341
|
+
_LineStyle2.validateJSON(obj, index, true);
|
|
15235
15342
|
return new _LineStyle2(obj);
|
|
15236
15343
|
}
|
|
15237
15344
|
};
|
|
@@ -15297,9 +15404,13 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
15297
15404
|
this._compiledPatterns = templates.map((t) => templateToRegex2(t));
|
|
15298
15405
|
this._templatePatterns = templates.map((t) => templateToTemplateRegex2(t));
|
|
15299
15406
|
this.lineWidthStops = lineWidthStops;
|
|
15300
|
-
this.lineStyles = lineStyles.map(
|
|
15301
|
-
(style
|
|
15302
|
-
|
|
15407
|
+
this.lineStyles = lineStyles.map((style) => {
|
|
15408
|
+
if (style instanceof LineStyle2) {
|
|
15409
|
+
return style;
|
|
15410
|
+
}
|
|
15411
|
+
const styleWithStops = style.lineWidthStops ? style : { ...style, lineWidthStops };
|
|
15412
|
+
return new LineStyle2(styleWithStops);
|
|
15413
|
+
});
|
|
15303
15414
|
}
|
|
15304
15415
|
/**
|
|
15305
15416
|
* Get line styles active at a given zoom level
|
|
@@ -15318,45 +15429,6 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
15318
15429
|
const activeStyles = this.getLineStylesForZoom(z2);
|
|
15319
15430
|
return [...new Set(activeStyles.map((s) => s.layerSuffix))];
|
|
15320
15431
|
}
|
|
15321
|
-
/**
|
|
15322
|
-
* Interpolate or extrapolate line width for a given zoom level.
|
|
15323
|
-
* Uses the lineWidthStops map to calculate the appropriate width.
|
|
15324
|
-
* @param {number} zoom - Zoom level
|
|
15325
|
-
* @returns {number}
|
|
15326
|
-
*/
|
|
15327
|
-
getLineWidth(zoom) {
|
|
15328
|
-
const zooms = Object.keys(this.lineWidthStops).map(Number).sort((a, b2) => a - b2);
|
|
15329
|
-
if (this.lineWidthStops[zoom] !== void 0) {
|
|
15330
|
-
return this.lineWidthStops[zoom];
|
|
15331
|
-
}
|
|
15332
|
-
if (zoom < zooms[0]) {
|
|
15333
|
-
const z1 = zooms[0];
|
|
15334
|
-
const z2 = zooms[1];
|
|
15335
|
-
const w1 = this.lineWidthStops[z1];
|
|
15336
|
-
const w2 = this.lineWidthStops[z2];
|
|
15337
|
-
const slope = (w2 - w1) / (z2 - z1);
|
|
15338
|
-
return Math.max(MIN_LINE_WIDTH2, w1 + slope * (zoom - z1));
|
|
15339
|
-
}
|
|
15340
|
-
if (zoom > zooms[zooms.length - 1]) {
|
|
15341
|
-
const z1 = zooms[zooms.length - 2];
|
|
15342
|
-
const z2 = zooms[zooms.length - 1];
|
|
15343
|
-
const w1 = this.lineWidthStops[z1];
|
|
15344
|
-
const w2 = this.lineWidthStops[z2];
|
|
15345
|
-
const slope = (w2 - w1) / (z2 - z1);
|
|
15346
|
-
return Math.max(MIN_LINE_WIDTH2, w2 + slope * (zoom - z2));
|
|
15347
|
-
}
|
|
15348
|
-
for (let i2 = 0; i2 < zooms.length - 1; i2++) {
|
|
15349
|
-
if (zoom > zooms[i2] && zoom < zooms[i2 + 1]) {
|
|
15350
|
-
const z1 = zooms[i2];
|
|
15351
|
-
const z2 = zooms[i2 + 1];
|
|
15352
|
-
const w1 = this.lineWidthStops[z1];
|
|
15353
|
-
const w2 = this.lineWidthStops[z2];
|
|
15354
|
-
const t = (zoom - z1) / (z2 - z1);
|
|
15355
|
-
return w1 + t * (w2 - w1);
|
|
15356
|
-
}
|
|
15357
|
-
}
|
|
15358
|
-
return DEFAULT_LINE_WIDTH2;
|
|
15359
|
-
}
|
|
15360
15432
|
/**
|
|
15361
15433
|
* Check if this config matches the given template URLs (with {z}/{x}/{y} placeholders)
|
|
15362
15434
|
* @param {string | string[]} templates - Single template URL or array of template URLs
|
|
@@ -15849,12 +15921,13 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
15849
15921
|
const canvas = this._canvas;
|
|
15850
15922
|
const ctx = canvas.getContext("2d", { willReadFrequently: true });
|
|
15851
15923
|
ctx.drawImage(imageBitmap, 0, 0, tileSize, tileSize);
|
|
15852
|
-
const baseLineWidth = layerConfig.getLineWidth(zoom);
|
|
15853
15924
|
const delLineWidthBySuffix = {};
|
|
15854
15925
|
for (const suffix of layerSuffixes) {
|
|
15855
15926
|
const stylesForSuffix = activeLineStyles.filter((s) => s.layerSuffix === suffix);
|
|
15856
|
-
const
|
|
15857
|
-
|
|
15927
|
+
const maxDelWidth = Math.max(...stylesForSuffix.map(
|
|
15928
|
+
(s) => s.getLineWidth(zoom) * s.widthFraction * s.delWidthFactor
|
|
15929
|
+
));
|
|
15930
|
+
delLineWidthBySuffix[suffix] = maxDelWidth;
|
|
15858
15931
|
}
|
|
15859
15932
|
for (const suffix of layerSuffixes) {
|
|
15860
15933
|
const delLineWidth = delLineWidthBySuffix[suffix];
|
|
@@ -15869,7 +15942,7 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
15869
15942
|
}
|
|
15870
15943
|
}
|
|
15871
15944
|
for (const style of activeLineStyles) {
|
|
15872
|
-
const { color,
|
|
15945
|
+
const { color, widthFraction, dashArray, alpha, lineExtensionFactor, layerSuffix } = style;
|
|
15873
15946
|
const addLayerName = `to-add-${layerSuffix}`;
|
|
15874
15947
|
let addFeatures = corrections[addLayerName] || [];
|
|
15875
15948
|
if (addFeatures.length > 0) {
|
|
@@ -15877,7 +15950,7 @@ var IndiaBoundaryCorrector = (() => {
|
|
|
15877
15950
|
if (lineExtensionFactor > 0) {
|
|
15878
15951
|
addFeatures = extendFeaturesByFactor(addFeatures, lineExtensionFactor, delLineWidth, tileSize);
|
|
15879
15952
|
}
|
|
15880
|
-
const lineWidth =
|
|
15953
|
+
const lineWidth = style.getLineWidth(zoom) * widthFraction;
|
|
15881
15954
|
drawFeatures(ctx, addFeatures, color, lineWidth, tileSize, dashArray, alpha);
|
|
15882
15955
|
}
|
|
15883
15956
|
}
|