Image LOCATE=googleearth

Since i use many programs in a portable way (not being installed but present on disk and executable) I wonder how dopus is starting google earth (Image LOCATE=googleearth) and passing the command containing the latitude/longitude information over to the program. I tried to capture a google earth installation with the changes made to the registry but couldnt find the "magic key :key:" that tells the os/dopus that/where GE is installed at. Maybe a dev could help me with this.
Thanks in advance

Opus generates a .kml file in the temp folder and opens it. You would need the file association set up in the registry for this to work.

Thanks, easy as this. Didnt think about that solution :sweat_smile:

Having done the kml association im now stuck with showing multiple locations in google earth. Dopus is enumerating the files but for each it says "another program is accessing this file" (%Temp%\dop****.kml) and im hardly struggeling aborting the enumeration, dopus creates a new kml per image. So for me it seems that this command is only usable for a single file and i cant understand it, at least for ge it should be possible to pass multiple locations to (i see that there might be a problem for bing/google maps since im not sure if their urls allow those parameters) but for ge the enumeration has to create just one kml with all those coordinates and then passing this file over to ge. Should i seperatly file a new bug report or feature request or am missing something?
Felix

Sending more than one image to Google Earth seems to be a bit more complicated (on GE's side) - so I wouldn't file a bug report.

Should be doable with script. And aren't you an expert on that matter?

Since kml is just it shouldnt be that hard to add extra nodes in one kml-file while enumerating files.

Haha thanks :sweat_smile: my question was indirectly if there is a chance for an update of the IMAGE LOCATE functionality since its already there and would just need a little improvement or if i would have to write a script to extend this existing feature.

Have you checked to see if a single .kml file will actually work with Google Earth if you add multiple Placemark nodes? We could probably extend the command to allow for this but there's not much point if GE doesn't support it.

No, it is pretty picky:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.0">
	<Placemark>
		<name>2021-03-02 19.40.13.360</name>
		<description>2021-03-02 20:40:13</description>
		<LookAt>
			<longitude>7.807200000</longitude>
			<latitude>46.934727777</latitude>
			<range>1000</range>
			<tilt>0</tilt>
			<heading>0</heading>
		</LookAt>
		<Point>
			<coordinates>7.807200000,46.934727777,0</coordinates>
		</Point>
	</Placemark>
    
    <Placemark>
		<name>name</name>
		<description>description</description>
		<LookAt>
			<longitude>7.807200000</longitude>
			<latitude>46.934727777</latitude>
			<range>1000</range>
			<tilt>0</tilt>
			<heading>0</heading>
		</LookAt>
		<Point>
			<coordinates>7.9,47.0,0</coordinates>
		</Point>
	</Placemark>
   
    
</kml>

image

Other programs will open the .kml and display the two places.

That doesn't mean it won't work at all with GE - it is just a bit more glue needed than simply adding more nodes.

1 Like

After getting hooked i came up with a first draft

function OnClick(clickData)
{
	DOpus.ClearOutput();
	if (clickData.func.sourcetab.selected.count == 0)
	{
		DOpus.Output("  (none)");
	}
	else
	{
		var selectedFiles = clickData.func.sourcetab.selected;
		var progress = clickData.Func.Command.Progress;
		progress.abort = true; // Allow abort button.
		progress.Init(clickData.func.sourcetab, "GPS Tags in " + clickData.func.sourcetab.path);
		progress.SetStatus("0/" + selectedFiles.count + " files");
		progress.SetFiles(selectedFiles);
		DOpus.Delay(200);
		progress.Show();

		//https://developers.google.com/kml/documentation/kml_tut#basic_kml
		var fso = new ActiveXObject("Scripting.FileSystemObject");
		var textFile = fso.CreateTextFile("T:\\test.kml", true);
		textFile.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
		textFile.WriteLine("<kml xmlns=\"http://earth.google.com/kml/2.0\">");
		textFile.WriteLine( "\t<Document>");

		var gpsCount = 0;
		var fsItems = new Enumerator(selectedFiles);
		var counter = 0;
		while (!fsItems.atEnd())
		{
			var abortState = progress.GetAbortState();
			if (abortState == "a")
			{
				return;
			}
			else if (abortState == "p")
			{
				DOpus.Delay(500);
				continue;
			}
	
			var currentItem = fsItems.item();
			if (!currentItem.is_dir)
			{	
				progress.SetName(currentItem.name);
				
				var fileMeta = currentItem.metadata;
				if (fileMeta == "image")
				{
					var imageMeta = fileMeta.image;
					var lat = imageMeta["latitude"];
					var lng = imageMeta["longitude"];
					if(lat == "" || typeof(lat) === 'undefined' || lng == "" || typeof(lng) === 'undefined')
					{
					}
					else
					{
						textFile.WriteLine("\t\t<Placemark>");
						textFile.WriteLine("\t\t\t<name>" + currentItem.name + "</name>");
						textFile.WriteLine("\t\t\t<description>" + currentItem.name + "</description>");
						textFile.WriteLine("\t\t\t<Point>");
						textFile.WriteLine("\t\t\t\t<coordinates>" + lng + "," + lat + "</coordinates>");
						textFile.WriteLine("\t\t\t</Point>");
					
						textFile.WriteLine("\t\t</Placemark>");
					}
					gpsCount++;
				}
			}
			fsItems.moveNext();
			progress.SetPercentProgress((counter++ * 100) / selectedFiles.count);
			progress.SetStatus(counter + "/" + selectedFiles.count + " files, GPS tags: " + gpsCount);
		}

		textFile.WriteLine("\t</Document>");
		textFile.WriteLine("</kml>");
		textFile.Close();
	}
}
/*	textFile.WriteLine("\t\t\t<LookAt>");
						textFile.WriteLine("\t\t\t\t<longitude>" + currentItem.name + "</longitude>");
						textFile.WriteLine("\t\t\t\t<range>1000</range>");
						textFile.WriteLine("\t\t\t</LookAt>");
						*/

This is because root level is inside <kml></kml> and there are several nodes on the same level which seems not to be allowed (not sure if this is kml specific or xml standard, but however) the solution is to put the nodes inside a <Document> node, thats it. So still very easy possible (still having the opinion that if this functionality is already implemented the changes are quite few to make it work with several files, but maybe not many people want/need this feature :sweat_smile:).

In the next update we'll make Image LOCATE handle multiple images (by putting them inside a Documentnode in the generated KML file). Thanks for your help working that out!

1 Like

Nice, cool to see how activley DOpus is developed :slight_smile:
I have created an advanced version of my demo script from this thread for handling multiple images in google earth and windows 10 maps at https://resource.dopus.com/t/command-imagelocateadvanced/38030d

2 Likes