Hello, I am working on a column script that needs to pass the Latitude and Longitude in to an external API. The API requires I pass the values as Decimal.
I would like to know the correct method of accessing the values in the image.
looking at Keywords for Columns.
The output is whole numbers and not the same value as I would get if I put the Degrees Minutes Seconds in to an online converter. Also it does not appear to change for different gps locations.
If you use image_text instead of image, you'll get the x° y' z.zzzzz" S style values you see in the columns and metadata panel. You'd still need some math to convert that to decimal if the API you're using won't accept that format.
The 2 / 196608 values returned from the image object look wrong, and may be a bug or something going wrong when the datatype we use is passed to the scripting hosts. We need to look in to that further, but using image_text is my advice for the time being.
Thanks Leo, that worked as expected. Much appreciated.
if (!scriptColData.item.is_dir && (scriptColData.item.ext.toLowerCase() == ".jpg")) {
var meta = scriptColData.item.metadata;
if(meta == "image")
{
var latitude = ParseDMS(meta.image_text.latitude);
var longitude = ParseDMS(meta.image_text.longitude);
Logger (LOG_DEBUG, ("latitude: " + latitude));
Logger (LOG_DEBUG, ("longitude: " + longitude));
}
}
function ParseDMS(input) {
var parts = input.split(/[^\d\w]+/);
return ConvertDMSToDD(parts[0], parts[1], parts[2], parts[3]);
}
function ConvertDMSToDD(degrees, minutes, seconds, direction) {
var dd = Number(degrees) + Number(minutes)/60 + Number(seconds)/(60*60);
if (direction == "S" || direction == "W") {
dd = dd * -1;
} // Don't do anything for N or E
return dd;
}
I used this in this custom columns script What3Words