2022-11-02 14:44:06 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								import  {  Store ,  UIEventSource  }  from  "../../Logic/UIEventSource" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								import  {  ProvidedImage  }  from  "../../Logic/ImageProviders/ImageProvider" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								import  Wikidata  from  "../../Logic/Web/Wikidata" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								import  ChangeTagAction  from  "../../Logic/Osm/Actions/ChangeTagAction" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								import  {  And  }  from  "../../Logic/Tags/And" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								import  {  Tag  }  from  "../../Logic/Tags/Tag" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								import  AllImageProviders  from  "../../Logic/ImageProviders/AllImageProviders" 
							 
						 
					
						
							
								
									
										
										
										
											2023-06-14 20:39:36 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								import  {  SpecialVisualization ,  SpecialVisualizationState  }  from  "../SpecialVisualization" 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 01:47:32 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								import  SvelteUIElement  from  "../Base/SvelteUIElement" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								import  PlantNet  from  "../PlantNet/PlantNet.svelte" 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-27 22:21:35 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								import  {  default  as  PlantNetCode  }  from  "../../Logic/Web/PlantNet" 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-17 14:25:30 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-10-28 04:33:05 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								export  class  PlantNetDetectionViz  implements  SpecialVisualization  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    funcName  =  "plantnet_detection" 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-27 22:21:35 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    needsUrls  =  [ PlantNetCode . baseUrl ] 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 20:37:04 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    group  =  "data_import" 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-28 04:33:05 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-02 14:44:06 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    docs  = 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        "Sends the images linked to the current object to plantnet.org and asks it what plant species is shown on it. The user can then select the correct species; the corresponding wikidata-identifier will then be added to the object (together with `source:species:wikidata=plantnet.org AI`). " 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-28 04:33:05 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    args  =  [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            name :  "image_key" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            defaultValue : AllImageProviders.defaultKeys.join ( "," ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            doc :  "The keys given to the images, e.g. if <span class='literal-code'>image</span> is given, the first picture URL will be added as <span class='literal-code'>image</span>, the second as <span class='literal-code'>image:0</span>, the third as <span class='literal-code'>image:1</span>, etc... Multiple values are allowed if ';'-separated " , 
							 
						 
					
						
							
								
									
										
										
										
											2022-11-02 14:44:06 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        } , 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-28 04:33:05 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-06-14 20:39:36 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								    public  constr ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        state : SpecialVisualizationState , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        tags : UIEventSource < Record < string ,  string > > , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        args : string [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-28 04:33:05 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        let  imagePrefixes : string [ ]  =  undefined 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        if  ( args . length  >  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            imagePrefixes  =  [ ] . concat ( . . . args . map ( ( a )  = >  a . split ( "," ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-17 14:25:30 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        const  allProvidedImages : Store < ProvidedImage [ ] >  =  AllImageProviders . loadImagesFor ( 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 01:47:32 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								            tags , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            imagePrefixes 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-28 04:33:05 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								        ) 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 01:47:32 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        const  imageUrls : Store < string [ ] >  =  allProvidedImages . map ( ( pi )  = >  pi . map ( ( pi )  = >  pi . url ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-28 04:33:05 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 01:47:32 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								        async  function  applySpecies ( selectedWikidata )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            selectedWikidata  =  Wikidata . ExtractKey ( selectedWikidata ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            const  change  =  new  ChangeTagAction ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                tags . data . id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                new  And ( [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    new  Tag ( "species:wikidata" ,  selectedWikidata ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                    new  Tag ( "source:species:wikidata" ,  "PlantNet.org AI" ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                ] ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                tags . data , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                { 
							 
						 
					
						
							
								
									
										
										
										
											2024-10-17 04:06:03 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                    theme : state.theme.id , 
							 
						 
					
						
							
								
									
										
										
										
											2023-09-20 01:47:32 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								                    changeType :  "plantnet-ai-detection" , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								            await  state . changes . applyAction ( change ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								        return  new  SvelteUIElement ( PlantNet ,  {  imageUrls ,  onConfirm : applySpecies  } ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-28 04:33:05 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}