Fix mapillary image detection

This commit is contained in:
pietervdvn 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,10 +11,10 @@ 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>>()
GetAttributionFor(url: string): UIEventSource<LicenseInfo> {
const cached = this._cache.get(url);
if (cached !== undefined) {
@ -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))};
@ -61,7 +58,7 @@ export class Mapillary extends ImageProvider {
}
async ExtractUrls(key: string, value: string): Promise<Promise<ProvidedImage>[]> {
return [this.PrepareUrlAsync(key, value)]
return [this.PrepareUrlAsync(key, value)]
}
private async PrepareUrlAsync(key: string, value: string): Promise<ProvidedImage> {