diff options
author | Samuel Tardieu <sam@rfc1149.net> | 2012-04-01 16:48:50 +0200 |
---|---|---|
committer | Samuel Tardieu <sam@rfc1149.net> | 2012-04-01 16:48:50 +0200 |
commit | 087f90fbb50796ae15c84ab6e321f5ddf8dceeec (patch) | |
tree | 974b1a822f25a30d2fed3e8fbdd1f782190d82f8 /main/src/cgeo | |
parent | b69cad6442d9d492fb4277fb4045ef4d8e5fecdf (diff) | |
download | cgeo-087f90fbb50796ae15c84ab6e321f5ddf8dceeec.zip cgeo-087f90fbb50796ae15c84ab6e321f5ddf8dceeec.tar.gz cgeo-087f90fbb50796ae15c84ab6e321f5ddf8dceeec.tar.bz2 |
Refactoring: use IWaypoint and cgCache instead of cgCoord object
Most of the time, the cgCoord is built from an existing cache or from an
existing waypoint. And most of the time, using the IWaypoint interface
is fine.
We can see a cache as being a waypoint as well, so by making it
implement IWaypoint we can manipulate IWaypoint objects every time we
were manipulating cgCoord ones without copying.
After this refactoring, cgCoord was only used to hold some partial cache
information. cgCache can be used instead, and cgCoord is not needed
anymore.
Diffstat (limited to 'main/src/cgeo')
15 files changed, 123 insertions, 295 deletions
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java index 8fd0f03..de754b9 100644 --- a/main/src/cgeo/geocaching/CacheDetailActivity.java +++ b/main/src/cgeo/geocaching/CacheDetailActivity.java @@ -836,39 +836,15 @@ public class CacheDetailActivity extends AbstractActivity { * * @return A {@link List} of all coordinates */ - public List<cgCoord> getCoordinates() { - List<cgCoord> coordinates = new ArrayList<cgCoord>(); + public List<IWaypoint> getCoordinates() { + List<IWaypoint> coordinates = new ArrayList<IWaypoint>(); // cache - try { - final cgCoord coords = new cgCoord(); - coords.setCoordType("cache"); - if (StringUtils.isNotBlank(cache.getName())) { - coords.setName(cache.getName()); - } else { - coords.setName(cache.getGeocode().toUpperCase()); - } - coords.setCoords(cache.getCoords()); - coordinates.add(coords); - } catch (Exception e) { - Log.e(Settings.tag, "CacheDetailActivity.getCoordinates (cache)", e); - } + coordinates.add(cache); // waypoints - try { - if (cache.hasWaypoints()) { - for (cgWaypoint waypoint : cache.getWaypoints()) { - if (null != waypoint.getCoords()) { - final cgCoord coords = new cgCoord(); - coords.setCoordType("waypoint"); - coords.setName(waypoint.getName()); - coords.setCoords(waypoint.getCoords()); - coordinates.add(coords); - } - } - } - } catch (Exception e) { - Log.e(Settings.tag, "CacheDetailActivity.getCoordinates (waypoint)", e); + if (cache.hasWaypoints()) { + coordinates.addAll(cache.getWaypoints()); } return coordinates; diff --git a/main/src/cgeo/geocaching/IWaypoint.java b/main/src/cgeo/geocaching/IWaypoint.java index 870fb12..3e26052 100644 --- a/main/src/cgeo/geocaching/IWaypoint.java +++ b/main/src/cgeo/geocaching/IWaypoint.java @@ -18,4 +18,6 @@ public interface IWaypoint extends ILogable { public abstract WaypointType getWaypointType(); + public abstract String getCoordType(); + } diff --git a/main/src/cgeo/geocaching/cgCache.java b/main/src/cgeo/geocaching/cgCache.java index ee692ed..beffa85 100644 --- a/main/src/cgeo/geocaching/cgCache.java +++ b/main/src/cgeo/geocaching/cgCache.java @@ -43,7 +43,7 @@ import java.util.regex.Pattern; /** * Internal c:geo representation of a "cache" */ -public class cgCache implements ICache { +public class cgCache implements ICache, IWaypoint { private long updated = 0; private long detailedUpdate = 0; @@ -1430,4 +1430,19 @@ public class cgCache implements ICache { public void setZoomlevel(int zoomlevel) { this.zoomlevel = zoomlevel; } + + @Override + public int getId() { + return 0; + } + + @Override + public WaypointType getWaypointType() { + return null; + } + + @Override + public String getCoordType() { + return "cache"; + } } diff --git a/main/src/cgeo/geocaching/cgCoord.java b/main/src/cgeo/geocaching/cgCoord.java deleted file mode 100644 index 236b8f5..0000000 --- a/main/src/cgeo/geocaching/cgCoord.java +++ /dev/null @@ -1,168 +0,0 @@ -package cgeo.geocaching; - -import cgeo.geocaching.enumerations.CacheSize; -import cgeo.geocaching.enumerations.CacheType; -import cgeo.geocaching.enumerations.WaypointType; -import cgeo.geocaching.geopoint.Geopoint; - -public class cgCoord implements IBasicCache, IWaypoint { - - private int id = 0; // only valid if constructed with a waypoint - private WaypointType waypointType = null; // only valid if constructed with a waypoint - private String guid = null; // only valid if constructed with a cache - private CacheType cacheType = null; // only valid if constructed with a cache - private String geocode = ""; - private String coordType = "cache"; // used values: { cache, waypoint } - private String typeSpec = CacheType.TRADITIONAL.id; - private String name = ""; - private boolean found = false; - private boolean disabled = false; - private Geopoint coords = new Geopoint(0, 0); - private float difficulty = 0; - private float terrain = 0; - private CacheSize size = CacheSize.UNKNOWN; - - public cgCoord() { - } - - public cgCoord(cgCache cache) { - guid = cache.getGuid(); - disabled = cache.isDisabled(); - found = cache.isFound(); - geocode = cache.getGeocode(); - coords = cache.getCoords(); - name = cache.getName(); - coordType = "cache"; - typeSpec = cache.getType().id; - difficulty = cache.getDifficulty(); - terrain = cache.getTerrain(); - size = cache.getSize(); - cacheType = cache.getType(); - } - - public cgCoord(cgWaypoint waypoint) { - id = waypoint.getId(); - disabled = false; - found = false; - geocode = waypoint.getGeocode(); - coords = waypoint.getCoords(); - name = waypoint.getName(); - coordType = "waypoint"; - typeSpec = waypoint.getWaypointType() != null ? waypoint.getWaypointType().id : null; - waypointType = waypoint.getWaypointType(); - } - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - @Override - public String getGeocode() { - return geocode; - } - - public void setGeocode(String geocode) { - this.geocode = geocode; - } - - public String getCoordType() { - return coordType; - } - - public void setCoordType(String type) { - this.coordType = type; - } - - public String getTypeSpec() { - return typeSpec; - } - - public void setTypeSpec(String typeSpec) { - this.typeSpec = typeSpec; - } - - @Override - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public boolean isFound() { - return found; - } - - public void setFound(boolean found) { - this.found = found; - } - - @Override - public boolean isDisabled() { - return disabled; - } - - public void setDisabled(boolean disabled) { - this.disabled = disabled; - } - - public Geopoint getCoords() { - return coords; - } - - public void setCoords(Geopoint coords) { - this.coords = coords; - } - - @Override - public float getDifficulty() { - return difficulty; - } - - public void setDifficulty(float difficulty) { - this.difficulty = difficulty; - } - - @Override - public float getTerrain() { - return terrain; - } - - public void setTerrain(float terrain) { - this.terrain = terrain; - } - - @Override - public CacheSize getSize() { - return size; - } - - public void setSize(CacheSize size) { - this.size = size; - } - - public void setGuid(String guid) { - this.guid = guid; - } - - @Override - public String getGuid() { - return guid; - } - - @Override - public WaypointType getWaypointType() { - return waypointType; - } - - @Override - public CacheType getType() { - return cacheType; - } -} diff --git a/main/src/cgeo/geocaching/cgWaypoint.java b/main/src/cgeo/geocaching/cgWaypoint.java index b13c141..d70e5ae 100644 --- a/main/src/cgeo/geocaching/cgWaypoint.java +++ b/main/src/cgeo/geocaching/cgWaypoint.java @@ -244,4 +244,9 @@ public class cgWaypoint implements IWaypoint, Comparable<cgWaypoint> { public boolean isFinalWithCoords() { return WaypointType.FINAL == waypointType && null != coords; } + + @Override + public String getCoordType() { + return "waypoint"; + } }
\ No newline at end of file diff --git a/main/src/cgeo/geocaching/cgeonavigate.java b/main/src/cgeo/geocaching/cgeonavigate.java index 57e6294..f5da2a1 100644 --- a/main/src/cgeo/geocaching/cgeonavigate.java +++ b/main/src/cgeo/geocaching/cgeonavigate.java @@ -30,7 +30,7 @@ public class cgeonavigate extends AbstractActivity { private static final String EXTRAS_LATITUDE = "latitude"; private static final String EXTRAS_NAME = "name"; private static final String EXTRAS_GEOCODE = "geocode"; - private static final List<cgCoord> coordinates = new ArrayList<cgCoord>(); + private static final List<IWaypoint> coordinates = new ArrayList<IWaypoint>(); private static final int MENU_MAP = 0; private static final int MENU_SWITCH_COMPASS_GPS = 1; private PowerManager pm = null; @@ -210,7 +210,7 @@ public class cgeonavigate extends AbstractActivity { SubMenu subMenu = menu.addSubMenu(0, 3, 0, res.getString(R.string.destination_select)).setIcon(android.R.drawable.ic_menu_myplaces); int cnt = 4; - for (cgCoord coordinate : coordinates) { + for (IWaypoint coordinate : coordinates) { subMenu.add(0, cnt, 0, coordinate.getName() + " (" + coordinate.getCoordType() + ")"); cnt++; } @@ -263,7 +263,7 @@ public class cgeonavigate extends AbstractActivity { finish(); return true; } else if (id > 3 && coordinates.get(id - 4) != null) { - cgCoord coordinate = coordinates.get(id - 4); + final IWaypoint coordinate = coordinates.get(id - 4); title = coordinate.getName(); dstCoords = coordinate.getCoords(); @@ -403,7 +403,7 @@ public class cgeonavigate extends AbstractActivity { } } - public static void startActivity(final Context context, final String geocode, final String displayedName, final Geopoint coords, final Collection<cgCoord> coordinatesWithType) { + public static void startActivity(final Context context, final String geocode, final String displayedName, final Geopoint coords, final Collection<IWaypoint> coordinatesWithType) { coordinates.clear(); if (coordinatesWithType != null) { // avoid possible NPE coordinates.addAll(coordinatesWithType); diff --git a/main/src/cgeo/geocaching/files/LocParser.java b/main/src/cgeo/geocaching/files/LocParser.java index 52fe955..3be8da4 100644 --- a/main/src/cgeo/geocaching/files/LocParser.java +++ b/main/src/cgeo/geocaching/files/LocParser.java @@ -3,7 +3,6 @@ package cgeo.geocaching.files; import cgeo.geocaching.SearchResult; import cgeo.geocaching.Settings; import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgCoord; import cgeo.geocaching.cgeoapplication; import cgeo.geocaching.enumerations.CacheSize; import cgeo.geocaching.enumerations.CacheType; @@ -15,7 +14,6 @@ import cgeo.geocaching.utils.Log; import org.apache.commons.lang3.StringUtils; - import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; @@ -30,6 +28,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; public final class LocParser extends FileParser { + private static final Pattern patternGeocode = Pattern .compile("name id=\"([^\"]+)\""); private static final Pattern patternLat = Pattern @@ -45,10 +44,21 @@ public final class LocParser extends FileParser { .compile("<container>([^<]+)</container>"); private static final Pattern patternName = Pattern.compile("CDATA\\[([^\\]]+)\\]"); + private static final CacheSize[] SIZES = { + CacheSize.NOT_CHOSEN, // 1 + CacheSize.MICRO, // 2 + CacheSize.REGULAR, // 3 + CacheSize.LARGE, // 4 + CacheSize.VIRTUAL, // 5 + CacheSize.OTHER, // 6 + CacheSize.UNKNOWN, // 7 + CacheSize.SMALL, // 8 + }; + private int listId; public static void parseLoc(final SearchResult searchResult, final String fileContent) { - final Map<String, cgCoord> cidCoords = parseCoordinates(fileContent); + final Map<String, cgCache> cidCoords = parseCoordinates(fileContent); // save found cache coordinates final HashSet<String> contained = new HashSet<String>(); @@ -59,12 +69,12 @@ public final class LocParser extends FileParser { } Set<cgCache> caches = cgeoapplication.getInstance().loadCaches(contained, LoadFlags.LOAD_CACHE_OR_DB); for (cgCache cache : caches) { - cgCoord coord = cidCoords.get(cache.getGeocode()); + cgCache coord = cidCoords.get(cache.getGeocode()); copyCoordToCache(coord, cache); } } - private static void copyCoordToCache(final cgCoord coord, final cgCache cache) { + private static void copyCoordToCache(final cgCache coord, final cgCache cache) { cache.setCoords(coord.getCoords()); cache.setDifficulty(coord.getDifficulty()); cache.setTerrain(coord.getTerrain()); @@ -76,9 +86,8 @@ public final class LocParser extends FileParser { } } - static Map<String, cgCoord> parseCoordinates( - final String fileContent) { - final Map<String, cgCoord> coords = new HashMap<String, cgCoord>(); + static Map<String, cgCache> parseCoordinates(final String fileContent) { + final Map<String, cgCache> coords = new HashMap<String, cgCache>(); if (StringUtils.isBlank(fileContent)) { return coords; } @@ -88,57 +97,7 @@ public final class LocParser extends FileParser { // parse coordinates for (String pointString : points) { - final cgCoord pointCoord = new cgCoord(); - - final Matcher matcherGeocode = patternGeocode.matcher(pointString); - if (matcherGeocode.find()) { - String geocode = matcherGeocode.group(1).trim().toUpperCase(); - pointCoord.setName(geocode); - pointCoord.setGeocode(geocode); - } - final Matcher matcherName = patternName.matcher(pointString); - if (matcherName.find()) { - String name = matcherName.group(1).trim(); - pointCoord.setName(StringUtils.substringBeforeLast(name, " by ").trim()); - // owner = StringUtils.substringAfterLast(" by ").trim(); - } - final Matcher matcherLat = patternLat.matcher(pointString); - final Matcher matcherLon = patternLon.matcher(pointString); - if (matcherLat.find() && matcherLon.find()) { - pointCoord.setCoords(parsePoint(matcherLat.group(1).trim(), matcherLon.group(1).trim())); - } - final Matcher matcherDifficulty = patternDifficulty.matcher(pointString); - if (matcherDifficulty.find()) { - pointCoord.setDifficulty(Float.parseFloat(matcherDifficulty.group(1).trim())); - } - final Matcher matcherTerrain = patternTerrain.matcher(pointString); - if (matcherTerrain.find()) { - pointCoord.setTerrain(Float.parseFloat(matcherTerrain.group(1).trim())); - } - final Matcher matcherContainer = patternContainer.matcher(pointString); - if (matcherContainer.find()) { - final int size = Integer.parseInt(matcherContainer.group(1) - .trim()); - - if (size == 1) { - pointCoord.setSize(CacheSize.NOT_CHOSEN); - } else if (size == 2) { - pointCoord.setSize(CacheSize.MICRO); - } else if (size == 3) { - pointCoord.setSize(CacheSize.REGULAR); - } else if (size == 4) { - pointCoord.setSize(CacheSize.LARGE); - } else if (size == 5) { - pointCoord.setSize(CacheSize.VIRTUAL); - } else if (size == 6) { - pointCoord.setSize(CacheSize.OTHER); - } else if (size == 8) { - pointCoord.setSize(CacheSize.SMALL); - } else { - pointCoord.setSize(CacheSize.UNKNOWN); - } - } - + final cgCache pointCoord = parseCache(pointString); if (StringUtils.isNotBlank(pointCoord.getGeocode())) { coords.put(pointCoord.getGeocode(), pointCoord); } @@ -149,7 +108,7 @@ public final class LocParser extends FileParser { return coords; } - private static Geopoint parsePoint(String latitude, String longitude) { + public static Geopoint parsePoint(final String latitude, final String longitude) { // the loc file contains the coordinates as plain floating point values, therefore avoid using the GeopointParser try { return new Geopoint(Double.valueOf(latitude), Double.valueOf(longitude)); @@ -168,10 +127,10 @@ public final class LocParser extends FileParser { public Collection<cgCache> parse(InputStream stream, CancellableHandler progressHandler) throws IOException, ParserException { // TODO: progress reporting happens during reading stream only, not during parsing String streamContent = readStream(stream, progressHandler).toString(); - final Map<String, cgCoord> coords = parseCoordinates(streamContent); + final Map<String, cgCache> coords = parseCoordinates(streamContent); final List<cgCache> caches = new ArrayList<cgCache>(); - for (Entry<String, cgCoord> entry : coords.entrySet()) { - cgCoord coord = entry.getValue(); + for (Entry<String, cgCache> entry : coords.entrySet()) { + cgCache coord = entry.getValue(); if (StringUtils.isBlank(coord.getGeocode()) || StringUtils.isBlank(coord.getName())) { continue; } @@ -188,4 +147,47 @@ public final class LocParser extends FileParser { Log.i(Settings.tag, "Caches found in .loc file: " + caches.size()); return caches; } + + public static cgCache parseCache(final String pointString) { + final cgCache cache = new cgCache(); + final Matcher matcherGeocode = patternGeocode.matcher(pointString); + if (matcherGeocode.find()) { + final String geocode = matcherGeocode.group(1).trim().toUpperCase(); + cache.setGeocode(geocode.toUpperCase()); + } + + final Matcher matcherName = patternName.matcher(pointString); + if (matcherName.find()) { + final String name = matcherName.group(1).trim(); + cache.setName(StringUtils.substringBeforeLast(name, " by ").trim()); + } else { + cache.setName(cache.getGeocode()); + } + + final Matcher matcherLat = patternLat.matcher(pointString); + final Matcher matcherLon = patternLon.matcher(pointString); + if (matcherLat.find() && matcherLon.find()) { + cache.setCoords(parsePoint(matcherLat.group(1).trim(), matcherLon.group(1).trim())); + } + + final Matcher matcherDifficulty = patternDifficulty.matcher(pointString); + if (matcherDifficulty.find()) { + cache.setDifficulty(Float.parseFloat(matcherDifficulty.group(1).trim())); + } + + final Matcher matcherTerrain = patternTerrain.matcher(pointString); + if (matcherTerrain.find()) { + cache.setTerrain(Float.parseFloat(matcherTerrain.group(1).trim())); + } + + final Matcher matcherContainer = patternContainer.matcher(pointString); + if (matcherContainer.find()) { + final int size = Integer.parseInt(matcherContainer.group(1).trim()); + if (size >= 1 && size <= 8) { + cache.setSize(SIZES[size - 1]); + } + } + + return cache; + } } diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java index 982ea39..12021db 100644 --- a/main/src/cgeo/geocaching/maps/CGeoMap.java +++ b/main/src/cgeo/geocaching/maps/CGeoMap.java @@ -1,5 +1,6 @@ package cgeo.geocaching.maps; +import cgeo.geocaching.IWaypoint; import cgeo.geocaching.R; import cgeo.geocaching.SearchResult; import cgeo.geocaching.Settings; @@ -8,7 +9,6 @@ import cgeo.geocaching.UpdateDirectionCallback; import cgeo.geocaching.UpdateLocationCallback; import cgeo.geocaching.cgBase; import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgCoord; import cgeo.geocaching.cgDirection; import cgeo.geocaching.cgGeo; import cgeo.geocaching.cgWaypoint; @@ -35,8 +35,8 @@ import cgeo.geocaching.maps.interfaces.MapViewImpl; import cgeo.geocaching.maps.interfaces.OnMapDragListener; import cgeo.geocaching.maps.interfaces.OtherCachersOverlayItemImpl; import cgeo.geocaching.network.Login; -import cgeo.geocaching.utils.CancellableHandler; import cgeo.geocaching.utils.BoundedList; +import cgeo.geocaching.utils.CancellableHandler; import cgeo.geocaching.utils.Log; import org.apache.commons.collections.CollectionUtils; @@ -1271,10 +1271,10 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto continue; } - itemsToDisplay.add(getItem(new cgCoord(waypoint), null, waypoint)); + itemsToDisplay.add(getItem(waypoint, null, waypoint)); } } - itemsToDisplay.add(getItem(new cgCoord(cache), cache, null)); + itemsToDisplay.add(getItem(cache, cache, null)); } overlayCaches.updateItems(itemsToDisplay); @@ -1379,14 +1379,10 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto } if (coordsIntent != null) { - final cgCoord coord = new cgCoord(); - coord.setCoordType("waypoint"); - coord.setCoords(coordsIntent); - coord.setName("some place"); - final cgWaypoint waypoint = new cgWaypoint("some place", waypointTypeIntent != null ? waypointTypeIntent : WaypointType.WAYPOINT, false); + waypoint.setCoords(coordsIntent); - final CachesOverlayItemImpl item = getItem(coord, null, waypoint); + final CachesOverlayItemImpl item = getItem(waypoint, null, waypoint); overlayCaches.updateItems(item); displayHandler.sendEmptyMessage(INVALIDATE_MAP); @@ -1706,7 +1702,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto * Waypoint. Mutally exclusive with cache * @return */ - private CachesOverlayItemImpl getItem(cgCoord coord, cgCache cache, cgWaypoint waypoint) { + private CachesOverlayItemImpl getItem(IWaypoint coord, cgCache cache, cgWaypoint waypoint) { if (cache != null) { CachesOverlayItemImpl item = mapProvider.getCachesOverlayItem(coord, cache.getType()); diff --git a/main/src/cgeo/geocaching/maps/CachesOverlay.java b/main/src/cgeo/geocaching/maps/CachesOverlay.java index fd17e8b..ddd6ec6 100644 --- a/main/src/cgeo/geocaching/maps/CachesOverlay.java +++ b/main/src/cgeo/geocaching/maps/CachesOverlay.java @@ -1,7 +1,7 @@ package cgeo.geocaching.maps; +import cgeo.geocaching.IWaypoint; import cgeo.geocaching.Settings; -import cgeo.geocaching.cgCoord; import cgeo.geocaching.cgeopopup; import cgeo.geocaching.cgeowaypoint; import cgeo.geocaching.enumerations.CacheType; @@ -130,7 +130,7 @@ public class CachesOverlay extends AbstractItemizedOverlay { canvas.setDrawFilter(setfil); for (CachesOverlayItemImpl item : items) { - final cgCoord itemCoord = item.getCoord(); + final IWaypoint itemCoord = item.getCoord(); float[] result = new float[1]; Location.distanceBetween(itemCoord.getCoords().getLatitude(), itemCoord.getCoords().getLongitude(), @@ -200,7 +200,7 @@ public class CachesOverlay extends AbstractItemizedOverlay { return false; } - cgCoord coordinate = item.getCoord(); + final IWaypoint coordinate = item.getCoord(); if (StringUtils.isNotBlank(coordinate.getCoordType()) && coordinate.getCoordType().equalsIgnoreCase("cache") && StringUtils.isNotBlank(coordinate.getGeocode())) { Intent popupIntent = new Intent(context, cgeopopup.class); diff --git a/main/src/cgeo/geocaching/maps/google/GoogleCacheOverlayItem.java b/main/src/cgeo/geocaching/maps/google/GoogleCacheOverlayItem.java index 5f41c54..27a1b56 100644 --- a/main/src/cgeo/geocaching/maps/google/GoogleCacheOverlayItem.java +++ b/main/src/cgeo/geocaching/maps/google/GoogleCacheOverlayItem.java @@ -1,6 +1,6 @@ package cgeo.geocaching.maps.google; -import cgeo.geocaching.cgCoord; +import cgeo.geocaching.IWaypoint; import cgeo.geocaching.enumerations.CacheType; import cgeo.geocaching.maps.interfaces.CachesOverlayItemImpl; @@ -9,16 +9,16 @@ import com.google.android.maps.OverlayItem; public class GoogleCacheOverlayItem extends OverlayItem implements CachesOverlayItemImpl { final private CacheType cacheType; - final private cgCoord coord; + final private IWaypoint coord; - public GoogleCacheOverlayItem(final cgCoord coordinate, final CacheType type) { + public GoogleCacheOverlayItem(final IWaypoint coordinate, final CacheType type) { super(new GeoPoint(coordinate.getCoords().getLatitudeE6(), coordinate.getCoords().getLongitudeE6()), coordinate.getName(), ""); this.cacheType = type; this.coord = coordinate; } - public cgCoord getCoord() { + public IWaypoint getCoord() { return coord; } diff --git a/main/src/cgeo/geocaching/maps/google/GoogleMapProvider.java b/main/src/cgeo/geocaching/maps/google/GoogleMapProvider.java index 7191428..6dfaf42 100644 --- a/main/src/cgeo/geocaching/maps/google/GoogleMapProvider.java +++ b/main/src/cgeo/geocaching/maps/google/GoogleMapProvider.java @@ -1,7 +1,7 @@ package cgeo.geocaching.maps.google; +import cgeo.geocaching.IWaypoint; import cgeo.geocaching.R; -import cgeo.geocaching.cgCoord; import cgeo.geocaching.cgeoapplication; import cgeo.geocaching.enumerations.CacheType; import cgeo.geocaching.geopoint.Geopoint; @@ -81,7 +81,7 @@ public class GoogleMapProvider implements MapProvider { } @Override - public CachesOverlayItemImpl getCachesOverlayItem(final cgCoord coordinate, final CacheType type) { + public CachesOverlayItemImpl getCachesOverlayItem(final IWaypoint coordinate, final CacheType type) { GoogleCacheOverlayItem baseItem = new GoogleCacheOverlayItem(coordinate, type); return baseItem; } diff --git a/main/src/cgeo/geocaching/maps/interfaces/CachesOverlayItemImpl.java b/main/src/cgeo/geocaching/maps/interfaces/CachesOverlayItemImpl.java index e2bf552..1afc120 100644 --- a/main/src/cgeo/geocaching/maps/interfaces/CachesOverlayItemImpl.java +++ b/main/src/cgeo/geocaching/maps/interfaces/CachesOverlayItemImpl.java @@ -1,6 +1,6 @@ package cgeo.geocaching.maps.interfaces; -import cgeo.geocaching.cgCoord; +import cgeo.geocaching.IWaypoint; import cgeo.geocaching.enumerations.CacheType; /** @@ -12,7 +12,7 @@ import cgeo.geocaching.enumerations.CacheType; */ public interface CachesOverlayItemImpl extends OverlayItemImpl { - public cgCoord getCoord(); + public IWaypoint getCoord(); public CacheType getType(); diff --git a/main/src/cgeo/geocaching/maps/interfaces/MapProvider.java b/main/src/cgeo/geocaching/maps/interfaces/MapProvider.java index c2c46ac..dd935c4 100644 --- a/main/src/cgeo/geocaching/maps/interfaces/MapProvider.java +++ b/main/src/cgeo/geocaching/maps/interfaces/MapProvider.java @@ -1,6 +1,6 @@ package cgeo.geocaching.maps.interfaces; -import cgeo.geocaching.cgCoord; +import cgeo.geocaching.IWaypoint; import cgeo.geocaching.enumerations.CacheType; import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.go4cache.Go4CacheUser; @@ -31,7 +31,7 @@ public interface MapProvider { public GeoPointImpl getGeoPointBase(final Geopoint coords); - public CachesOverlayItemImpl getCachesOverlayItem(final cgCoord coordinate, final CacheType type); + public CachesOverlayItemImpl getCachesOverlayItem(final IWaypoint iWaypoint, final CacheType type); public OtherCachersOverlayItemImpl getOtherCachersOverlayItemBase(Context context, Go4CacheUser userOne); diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeCacheOverlayItem.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeCacheOverlayItem.java index ccc0e78..f2ffae7 100644 --- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeCacheOverlayItem.java +++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeCacheOverlayItem.java @@ -1,6 +1,6 @@ package cgeo.geocaching.maps.mapsforge; -import cgeo.geocaching.cgCoord; +import cgeo.geocaching.IWaypoint; import cgeo.geocaching.enumerations.CacheType; import cgeo.geocaching.maps.interfaces.CachesOverlayItemImpl; @@ -11,16 +11,16 @@ import android.graphics.drawable.Drawable; public class MapsforgeCacheOverlayItem extends OverlayItem implements CachesOverlayItemImpl { final private CacheType cacheType; - final private cgCoord coord; + final private IWaypoint coord; - public MapsforgeCacheOverlayItem(cgCoord coordinate, final CacheType type) { + public MapsforgeCacheOverlayItem(IWaypoint coordinate, final CacheType type) { super(new GeoPoint(coordinate.getCoords().getLatitudeE6(), coordinate.getCoords().getLongitudeE6()), coordinate.getName(), ""); this.cacheType = type; this.coord = coordinate; } - public cgCoord getCoord() { + public IWaypoint getCoord() { return coord; } diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapProvider.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapProvider.java index 19c1335..1929b7b 100644 --- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapProvider.java +++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapProvider.java @@ -1,7 +1,7 @@ package cgeo.geocaching.maps.mapsforge; +import cgeo.geocaching.IWaypoint; import cgeo.geocaching.R; -import cgeo.geocaching.cgCoord; import cgeo.geocaching.cgeoapplication; import cgeo.geocaching.enumerations.CacheType; import cgeo.geocaching.geopoint.Geopoint; @@ -80,7 +80,7 @@ public class MapsforgeMapProvider implements MapProvider { } @Override - public CachesOverlayItemImpl getCachesOverlayItem(final cgCoord coordinate, final CacheType type) { + public CachesOverlayItemImpl getCachesOverlayItem(final IWaypoint coordinate, final CacheType type) { MapsforgeCacheOverlayItem baseItem = new MapsforgeCacheOverlayItem(coordinate, type); return baseItem; } |