From 39ec7accd759fd60706523b366977ba371efd168 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Thu, 8 Sep 2011 00:00:58 +0200 Subject: Refactoring to use Geopoint for coordinates This uses the new Geopoint immutable class discussed in #58. No more independent longitude or latitude fields -- they are now treated and defined as a consistent pair. --- src/cgeo/geocaching/files/LocParser.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/cgeo/geocaching/files/LocParser.java') diff --git a/src/cgeo/geocaching/files/LocParser.java b/src/cgeo/geocaching/files/LocParser.java index 9f7f525..47d46d4 100644 --- a/src/cgeo/geocaching/files/LocParser.java +++ b/src/cgeo/geocaching/files/LocParser.java @@ -19,6 +19,7 @@ import cgeo.geocaching.cgCoord; import cgeo.geocaching.cgSearch; import cgeo.geocaching.cgSettings; import cgeo.geocaching.cgeoapplication; +import cgeo.geocaching.geopoint.Geopoint; public final class LocParser extends FileParser { private static final Pattern patternGeocode = Pattern @@ -51,8 +52,7 @@ public final class LocParser extends FileParser { } private static void copyCoordToCache(final cgCoord coord, final cgCache cache) { - cache.latitude = coord.latitude; - cache.longitude = coord.longitude; + cache.coords = coord.coords; cache.difficulty = coord.difficulty; cache.terrain = coord.terrain; cache.size = coord.size; @@ -93,14 +93,12 @@ public final class LocParser extends FileParser { pointCoord.name = name; } final Matcher matcherLat = patternLat.matcher(pointString); - if (matcherLat.find()) { - tmp = cgBase.parseCoordinate(matcherLat.group(1).trim(), "lat"); - pointCoord.latitude = (Double) tmp.get("coordinate"); - } final Matcher matcherLon = patternLon.matcher(pointString); - if (matcherLon.find()) { - tmp = cgBase.parseCoordinate(matcherLon.group(1).trim(), "lon"); - pointCoord.longitude = (Double) tmp.get("coordinate"); + if (matcherLat.find() && matcherLon.find()) { + final MaptmpLat = cgBase.parseCoordinate(matcherLat.group(1).trim(), "lat"); + final Map tmpLon = cgBase.parseCoordinate(matcherLon.group(1).trim(), "lon"); + pointCoord.coords = new Geopoint((Double) tmpLat.get("coordinate"), + (Double) tmpLon.get("coordinate")); } final Matcher matcherDifficulty = patternDifficulty.matcher(pointString); if (matcherDifficulty.find()) { -- cgit v1.1