forked from MapComplete/MapComplete
		
	Fix mapillary image detection
This commit is contained in:
		
							parent
							
								
									46e3fa84de
								
							
						
					
					
						commit
						83f79d95b9
					
				
					 3 changed files with 7 additions and 9 deletions
				
			
		|  | @ -44,7 +44,7 @@ export default class AllImageProviders { | ||||||
|              |              | ||||||
|             let prefixes = imageProvider.defaultKeyPrefixes |             let prefixes = imageProvider.defaultKeyPrefixes | ||||||
|             if(tagKey !== undefined){ |             if(tagKey !== undefined){ | ||||||
|                 prefixes = [tagKey] |                 prefixes = [...prefixes, tagKey] | ||||||
|             } |             } | ||||||
|              |              | ||||||
|             const singleSource = imageProvider.GetRelevantUrls(tags, { |             const singleSource = imageProvider.GetRelevantUrls(tags, { | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ export interface ProvidedImage { | ||||||
| 
 | 
 | ||||||
| export default abstract class ImageProvider { | export default abstract class ImageProvider { | ||||||
| 
 | 
 | ||||||
|     public abstract readonly defaultKeyPrefixes: string[] = ["mapillary", "image"] |     public abstract readonly defaultKeyPrefixes: string[] | ||||||
| 
 | 
 | ||||||
|     private _cache = new Map<string, UIEventSource<LicenseInfo>>() |     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 relevantUrls = new UIEventSource<{ url: string; key: string; provider: ImageProvider }[]>([]) | ||||||
|         const seenValues = new Set<string>() |         const seenValues = new Set<string>() | ||||||
|         const self =this |  | ||||||
|         allTags.addCallbackAndRunD(tags => { |         allTags.addCallbackAndRunD(tags => { | ||||||
|             for (const key in tags) { |             for (const key in tags) { | ||||||
|  |                 console.log("Does ", key,"have images?") | ||||||
|                 if (!prefixes.some(prefix => key.startsWith(prefix))) { |                 if (!prefixes.some(prefix => key.startsWith(prefix))) { | ||||||
|  |                     console.log(key,": NO", this.constructor.name, "prefixes are", prefixes) | ||||||
|                     continue |                     continue | ||||||
|                 } |                 } | ||||||
|                 const values = Utils.NoEmpty(tags[key]?.split(";")?.map(v => v.trim()) ?? []) |                 const values = Utils.NoEmpty(tags[key]?.split(";")?.map(v => v.trim()) ?? []) | ||||||
|  |  | ||||||
|  | @ -15,14 +15,11 @@ export class Mapillary extends ImageProvider { | ||||||
|     private static readonly valuePrefix = "https://a.mapillary.com" |     private static readonly valuePrefix = "https://a.mapillary.com" | ||||||
|     public static readonly valuePrefixes = [Mapillary.valuePrefix, "http://mapillary.com","https://mapillary.com"] |     public static readonly valuePrefixes = [Mapillary.valuePrefix, "http://mapillary.com","https://mapillary.com"] | ||||||
| 
 | 
 | ||||||
|     private constructor() { |  | ||||||
|         super(); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     private static ExtractKeyFromURL(value: string, failIfNoMath = false): { |     private static ExtractKeyFromURL(value: string, failIfNoMath = false): { | ||||||
|         key: string, |         key: string, | ||||||
|         isApiv4?: boolean |         isApiv4?: boolean | ||||||
|     } { |     } { | ||||||
|  |          | ||||||
|         if (value.startsWith(Mapillary.valuePrefix)) { |         if (value.startsWith(Mapillary.valuePrefix)) { | ||||||
|             const key = value.substring(0, value.lastIndexOf("?")).substring(value.lastIndexOf("/") + 1) |             const key = value.substring(0, value.lastIndexOf("?")).substring(value.lastIndexOf("/") + 1) | ||||||
|             return {key: key, isApiv4: !isNaN(Number(key))}; |             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>[]> { |     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> { |     private async PrepareUrlAsync(key: string, value: string): Promise<ProvidedImage> { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue