Ignore:
Timestamp:
2015-03-10T01:17:39+01:00 (9 years ago)
Author:
Don-vip
Message:

fix #11162 - update to metadata-extractor 2.7.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/com/drew/metadata/exif/GpsDescriptor.java

    r6127 r8132  
    11/*
    2  * Copyright 2002-2012 Drew Noakes
     2 * Copyright 2002-2015 Drew Noakes
    33 *
    44 *    Licensed under the Apache License, Version 2.0 (the "License");
     
    1616 * More information about this project is available at:
    1717 *
    18  *    http://drewnoakes.com/code/exif/
    19  *    http://code.google.com/p/metadata-extractor/
     18 *    https://drewnoakes.com/code/exif/
     19 *    https://github.com/drewnoakes/metadata-extractor
    2020 */
    2121package com.drew.metadata.exif;
     
    2929import java.text.DecimalFormat;
    3030
     31import static com.drew.metadata.exif.GpsDirectory.*;
     32
    3133/**
    32  * Provides human-readable string representations of tag values stored in a <code>GpsDirectory</code>.
    33  *
    34  * @author Drew Noakes http://drewnoakes.com
     34 * Provides human-readable string representations of tag values stored in a {@link GpsDirectory}.
     35 *
     36 * @author Drew Noakes https://drewnoakes.com
    3537 */
    3638public class GpsDescriptor extends TagDescriptor<GpsDirectory>
     
    4143    }
    4244
     45    @Override
    4346    @Nullable
    4447    public String getDescription(int tagType)
    4548    {
    4649        switch (tagType) {
    47             case GpsDirectory.TAG_GPS_VERSION_ID:
     50            case TAG_VERSION_ID:
    4851                return getGpsVersionIdDescription();
    49             case GpsDirectory.TAG_GPS_ALTITUDE:
     52            case TAG_ALTITUDE:
    5053                return getGpsAltitudeDescription();
    51             case GpsDirectory.TAG_GPS_ALTITUDE_REF:
     54            case TAG_ALTITUDE_REF:
    5255                return getGpsAltitudeRefDescription();
    53             case GpsDirectory.TAG_GPS_STATUS:
     56            case TAG_STATUS:
    5457                return getGpsStatusDescription();
    55             case GpsDirectory.TAG_GPS_MEASURE_MODE:
     58            case TAG_MEASURE_MODE:
    5659                return getGpsMeasureModeDescription();
    57             case GpsDirectory.TAG_GPS_SPEED_REF:
     60            case TAG_SPEED_REF:
    5861                return getGpsSpeedRefDescription();
    59             case GpsDirectory.TAG_GPS_TRACK_REF:
    60             case GpsDirectory.TAG_GPS_IMG_DIRECTION_REF:
    61             case GpsDirectory.TAG_GPS_DEST_BEARING_REF:
     62            case TAG_TRACK_REF:
     63            case TAG_IMG_DIRECTION_REF:
     64            case TAG_DEST_BEARING_REF:
    6265                return getGpsDirectionReferenceDescription(tagType);
    63             case GpsDirectory.TAG_GPS_TRACK:
    64             case GpsDirectory.TAG_GPS_IMG_DIRECTION:
    65             case GpsDirectory.TAG_GPS_DEST_BEARING:
     66            case TAG_TRACK:
     67            case TAG_IMG_DIRECTION:
     68            case TAG_DEST_BEARING:
    6669                return getGpsDirectionDescription(tagType);
    67             case GpsDirectory.TAG_GPS_DEST_DISTANCE_REF:
     70            case TAG_DEST_DISTANCE_REF:
    6871                return getGpsDestinationReferenceDescription();
    69             case GpsDirectory.TAG_GPS_TIME_STAMP:
     72            case TAG_TIME_STAMP:
    7073                return getGpsTimeStampDescription();
    71             case GpsDirectory.TAG_GPS_LONGITUDE:
     74            case TAG_LONGITUDE:
    7275                // three rational numbers -- displayed in HH"MM"SS.ss
    7376                return getGpsLongitudeDescription();
    74             case GpsDirectory.TAG_GPS_LATITUDE:
     77            case TAG_LATITUDE:
    7578                // three rational numbers -- displayed in HH"MM"SS.ss
    7679                return getGpsLatitudeDescription();
    77             case GpsDirectory.TAG_GPS_DIFFERENTIAL:
     80            case TAG_DIFFERENTIAL:
    7881                return getGpsDifferentialDescription();
    7982            default:
     
    8588    private String getGpsVersionIdDescription()
    8689    {
    87         return convertBytesToVersionString(_directory.getIntArray(GpsDirectory.TAG_GPS_VERSION_ID), 1);
     90        return getVersionBytesDescription(TAG_VERSION_ID, 1);
    8891    }
    8992
     
    9295    {
    9396        GeoLocation location = _directory.getGeoLocation();
    94 
    95         if (location == null)
    96             return null;
    97 
    98         return GeoLocation.decimalToDegreesMinutesSecondsString(location.getLatitude());
     97        return location == null ? null : GeoLocation.decimalToDegreesMinutesSecondsString(location.getLatitude());
    9998    }
    10099
     
    103102    {
    104103        GeoLocation location = _directory.getGeoLocation();
    105 
    106         if (location == null)
    107             return null;
    108 
    109         return GeoLocation.decimalToDegreesMinutesSecondsString(location.getLongitude());
     104        return location == null ? null : GeoLocation.decimalToDegreesMinutesSecondsString(location.getLongitude());
    110105    }
    111106
     
    114109    {
    115110        // time in hour, min, sec
    116         int[] timeComponents = _directory.getIntArray(GpsDirectory.TAG_GPS_TIME_STAMP);
    117         if (timeComponents==null)
    118             return null;
    119         StringBuilder description = new StringBuilder();
    120         description.append(timeComponents[0]);
    121         description.append(":");
    122         description.append(timeComponents[1]);
    123         description.append(":");
    124         description.append(timeComponents[2]);
    125         description.append(" UTC");
    126         return description.toString();
     111        int[] timeComponents = _directory.getIntArray(TAG_TIME_STAMP);
     112        return timeComponents == null ? null : String.format("%d:%d:%d UTC", timeComponents[0], timeComponents[1], timeComponents[2]);
    127113    }
    128114
     
    130116    public String getGpsDestinationReferenceDescription()
    131117    {
    132         final String value = _directory.getString(GpsDirectory.TAG_GPS_DEST_DISTANCE_REF);
    133         if (value==null)
     118        final String value = _directory.getString(TAG_DEST_DISTANCE_REF);
     119        if (value == null)
    134120            return null;
    135121        String distanceRef = value.trim();
     
    151137        // provide a decimal version of rational numbers in the description, to avoid strings like "35334/199 degrees"
    152138        String value = angle != null
    153                 ? new DecimalFormat("0.##").format(angle.doubleValue())
    154                 : _directory.getString(tagType);
    155         if (value==null || value.trim().length()==0)
    156             return null;
    157         return value.trim() + " degrees";
     139            ? new DecimalFormat("0.##").format(angle.doubleValue())
     140            : _directory.getString(tagType);
     141        return value == null || value.trim().length() == 0 ? null : value.trim() + " degrees";
    158142    }
    159143
     
    162146    {
    163147        final String value = _directory.getString(tagType);
    164         if (value==null)
     148        if (value == null)
    165149            return null;
    166150        String gpsDistRef = value.trim();
     
    177161    public String getGpsSpeedRefDescription()
    178162    {
    179         final String value = _directory.getString(GpsDirectory.TAG_GPS_SPEED_REF);
    180         if (value==null)
     163        final String value = _directory.getString(TAG_SPEED_REF);
     164        if (value == null)
    181165            return null;
    182166        String gpsSpeedRef = value.trim();
     
    195179    public String getGpsMeasureModeDescription()
    196180    {
    197         final String value = _directory.getString(GpsDirectory.TAG_GPS_MEASURE_MODE);
    198         if (value==null)
     181        final String value = _directory.getString(TAG_MEASURE_MODE);
     182        if (value == null)
    199183            return null;
    200184        String gpsSpeedMeasureMode = value.trim();
     
    211195    public String getGpsStatusDescription()
    212196    {
    213         final String value = _directory.getString(GpsDirectory.TAG_GPS_STATUS);
    214         if (value==null)
     197        final String value = _directory.getString(TAG_STATUS);
     198        if (value == null)
    215199            return null;
    216200        String gpsStatus = value.trim();
     
    227211    public String getGpsAltitudeRefDescription()
    228212    {
    229         Integer value = _directory.getInteger(GpsDirectory.TAG_GPS_ALTITUDE_REF);
    230         if (value==null)
    231             return null;
    232         if (value == 0)
    233             return "Sea level";
    234         if (value == 1)
    235             return "Below sea level";
    236         return "Unknown (" + value + ")";
     213        return getIndexedDescription(TAG_ALTITUDE_REF, "Sea level", "Below sea level");
    237214    }
    238215
     
    240217    public String getGpsAltitudeDescription()
    241218    {
    242         final Rational value = _directory.getRational(GpsDirectory.TAG_GPS_ALTITUDE);
    243         if (value==null)
    244             return null;
    245         return value.intValue() + " metres";
     219        final Rational value = _directory.getRational(TAG_ALTITUDE);
     220        return value == null ? null : value.intValue() + " metres";
    246221    }
    247222
     
    249224    public String getGpsDifferentialDescription()
    250225    {
    251         final Integer value = _directory.getInteger(GpsDirectory.TAG_GPS_DIFFERENTIAL);
    252         if (value==null)
    253             return null;
    254         if (value == 0)
    255             return "No Correction";
    256         if (value == 1)
    257             return "Differential Corrected";
    258         return "Unknown (" + value + ")";
     226        return getIndexedDescription(TAG_DIFFERENTIAL, "No Correction", "Differential Corrected");
    259227    }
    260228
     
    263231    {
    264232        GeoLocation location = _directory.getGeoLocation();
    265 
    266         if (location == null)
    267             return null;
    268 
    269         return location.toDMSString();
     233        return location == null ? null : location.toDMSString();
    270234    }
    271235}
Note: See TracChangeset for help on using the changeset viewer.