diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2012-04-20 20:16:40 +0200 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2012-04-20 22:14:19 +0200 |
| commit | b9b297a38accdd54641b325ece04f488bbf90fb8 (patch) | |
| tree | 5ab47eb0f713148a86a03d7c14ee2223acbfb396 /main/src/cgeo/geocaching/geopoint | |
| parent | c91a817d13a8f68cc5b7399ba4cbe7cd16a4645b (diff) | |
| download | cgeo-b9b297a38accdd54641b325ece04f488bbf90fb8.zip cgeo-b9b297a38accdd54641b325ece04f488bbf90fb8.tar.gz cgeo-b9b297a38accdd54641b325ece04f488bbf90fb8.tar.bz2 | |
Refactoring: cleanup control flow
Diffstat (limited to 'main/src/cgeo/geocaching/geopoint')
| -rw-r--r-- | main/src/cgeo/geocaching/geopoint/GeopointParser.java | 23 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/geopoint/Viewport.java | 18 |
2 files changed, 20 insertions, 21 deletions
diff --git a/main/src/cgeo/geocaching/geopoint/GeopointParser.java b/main/src/cgeo/geocaching/geopoint/GeopointParser.java index ad5d6ba..3c72f1e 100644 --- a/main/src/cgeo/geocaching/geopoint/GeopointParser.java +++ b/main/src/cgeo/geocaching/geopoint/GeopointParser.java @@ -129,19 +129,18 @@ public class GeopointParser return new ResultWrapper(sign * (degree + minutes / 60.0 + seconds / 3600.0), matcher.start(), matcher.group().length()); - } else { - - // Nothing found with "N 52...", try to match string as decimaldegree - try { - final String[] items = StringUtils.split(text.trim()); - if (items.length > 0) { - final int index = (latlon == LatLon.LON ? items.length - 1 : 0); - final int pos = (latlon == LatLon.LON ? text.lastIndexOf(items[index]) : text.indexOf(items[index])); - return new ResultWrapper(Double.parseDouble(items[index]), pos, items[index].length()); - } - } catch (NumberFormatException e) { - // The right exception will be raised below. + } + + // Nothing found with "N 52...", try to match string as decimaldegree + try { + final String[] items = StringUtils.split(text.trim()); + if (items.length > 0) { + final int index = (latlon == LatLon.LON ? items.length - 1 : 0); + final int pos = (latlon == LatLon.LON ? text.lastIndexOf(items[index]) : text.indexOf(items[index])); + return new ResultWrapper(Double.parseDouble(items[index]), pos, items[index].length()); } + } catch (NumberFormatException e) { + // The right exception will be raised below. } throw new ParseException("Could not parse coordinates as " + latlon + ": \"" + text + "\"", latlon); diff --git a/main/src/cgeo/geocaching/geopoint/Viewport.java b/main/src/cgeo/geocaching/geopoint/Viewport.java index 4f70291..1d082fc 100644 --- a/main/src/cgeo/geocaching/geopoint/Viewport.java +++ b/main/src/cgeo/geocaching/geopoint/Viewport.java @@ -128,16 +128,16 @@ public class Viewport { public Viewport expand(final ICoordinates point) { if (contains(point)) { return this; - } else { - final Geopoint coords = point.getCoords(); - final double latitude = coords.getLatitude(); - final double longitude = coords.getLongitude(); - final double latMin = Math.min(getLatitudeMin(), latitude); - final double latMax = Math.max(getLatitudeMax(), latitude); - final double lonMin = Math.min(getLongitudeMin(), longitude); - final double lonMax = Math.max(getLongitudeMax(), longitude); - return new Viewport(new Geopoint(latMin, lonMin), new Geopoint(latMax, lonMax)); } + + final Geopoint coords = point.getCoords(); + final double latitude = coords.getLatitude(); + final double longitude = coords.getLongitude(); + final double latMin = Math.min(getLatitudeMin(), latitude); + final double latMax = Math.max(getLatitudeMax(), latitude); + final double lonMin = Math.min(getLongitudeMin(), longitude); + final double lonMax = Math.max(getLongitudeMax(), longitude); + return new Viewport(new Geopoint(latMin, lonMin), new Geopoint(latMax, lonMax)); } /** |
