Ignore:
Timestamp:
2011-10-17T00:11:45+02:00 (13 years ago)
Author:
Don-vip
Message:

see #6960 - Code simplification

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/Bounds.java

    r4521 r4522  
    8282        }
    8383       
    84         int minLatIndex;
    85         int minLonIndex;
    86         int maxLatIndex;
    87         int maxLonIndex;
    88        
    8984        switch (parseMethod) {
    9085            case LEFT_BOTTOM_RIGHT_TOP:
    91                 minLatIndex = 1;
    92                 minLonIndex = 0;
    93                 maxLatIndex = 3;
    94                 maxLonIndex = 2;
     86                this.minLat = initLat(values[1]);
     87                this.minLon = initLon(values[0]);
     88                this.maxLat = initLat(values[3]);
     89                this.maxLon = initLon(values[2]);
    9590                break;
    9691            case MINLAT_MINLON_MAXLAT_MAXLON:
    9792            default:
    98                 minLatIndex = 0;
    99                 minLonIndex = 1;
    100                 maxLatIndex = 2;
    101                 maxLonIndex = 3;
    102         }
    103        
    104         if (!LatLon.isValidLat(values[minLatIndex]))
    105             throw new IllegalArgumentException(tr("Illegal latitude value ''{0}''", values[minLatIndex]));
    106         if (!LatLon.isValidLon(values[minLonIndex]))
    107             throw new IllegalArgumentException(tr("Illegal longitude value ''{0}''", values[minLonIndex]));
    108         if (!LatLon.isValidLat(values[maxLatIndex]))
    109             throw new IllegalArgumentException(tr("Illegal latitude value ''{0}''", values[maxLatIndex]));
    110         if (!LatLon.isValidLon(values[maxLonIndex]))
    111             throw new IllegalArgumentException(tr("Illegal longitude value ''{0}''", values[maxLonIndex]));
    112 
    113         this.minLat = LatLon.roundToOsmPrecision(values[minLatIndex]);
    114         this.minLon = LatLon.roundToOsmPrecision(values[minLonIndex]);
    115         this.maxLat = LatLon.roundToOsmPrecision(values[maxLatIndex]);
    116         this.maxLon = LatLon.roundToOsmPrecision(values[maxLonIndex]);
     93                this.minLat = initLat(values[0]);
     94                this.minLon = initLon(values[1]);
     95                this.maxLat = initLat(values[2]);
     96                this.maxLon = initLon(values[3]);
     97        }
     98    }
     99   
     100    protected static double initLat(double value) {
     101        if (!LatLon.isValidLat(value))
     102            throw new IllegalArgumentException(tr("Illegal latitude value ''{0}''", value));
     103        return LatLon.roundToOsmPrecision(value);
     104    }
     105
     106    protected static double initLon(double value) {
     107        if (!LatLon.isValidLon(value))
     108            throw new IllegalArgumentException(tr("Illegal longitude value ''{0}''", value));
     109        return LatLon.roundToOsmPrecision(value);
    117110    }
    118111
Note: See TracChangeset for help on using the changeset viewer.