forked from MapComplete/MapComplete
		
	Refactoring: rename method
This commit is contained in:
		
							parent
							
								
									622049f21f
								
							
						
					
					
						commit
						e69a08baa1
					
				
					 5 changed files with 8 additions and 11 deletions
				
			
		| 
						 | 
					@ -70,7 +70,7 @@ export default class AllImageProviders {
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Tries to extract all image data for this image. Cached on tags?.data?.id
 | 
					     * Tries to extract all image data for this image. Cached on tags?.data?.id
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    public static LoadImagesFor(
 | 
					    public static loadImagesFor(
 | 
				
			||||||
        tags: Store<Record<string, string>>,
 | 
					        tags: Store<Record<string, string>>,
 | 
				
			||||||
        tagKey?: string[]
 | 
					        tagKey?: string[]
 | 
				
			||||||
    ): Store<ProvidedImage[]> {
 | 
					    ): Store<ProvidedImage[]> {
 | 
				
			||||||
| 
						 | 
					@ -113,6 +113,6 @@ export default class AllImageProviders {
 | 
				
			||||||
        for (let i = 0; i < urls.length; i++) {
 | 
					        for (let i = 0; i < urls.length; i++) {
 | 
				
			||||||
            tags["image:" + i] = urls[i]
 | 
					            tags["image:" + i] = urls[i]
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return this.LoadImagesFor(new ImmutableStore(tags))
 | 
					        return this.loadImagesFor(new ImmutableStore(tags))
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -36,7 +36,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  let imagesProvider = state.nearbyImageSearcher
 | 
					  let imagesProvider = state.nearbyImageSearcher
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  let loadedImages = AllImageProviders.LoadImagesFor(tags).mapD(
 | 
					  let loadedImages = AllImageProviders.loadImagesFor(tags).mapD(
 | 
				
			||||||
    (loaded) => new Set(loaded.map((img) => img.url))
 | 
					    (loaded) => new Set(loaded.map((img) => img.url))
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
  let imageState = imagesProvider.getImagesAround(lon, lat)
 | 
					  let imageState = imagesProvider.getImagesAround(lon, lat)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,6 +9,7 @@ import { SpecialVisualization, SpecialVisualizationState } from "../SpecialVisua
 | 
				
			||||||
import SvelteUIElement from "../Base/SvelteUIElement"
 | 
					import SvelteUIElement from "../Base/SvelteUIElement"
 | 
				
			||||||
import PlantNet from "../PlantNet/PlantNet.svelte"
 | 
					import PlantNet from "../PlantNet/PlantNet.svelte"
 | 
				
			||||||
import { default as PlantNetCode } from "../../Logic/Web/PlantNet"
 | 
					import { default as PlantNetCode } from "../../Logic/Web/PlantNet"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export class PlantNetDetectionViz implements SpecialVisualization {
 | 
					export class PlantNetDetectionViz implements SpecialVisualization {
 | 
				
			||||||
    funcName = "plantnet_detection"
 | 
					    funcName = "plantnet_detection"
 | 
				
			||||||
    needsUrls = [PlantNetCode.baseUrl]
 | 
					    needsUrls = [PlantNetCode.baseUrl]
 | 
				
			||||||
| 
						 | 
					@ -33,7 +34,7 @@ export class PlantNetDetectionViz implements SpecialVisualization {
 | 
				
			||||||
            imagePrefixes = [].concat(...args.map((a) => a.split(",")))
 | 
					            imagePrefixes = [].concat(...args.map((a) => a.split(",")))
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const allProvidedImages: Store<ProvidedImage[]> = AllImageProviders.LoadImagesFor(
 | 
					        const allProvidedImages: Store<ProvidedImage[]> = AllImageProviders.loadImagesFor(
 | 
				
			||||||
            tags,
 | 
					            tags,
 | 
				
			||||||
            imagePrefixes
 | 
					            imagePrefixes
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,11 +3,7 @@ import { FixedUiElement } from "./Base/FixedUiElement"
 | 
				
			||||||
import BaseUIElement from "./BaseUIElement"
 | 
					import BaseUIElement from "./BaseUIElement"
 | 
				
			||||||
import Title from "./Base/Title"
 | 
					import Title from "./Base/Title"
 | 
				
			||||||
import { default as FeatureTitle } from "./Popup/Title.svelte"
 | 
					import { default as FeatureTitle } from "./Popup/Title.svelte"
 | 
				
			||||||
import {
 | 
					import { RenderingSpecification, SpecialVisualization, SpecialVisualizationState } from "./SpecialVisualization"
 | 
				
			||||||
    RenderingSpecification,
 | 
					 | 
				
			||||||
    SpecialVisualization,
 | 
					 | 
				
			||||||
    SpecialVisualizationState,
 | 
					 | 
				
			||||||
} from "./SpecialVisualization"
 | 
					 | 
				
			||||||
import { HistogramViz } from "./Popup/HistogramViz"
 | 
					import { HistogramViz } from "./Popup/HistogramViz"
 | 
				
			||||||
import MinimapViz from "./Popup/MinimapViz.svelte"
 | 
					import MinimapViz from "./Popup/MinimapViz.svelte"
 | 
				
			||||||
import { ShareLinkViz } from "./Popup/ShareLinkViz"
 | 
					import { ShareLinkViz } from "./Popup/ShareLinkViz"
 | 
				
			||||||
| 
						 | 
					@ -720,7 +716,7 @@ export default class SpecialVisualizations {
 | 
				
			||||||
                    if (args.length > 0) {
 | 
					                    if (args.length > 0) {
 | 
				
			||||||
                        imagePrefixes = [].concat(...args.map((a) => a.split(",")))
 | 
					                        imagePrefixes = [].concat(...args.map((a) => a.split(",")))
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    const images = AllImageProviders.LoadImagesFor(tags, imagePrefixes)
 | 
					                    const images = AllImageProviders.loadImagesFor(tags, imagePrefixes)
 | 
				
			||||||
                    return new SvelteUIElement(ImageCarousel, { state, tags, images })
 | 
					                    return new SvelteUIElement(ImageCarousel, { state, tags, images })
 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -79,7 +79,7 @@ describe("ImageProviders", () => {
 | 
				
			||||||
            if (!Array.isArray(urls)) {
 | 
					            if (!Array.isArray(urls)) {
 | 
				
			||||||
                urls = [urls]
 | 
					                urls = [urls]
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            const images = await AllImageProviders.LoadImagesFor(
 | 
					            const images = await AllImageProviders.loadImagesFor(
 | 
				
			||||||
                new ImmutableStore(tags)
 | 
					                new ImmutableStore(tags)
 | 
				
			||||||
            ).AsPromise((imgs) => imgs !== undefined && imgs.length > 0)
 | 
					            ).AsPromise((imgs) => imgs !== undefined && imgs.length > 0)
 | 
				
			||||||
            console.log("ImageProvider test", tags.id, "for", tags)
 | 
					            console.log("ImageProvider test", tags.id, "for", tags)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue