Fix mapillary image detection

This commit is contained in:
Pieter Vander Vennet 2021-10-18 22:17:41 +02:00
parent 46e3fa84de
commit 83f79d95b9
3 changed files with 7 additions and 9 deletions

View file

@ -44,7 +44,7 @@ export default class AllImageProviders {
let prefixes = imageProvider.defaultKeyPrefixes
if(tagKey !== undefined){
prefixes = [tagKey]
prefixes = [...prefixes, tagKey]
}
const singleSource = imageProvider.GetRelevantUrls(tags, {

View file

@ -11,7 +11,7 @@ export interface ProvidedImage {
export default abstract class ImageProvider {
public abstract readonly defaultKeyPrefixes: string[] = ["mapillary", "image"]
public abstract readonly defaultKeyPrefixes: string[]
private _cache = new Map<string, UIEventSource<LicenseInfo>>()
@ -41,10 +41,11 @@ export default abstract class ImageProvider {
}
const relevantUrls = new UIEventSource<{ url: string; key: string; provider: ImageProvider }[]>([])
const seenValues = new Set<string>()
const self =this
allTags.addCallbackAndRunD(tags => {
for (const key in tags) {
console.log("Does ", key,"have images?")
if (!prefixes.some(prefix => key.startsWith(prefix))) {
console.log(key,": NO", this.constructor.name, "prefixes are", prefixes)
continue
}
const values = Utils.NoEmpty(tags[key]?.split(";")?.map(v => v.trim()) ?? [])

View file

@ -15,14 +15,11 @@ export class Mapillary extends ImageProvider {
private static readonly valuePrefix = "https://a.mapillary.com"
public static readonly valuePrefixes = [Mapillary.valuePrefix, "http://mapillary.com","https://mapillary.com"]
private constructor() {
super();
}
private static ExtractKeyFromURL(value: string, failIfNoMath = false): {
key: string,
isApiv4?: boolean
} {
if (value.startsWith(Mapillary.valuePrefix)) {
const key = value.substring(0, value.lastIndexOf("?")).substring(value.lastIndexOf("/") + 1)
return {key: key, isApiv4: !isNaN(Number(key))};