exiftool -a -api geolocation=51.479345,-0.290328,num=2
Returns a warning ("Search matched 2 cities", which should probably only be emitted when data is written to a file?) and returns two sets of data for two matching cities. The same result is emitted with XML output when using -X.
But for -JSON, only one set of data is emitted (same warning). This seems inconsistent.
I understand from the docs that when writing location data, only one city can win (city with the largest population).
But when just dumping the information to the console or a stream, maybe ExifTool could output all matches found when -JSON is used, too? It already emits an array, which makes this very easy to parse.
I believe this is cause. From the docs on the
-j (
-json) option (https://exiftool.org/exiftool_pod.html#j-JSONFILE--json)
QuoteThe -a option is implied when -json is used, but entries with identical JSON names are suppressed in the output. (-G4 may be used to ensure that all tags have unique JSON names.)
I see, thanks.
With -G4, the JSON array (!) returned has still one object, but this object now uses unique element names like
"Unknown:GeolocationCity"
"Copy1:GeolocationCity"
"Copy2:GeolocationCity"
"Copy3:GeolocationCity"
Would it somehow be possible to output one object per city object in the array?
This would avoid all the duplicate name issues and would make parsing easier.
I would suggest using -g3:
> exiftool -a -api geolocation=51.479345,-0.290328,num=2 -j -g3
[{
"SourceFile": " ",
"Main": {
"GeolocationWarning": "Search matched 2 cities",
"GeolocationCity": "Kew",
"GeolocationRegion": "England",
"GeolocationSubregion": "Greater London",
"GeolocationCountryCode": "GB",
"GeolocationCountry": "United Kingdom",
"GeolocationTimeZone": "Europe/London",
"GeolocationFeatureCode": "PPL",
"GeolocationFeatureType": "Populated Place",
"GeolocationPopulation": 11000,
"GeolocationPosition": "51.4816, -0.2874",
"GeolocationDistance": "0.33 km",
"GeolocationBearing": 54
},
"Doc1": {
"GeolocationCity": "Brentford",
"GeolocationRegion": "England",
"GeolocationSubregion": "Greater London",
"GeolocationCountryCode": "GB",
"GeolocationCountry": "United Kingdom",
"GeolocationTimeZone": "Europe/London",
"GeolocationFeatureCode": "PPL",
"GeolocationFeatureType": "Populated Place",
"GeolocationPopulation": 11000,
"GeolocationPosition": "51.4862, -0.3083",
"GeolocationDistance": "1.45 km",
"GeolocationBearing": 291
}
}]
- Phil
Ah, that's better :) Where there is an ExifTool, there is a way.
Thanks!