*
(source)
| 375 | * |
| 376 | */ |
| 377 | baseLayerSource(source) { |
| 378 | if (!arguments.length) return this._baseLayer; |
| 379 | |
| 380 | // test source against OSM imagery blocklists.. |
| 381 | const osm = this.context.services.osm; |
| 382 | if (!osm) return this; |
| 383 | |
| 384 | const blocklists = osm?.imageryBlocklists ?? []; |
| 385 | const template = source.template; |
| 386 | let fail = false; |
| 387 | let tested = 0; |
| 388 | let regex; |
| 389 | |
| 390 | for (regex of blocklists) { |
| 391 | fail = regex.test(template); |
| 392 | tested++; |
| 393 | if (fail) break; |
| 394 | } |
| 395 | |
| 396 | // ensure at least one test was run. |
| 397 | if (!tested) { |
| 398 | regex = /.*\.google(apis)?\..*\/(vt|kh)[\?\/].*([xyz]=.*){3}.*/; |
| 399 | fail = regex.test(template); |
| 400 | } |
| 401 | |
| 402 | this._baseLayer = (!fail ? source : this.getSourceByID('none')); |
| 403 | |
| 404 | this._imageryChanged(); |
| 405 | this.emit('imagerychange'); |
| 406 | return this; |
| 407 | } |
| 408 | |
| 409 | |
| 410 | /** |
no test coverage detected