Ignore:
Timestamp:
2013-12-07T13:51:13+01:00 (10 years ago)
Author:
Don-vip
Message:

Sonar/Findbugs: fix recent issues

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java

    r6392 r6450  
    10741074        List<ImageEntry> dateImgLst = new ArrayList<ImageEntry>(yLayer.data.size());
    10751075        for (ImageEntry e : yLayer.data) {
    1076             if (e.getExifTime() == null) {
     1076            if (!e.hasExifTime()) {
    10771077                continue;
    10781078            }
     
    11591159    }
    11601160
     1161    private static Double getElevation(WayPoint wp) {
     1162        String value = (String) wp.attr.get("ele");
     1163        if (value != null) {
     1164            try {
     1165                return new Double(value);
     1166            } catch (NumberFormatException e) {
     1167                Main.warn(e);
     1168            }
     1169        }
     1170        return null;
     1171    }
     1172   
    11611173    private int matchPoints(List<ImageEntry> images, WayPoint prevWp, long prevWpTime,
    11621174            WayPoint curWp, long curWpTime, long offset) {
     
    11751187        Double speed = null;
    11761188        Double prevElevation = null;
    1177         Double curElevation = null;
    11781189
    11791190        if (prevWp != null) {
     
    11831194                speed = 3600 * distance / (curWpTime - prevWpTime);
    11841195            }
    1185             try {
    1186                 prevElevation = new Double((String) prevWp.attr.get("ele"));
    1187             } catch(Exception e) {}
    1188         }
    1189 
    1190         try {
    1191             curElevation = new Double((String) curWp.attr.get("ele"));
    1192         } catch (Exception e) {}
     1196            prevElevation = getElevation(prevWp);
     1197        }
     1198
     1199        Double curElevation = getElevation(curWp);
    11931200
    11941201        // First trackpoint, then interval is set to five seconds, i.e. photos up to five seconds
    11951202        // before the first point will be geotagged with the starting point
    1196         if(prevWpTime == 0 || curWpTime <= prevWpTime) {
     1203        if (prevWpTime == 0 || curWpTime <= prevWpTime) {
    11971204            while (true) {
    11981205                if (i < 0) {
     
    12001207                }
    12011208                final ImageEntry curImg = images.get(i);
    1202                 if (curImg.getExifTime().getTime() > curWpTime
    1203                         || curImg.getExifTime().getTime() < curWpTime - interval) {
     1209                long time = curImg.getExifTime().getTime();
     1210                if (time > curWpTime || time < curWpTime - interval) {
    12041211                    break;
    12051212                }
    1206                 if(curImg.tmp.getPos() == null) {
     1213                if (curImg.tmp.getPos() == null) {
    12071214                    curImg.tmp.setPos(curWp.getCoor());
    12081215                    curImg.tmp.setSpeed(speed);
     
    12291236            }
    12301237
    1231             if(curImg.tmp.getPos() == null) {
    1232                 // The values of timeDiff are between 0 and 1, it is not seconds but a dimensionless
    1233                 // variable
     1238            if (curImg.tmp.getPos() == null) {
     1239                // The values of timeDiff are between 0 and 1, it is not seconds but a dimensionless variable
    12341240                double timeDiff = (double)(imgTime - prevWpTime) / interval;
    12351241                curImg.tmp.setPos(prevWp.getCoor().interpolate(curWp.getCoor(), timeDiff));
Note: See TracChangeset for help on using the changeset viewer.