Changeset 15217 in josm for trunk/src/com/drew/metadata/exif/GpsDescriptor.java
- Timestamp:
- 2019-07-07T01:56:46+02:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/com/drew/metadata/exif/GpsDescriptor.java
r13061 r15217 1 1 /* 2 * Copyright 2002-201 7 Drew Noakes2 * Copyright 2002-2019 Drew Noakes and contributors 3 3 * 4 4 * Licensed under the Apache License, Version 2.0 (the "License"); … … 59 59 case TAG_MEASURE_MODE: 60 60 return getGpsMeasureModeDescription(); 61 case TAG_DOP: 62 return getGpsDopDescription(); 61 63 case TAG_SPEED_REF: 62 64 return getGpsSpeedRefDescription(); 65 case TAG_SPEED: 66 return getGpsSpeedDescription(); 63 67 case TAG_TRACK_REF: 64 68 case TAG_IMG_DIRECTION_REF: … … 69 73 case TAG_DEST_BEARING: 70 74 return getGpsDirectionDescription(tagType); 75 case TAG_DEST_LATITUDE: 76 return getGpsDestLatitudeDescription(); 77 case TAG_DEST_LONGITUDE: 78 return getGpsDestLongitudeDescription(); 71 79 case TAG_DEST_DISTANCE_REF: 72 80 return getGpsDestinationReferenceDescription(); 81 case TAG_DEST_DISTANCE: 82 return getGpsDestDistanceDescription(); 73 83 case TAG_TIME_STAMP: 74 84 return getGpsTimeStampDescription(); … … 79 89 // three rational numbers -- displayed in HH"MM"SS.ss 80 90 return getGpsLatitudeDescription(); 91 case TAG_PROCESSING_METHOD: 92 return getGpsProcessingMethodDescription(); 93 case TAG_AREA_INFORMATION: 94 return getGpsAreaInformationDescription(); 81 95 case TAG_DIFFERENTIAL: 82 96 return getGpsDifferentialDescription(); 97 case TAG_H_POSITIONING_ERROR: 98 return getGpsHPositioningErrorDescription(); 83 99 default: 84 100 return super.getDescription(tagType); … … 121 137 122 138 @Nullable 139 public String getGpsDestLatitudeDescription() 140 { 141 Rational[] latitudes = _directory.getRationalArray(TAG_DEST_LATITUDE); 142 String latitudeRef = _directory.getString(TAG_DEST_LATITUDE_REF); 143 144 if (latitudes == null || latitudes.length != 3 || latitudeRef == null) 145 return null; 146 147 Double lat = GeoLocation.degreesMinutesSecondsToDecimal( 148 latitudes[0], latitudes[1], latitudes[2], latitudeRef.equalsIgnoreCase("S")); 149 150 return lat == null ? null : GeoLocation.decimalToDegreesMinutesSecondsString(lat); 151 } 152 153 @Nullable 154 public String getGpsDestLongitudeDescription() 155 { 156 Rational[] longitudes = _directory.getRationalArray(TAG_LONGITUDE); 157 String longitudeRef = _directory.getString(TAG_LONGITUDE_REF); 158 159 if (longitudes == null || longitudes.length != 3 || longitudeRef == null) 160 return null; 161 162 Double lon = GeoLocation.degreesMinutesSecondsToDecimal( 163 longitudes[0], longitudes[1], longitudes[2], longitudeRef.equalsIgnoreCase("W")); 164 165 return lon == null ? null : GeoLocation.decimalToDegreesMinutesSecondsString(lon); 166 } 167 168 @Nullable 123 169 public String getGpsDestinationReferenceDescription() 124 170 { … … 139 185 140 186 @Nullable 187 public String getGpsDestDistanceDescription() 188 { 189 final Rational value = _directory.getRational(TAG_DEST_DISTANCE); 190 if (value == null) 191 return null; 192 final String unit = getGpsDestinationReferenceDescription(); 193 return String.format("%s %s", 194 new DecimalFormat("0.##").format(value.doubleValue()), 195 unit == null ? "unit" : unit.toLowerCase()); 196 } 197 198 @Nullable 141 199 public String getGpsDirectionDescription(int tagType) 142 200 { … … 166 224 167 225 @Nullable 226 public String getGpsDopDescription() 227 { 228 final Rational value = _directory.getRational(TAG_DOP); 229 return value == null ? null : new DecimalFormat("0.##").format(value.doubleValue()); 230 } 231 232 @Nullable 168 233 public String getGpsSpeedRefDescription() 169 234 { … … 173 238 String gpsSpeedRef = value.trim(); 174 239 if ("K".equalsIgnoreCase(gpsSpeedRef)) { 175 return "k ph";240 return "km/h"; 176 241 } else if ("M".equalsIgnoreCase(gpsSpeedRef)) { 177 242 return "mph"; … … 181 246 return "Unknown (" + gpsSpeedRef + ")"; 182 247 } 248 } 249 250 @Nullable 251 public String getGpsSpeedDescription() 252 { 253 final Rational value = _directory.getRational(TAG_SPEED); 254 if (value == null) 255 return null; 256 final String unit = getGpsSpeedRefDescription(); 257 return String.format("%s %s", 258 new DecimalFormat("0.##").format(value.doubleValue()), 259 unit == null ? "unit" : unit.toLowerCase()); 183 260 } 184 261 … … 225 302 { 226 303 final Rational value = _directory.getRational(TAG_ALTITUDE); 227 return value == null ? null : value.intValue() + " metres"; 304 return value == null ? null : new DecimalFormat("0.##").format(value.doubleValue()) + " metres"; 305 } 306 307 @Nullable 308 public String getGpsProcessingMethodDescription() 309 { 310 return getEncodedTextDescription(TAG_PROCESSING_METHOD); 311 } 312 313 @Nullable 314 public String getGpsAreaInformationDescription() 315 { 316 return getEncodedTextDescription(TAG_AREA_INFORMATION); 228 317 } 229 318 … … 232 321 { 233 322 return getIndexedDescription(TAG_DIFFERENTIAL, "No Correction", "Differential Corrected"); 323 } 324 325 @Nullable 326 public String getGpsHPositioningErrorDescription() 327 { 328 final Rational value = _directory.getRational(TAG_H_POSITIONING_ERROR); 329 return value == null ? null : new DecimalFormat("0.##").format(value.doubleValue()) + " metres"; 234 330 } 235 331
Note:
See TracChangeset
for help on using the changeset viewer.