forked from MapComplete/MapComplete
Fix: tests
This commit is contained in:
parent
32993df92a
commit
392e96e4f5
1 changed files with 5 additions and 4 deletions
|
@ -72,17 +72,18 @@ export default class AllImageProviders {
|
||||||
* Does a guess on the number of images that are probably there.
|
* Does a guess on the number of images that are probably there.
|
||||||
* Will simply count all image tags
|
* Will simply count all image tags
|
||||||
*
|
*
|
||||||
* AllImageProviders.estimateNumberOfImages({image:"abc", "mapillary": "123", "panoramax:0"}) // => 3
|
* AllImageProviders.estimateNumberOfImages({image:"abc", "mapillary": "123", "panoramax:0": "xyz"}) // => 3
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static estimateNumberOfImages(tags: Record<string, string>, prefixes: string[] = undefined): number {
|
public static estimateNumberOfImages(tags: Record<string, string>, prefixes: string[] = undefined): number {
|
||||||
let count = 0
|
let count = 0
|
||||||
|
|
||||||
const allPrefixes = prefixes ?? [].concat(...AllImageProviders.ImageAttributionSource.map(s => s.defaultKeyPrefixes))
|
const allPrefixes = Utils.Dedup(prefixes ?? [].concat(...AllImageProviders.ImageAttributionSource.map(s => s.defaultKeyPrefixes)))
|
||||||
for (const k in tags) {
|
for (const prefix of allPrefixes) {
|
||||||
for (const prefix of allPrefixes) {
|
for (const k in tags) {
|
||||||
if (k === prefix || k.startsWith(prefix + ":")) {
|
if (k === prefix || k.startsWith(prefix + ":")) {
|
||||||
count++
|
count++
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue