画像のすべてのメタデータ (緯度、経度、日時など) を実際に読み取る Java プログラムを作成しています。以下は、私が実行しているサンプルコードです。
public static void findLatLong(File jpg){
try {
Metadata metadata = ImageMetadataReader.readMetadata(jpg);
if (metadata.containsDirectory(GpsDirectory.class)) {
GpsDirectory gpsDir =(GpsDirectory)metadata.getDirectory(GpsDirectory.class);
GpsDescriptor gpsDesc = new GpsDescriptor(gpsDir);
System.out.println("Latitude: " + gpsDesc.getGpsLatitudeDescription());
System.out.println("Longitude : " + gpsDesc.getGpsLongitudeDescription());
System.out.println("Date : " + gpsDesc.getGpsTimeStampDescription());
System.out.println("Minute : " + gpsDesc.getDegreesMinutesSecondsDescription());
}else{
// System.out.println("----- Did not find GPS Information-------------for file " + jpg.getName() );
}
} catch (ImageProcessingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
出力: - 緯度:21.0°8.0 '22.99999999999998693 "経度:79.0°3.0' 12.99999994998"日付:14:16:30 UTC分:21.0°8.0 '22.9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
これはすべて学位形式だと思います。緯度と経度の実際の値を取得する方法を教えてください。また、適切な日付を取得します。