diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2011-09-08 00:00:58 +0200 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2011-09-08 11:32:14 +0200 |
| commit | 39ec7accd759fd60706523b366977ba371efd168 (patch) | |
| tree | 401ba08d9ec58e49d02ce614e12db5cf7b2b57bd /src/cgeo/geocaching/files/GPXParser.java | |
| parent | 668472ec735f827a4741a971614596df02618689 (diff) | |
| download | cgeo-39ec7accd759fd60706523b366977ba371efd168.zip cgeo-39ec7accd759fd60706523b366977ba371efd168.tar.gz cgeo-39ec7accd759fd60706523b366977ba371efd168.tar.bz2 | |
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.
Diffstat (limited to 'src/cgeo/geocaching/files/GPXParser.java')
| -rw-r--r-- | src/cgeo/geocaching/files/GPXParser.java | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/cgeo/geocaching/files/GPXParser.java b/src/cgeo/geocaching/files/GPXParser.java index 101d68b..978079d 100644 --- a/src/cgeo/geocaching/files/GPXParser.java +++ b/src/cgeo/geocaching/files/GPXParser.java @@ -34,6 +34,7 @@ import cgeo.geocaching.cgSettings; import cgeo.geocaching.cgTrackable; import cgeo.geocaching.cgeoapplication; import cgeo.geocaching.connector.ConnectorFactory; +import cgeo.geocaching.geopoint.Geopoint; public abstract class GPXParser extends FileParser { @@ -226,11 +227,9 @@ public abstract class GPXParser extends FileParser { @Override public void start(Attributes attrs) { try { - if (attrs.getIndex("lat") > -1) { - cache.latitude = new Double(attrs.getValue("lat")); - } - if (attrs.getIndex("lon") > -1) { - cache.longitude = new Double(attrs.getValue("lon")); + if (attrs.getIndex("lat") > -1 && attrs.getIndex("lon") > -1) { + cache.coords = new Geopoint(new Double(attrs.getValue("lat")), + new Double(attrs.getValue("lon"))); } } catch (Exception e) { Log.w(cgSettings.tag, "Failed to parse waypoint's latitude and/or longitude."); @@ -251,7 +250,7 @@ public abstract class GPXParser extends FileParser { } if (StringUtils.isNotBlank(cache.geocode) - && cache.latitude != null && cache.longitude != null + && cache.coords != null && ((type == null && sym == null) || (type != null && type.indexOf("geocache") > -1) || (sym != null && sym.indexOf("geocache") > -1))) { |
