From 7c95d28947a9ed8f003bfaef147f2fb72dc4b6ab Mon Sep 17 00:00:00 2001 From: Bananeweizen Date: Sun, 2 Nov 2014 11:07:28 +0100 Subject: rename package The package not only contains the GeoPoint definition, but other location related classes, too. --- main/src/cgeo/calendar/CalendarAddon.java | 2 +- .../cgeo/geocaching/AbstractDialogFragment.java | 4 +- main/src/cgeo/geocaching/CacheCache.java | 2 +- main/src/cgeo/geocaching/CacheDetailActivity.java | 2 +- main/src/cgeo/geocaching/CacheListActivity.java | 2 +- main/src/cgeo/geocaching/CachePopupFragment.java | 2 +- main/src/cgeo/geocaching/CompassActivity.java | 4 +- main/src/cgeo/geocaching/DataStore.java | 4 +- main/src/cgeo/geocaching/Destination.java | 2 +- main/src/cgeo/geocaching/EditWaypointActivity.java | 6 +- main/src/cgeo/geocaching/Geocache.java | 2 +- main/src/cgeo/geocaching/ICoordinates.java | 2 +- main/src/cgeo/geocaching/MainActivity.java | 4 +- .../cgeo/geocaching/NavigateAnyPointActivity.java | 6 +- main/src/cgeo/geocaching/SearchActivity.java | 4 +- main/src/cgeo/geocaching/StaticMapsProvider.java | 2 +- main/src/cgeo/geocaching/TrackableActivity.java | 2 +- main/src/cgeo/geocaching/Waypoint.java | 2 +- .../src/cgeo/geocaching/WaypointPopupFragment.java | 4 +- .../cache/navi/AbstractPointNavigationApp.java | 2 +- .../apps/cache/navi/AbstractRadarApp.java | 2 +- .../geocaching/apps/cache/navi/AndroidWearApp.java | 2 +- .../geocaching/apps/cache/navi/CompassApp.java | 2 +- .../apps/cache/navi/GeopointNavigationApp.java | 2 +- .../geocaching/apps/cache/navi/GoogleMapsApp.java | 6 +- .../apps/cache/navi/GoogleMapsDirectionApp.java | 2 +- .../apps/cache/navi/GoogleNavigationApp.java | 2 +- .../geocaching/apps/cache/navi/InternalMap.java | 2 +- .../geocaching/apps/cache/navi/MapsWithMeApp.java | 2 +- .../apps/cache/navi/NavigationAppFactory.java | 2 +- .../geocaching/apps/cache/navi/NavigonApp.java | 2 +- .../geocaching/apps/cache/navi/OruxMapsApp.java | 2 +- .../cgeo/geocaching/apps/cache/navi/PebbleApp.java | 2 +- .../cgeo/geocaching/apps/cache/navi/RMapsApp.java | 4 +- .../cgeo/geocaching/apps/cache/navi/RadarApp.java | 2 +- .../geocaching/apps/cache/navi/StreetviewApp.java | 2 +- .../apps/cache/navi/SygicNavigationApp.java | 2 +- .../geocaching/connector/AbstractConnector.java | 3 +- .../geocaching/connector/ConnectorFactory.java | 2 +- main/src/cgeo/geocaching/connector/IConnector.java | 2 +- .../connector/capability/ISearchByCenter.java | 2 +- .../connector/capability/ISearchByViewPort.java | 2 +- main/src/cgeo/geocaching/connector/ec/ECApi.java | 4 +- .../cgeo/geocaching/connector/ec/ECConnector.java | 4 +- .../cgeo/geocaching/connector/gc/GCConnector.java | 4 +- main/src/cgeo/geocaching/connector/gc/GCMap.java | 8 +- .../src/cgeo/geocaching/connector/gc/GCParser.java | 4 +- main/src/cgeo/geocaching/connector/gc/Tile.java | 4 +- .../connector/oc/OCApiLiveConnector.java | 4 +- .../cgeo/geocaching/connector/oc/OkapiClient.java | 6 +- .../cgeo/geocaching/connector/ox/OXConnector.java | 4 +- .../geocaching/connector/ox/OpenCachingApi.java | 6 +- main/src/cgeo/geocaching/export/GpxSerializer.java | 2 +- main/src/cgeo/geocaching/files/GPXParser.java | 2 +- main/src/cgeo/geocaching/files/LocParser.java | 2 +- .../src/cgeo/geocaching/filter/DistanceFilter.java | 2 +- .../cgeo/geocaching/geopoint/DistanceParser.java | 51 -- main/src/cgeo/geocaching/geopoint/Geopoint.java | 601 --------------------- .../geocaching/geopoint/GeopointFormatter.java | 116 ---- .../cgeo/geocaching/geopoint/GeopointParser.java | 163 ------ main/src/cgeo/geocaching/geopoint/IConversion.java | 13 - main/src/cgeo/geocaching/geopoint/Units.java | 62 --- main/src/cgeo/geocaching/geopoint/Viewport.java | 192 ------- .../loaders/CoordsGeocacheListLoader.java | 3 +- .../loaders/HistoryGeocacheListLoader.java | 2 +- .../loaders/OfflineGeocacheListLoader.java | 2 +- .../cgeo/geocaching/location/DistanceParser.java | 51 ++ main/src/cgeo/geocaching/location/Geopoint.java | 601 +++++++++++++++++++++ .../geocaching/location/GeopointFormatter.java | 116 ++++ .../cgeo/geocaching/location/GeopointParser.java | 163 ++++++ main/src/cgeo/geocaching/location/IConversion.java | 13 + main/src/cgeo/geocaching/location/Units.java | 62 +++ main/src/cgeo/geocaching/location/Viewport.java | 192 +++++++ main/src/cgeo/geocaching/maps/CGeoMap.java | 4 +- main/src/cgeo/geocaching/maps/CachesOverlay.java | 2 +- main/src/cgeo/geocaching/maps/PositionDrawer.java | 2 +- main/src/cgeo/geocaching/maps/ScaleDrawer.java | 4 +- .../geocaching/maps/google/v1/GoogleGeoPoint.java | 2 +- .../maps/google/v1/GoogleMapItemFactory.java | 2 +- .../geocaching/maps/google/v1/GoogleMapView.java | 2 +- .../geocaching/maps/interfaces/MapItemFactory.java | 2 +- .../geocaching/maps/interfaces/MapViewImpl.java | 2 +- .../maps/mapsforge/MapsforgeGeoPoint.java | 2 +- .../maps/mapsforge/MapsforgeMapItemFactory.java | 2 +- .../maps/mapsforge/MapsforgeMapView.java | 2 +- .../maps/mapsforge/v024/MapsforgeGeoPoint.java | 2 +- .../mapsforge/v024/MapsforgeMapItemFactory024.java | 2 +- .../maps/mapsforge/v024/MapsforgeMapView024.java | 2 +- main/src/cgeo/geocaching/sensors/GeoData.java | 2 +- main/src/cgeo/geocaching/sensors/IGeoData.java | 2 +- main/src/cgeo/geocaching/settings/Settings.java | 2 +- .../geocaching/sorting/DistanceComparator.java | 2 +- main/src/cgeo/geocaching/speech/SpeechService.java | 2 +- main/src/cgeo/geocaching/speech/TextFactory.java | 4 +- main/src/cgeo/geocaching/twitter/Twitter.java | 4 +- .../src/cgeo/geocaching/ui/AddressListAdapter.java | 4 +- .../cgeo/geocaching/ui/CacheDetailsCreator.java | 2 +- main/src/cgeo/geocaching/ui/CacheListAdapter.java | 2 +- main/src/cgeo/geocaching/ui/CompassMiniView.java | 2 +- .../geocaching/ui/CoordinatesFormatSwitcher.java | 4 +- main/src/cgeo/geocaching/ui/DistanceView.java | 4 +- .../ui/dialog/CoordinatesInputDialog.java | 6 +- 102 files changed, 1324 insertions(+), 1322 deletions(-) delete mode 100644 main/src/cgeo/geocaching/geopoint/DistanceParser.java delete mode 100644 main/src/cgeo/geocaching/geopoint/Geopoint.java delete mode 100644 main/src/cgeo/geocaching/geopoint/GeopointFormatter.java delete mode 100644 main/src/cgeo/geocaching/geopoint/GeopointParser.java delete mode 100644 main/src/cgeo/geocaching/geopoint/IConversion.java delete mode 100644 main/src/cgeo/geocaching/geopoint/Units.java delete mode 100644 main/src/cgeo/geocaching/geopoint/Viewport.java create mode 100644 main/src/cgeo/geocaching/location/DistanceParser.java create mode 100644 main/src/cgeo/geocaching/location/Geopoint.java create mode 100644 main/src/cgeo/geocaching/location/GeopointFormatter.java create mode 100644 main/src/cgeo/geocaching/location/GeopointParser.java create mode 100644 main/src/cgeo/geocaching/location/IConversion.java create mode 100644 main/src/cgeo/geocaching/location/Units.java create mode 100644 main/src/cgeo/geocaching/location/Viewport.java (limited to 'main/src') diff --git a/main/src/cgeo/calendar/CalendarAddon.java b/main/src/cgeo/calendar/CalendarAddon.java index 4a672fa..8737447 100644 --- a/main/src/cgeo/calendar/CalendarAddon.java +++ b/main/src/cgeo/calendar/CalendarAddon.java @@ -2,7 +2,7 @@ package cgeo.calendar; import cgeo.geocaching.Geocache; import cgeo.geocaching.R; -import cgeo.geocaching.geopoint.GeopointFormatter; +import cgeo.geocaching.location.GeopointFormatter; import cgeo.geocaching.network.Parameters; import cgeo.geocaching.ui.dialog.Dialogs; import cgeo.geocaching.utils.ProcessUtils; diff --git a/main/src/cgeo/geocaching/AbstractDialogFragment.java b/main/src/cgeo/geocaching/AbstractDialogFragment.java index 343d97c..3deb701 100644 --- a/main/src/cgeo/geocaching/AbstractDialogFragment.java +++ b/main/src/cgeo/geocaching/AbstractDialogFragment.java @@ -7,8 +7,8 @@ import cgeo.geocaching.activity.ActivityMixin; import cgeo.geocaching.enumerations.LoadFlags; import cgeo.geocaching.gcvote.GCVote; import cgeo.geocaching.gcvote.GCVoteRating; -import cgeo.geocaching.geopoint.Geopoint; -import cgeo.geocaching.geopoint.Units; +import cgeo.geocaching.location.Geopoint; +import cgeo.geocaching.location.Units; import cgeo.geocaching.sensors.GeoDirHandler; import cgeo.geocaching.sensors.IGeoData; import cgeo.geocaching.settings.Settings; diff --git a/main/src/cgeo/geocaching/CacheCache.java b/main/src/cgeo/geocaching/CacheCache.java index 1913d3c..74e22b5 100644 --- a/main/src/cgeo/geocaching/CacheCache.java +++ b/main/src/cgeo/geocaching/CacheCache.java @@ -3,7 +3,7 @@ package cgeo.geocaching; import cgeo.geocaching.DataStore.StorageLocation; import cgeo.geocaching.connector.gc.Tile; import cgeo.geocaching.enumerations.CacheType; -import cgeo.geocaching.geopoint.Viewport; +import cgeo.geocaching.location.Viewport; import cgeo.geocaching.utils.LeastRecentlyUsedMap; import cgeo.geocaching.utils.LeastRecentlyUsedMap.RemoveHandler; import cgeo.geocaching.utils.Log; diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java index 7ca6525..16f5cef 100644 --- a/main/src/cgeo/geocaching/CacheDetailActivity.java +++ b/main/src/cgeo/geocaching/CacheDetailActivity.java @@ -21,8 +21,8 @@ import cgeo.geocaching.enumerations.CacheAttribute; import cgeo.geocaching.enumerations.LoadFlags; import cgeo.geocaching.enumerations.LoadFlags.SaveFlag; import cgeo.geocaching.enumerations.WaypointType; -import cgeo.geocaching.geopoint.Units; import cgeo.geocaching.list.StoredList; +import cgeo.geocaching.location.Units; import cgeo.geocaching.network.HtmlImage; import cgeo.geocaching.network.Network; import cgeo.geocaching.sensors.GeoDirHandler; diff --git a/main/src/cgeo/geocaching/CacheListActivity.java b/main/src/cgeo/geocaching/CacheListActivity.java index 7ef59dd..c501f89 100644 --- a/main/src/cgeo/geocaching/CacheListActivity.java +++ b/main/src/cgeo/geocaching/CacheListActivity.java @@ -21,7 +21,6 @@ import cgeo.geocaching.export.GpxExport; import cgeo.geocaching.files.GPXImporter; import cgeo.geocaching.filter.FilterUserInterface; import cgeo.geocaching.filter.IFilter; -import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.list.AbstractList; import cgeo.geocaching.list.ListNameMemento; import cgeo.geocaching.list.PseudoList; @@ -37,6 +36,7 @@ import cgeo.geocaching.loaders.NextPageGeocacheListLoader; import cgeo.geocaching.loaders.OfflineGeocacheListLoader; import cgeo.geocaching.loaders.OwnerGeocacheListLoader; import cgeo.geocaching.loaders.PocketGeocacheListLoader; +import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.maps.CGeoMap; import cgeo.geocaching.network.Cookies; import cgeo.geocaching.network.Network; diff --git a/main/src/cgeo/geocaching/CachePopupFragment.java b/main/src/cgeo/geocaching/CachePopupFragment.java index 4db74ef..068663f 100644 --- a/main/src/cgeo/geocaching/CachePopupFragment.java +++ b/main/src/cgeo/geocaching/CachePopupFragment.java @@ -2,8 +2,8 @@ package cgeo.geocaching; import cgeo.geocaching.activity.Progress; import cgeo.geocaching.apps.cache.navi.NavigationAppFactory; -import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.list.StoredList; +import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.network.Network; import cgeo.geocaching.settings.Settings; import cgeo.geocaching.ui.CacheDetailsCreator; diff --git a/main/src/cgeo/geocaching/CompassActivity.java b/main/src/cgeo/geocaching/CompassActivity.java index 4196ee2..6d45911 100644 --- a/main/src/cgeo/geocaching/CompassActivity.java +++ b/main/src/cgeo/geocaching/CompassActivity.java @@ -5,8 +5,8 @@ import butterknife.InjectView; import cgeo.geocaching.activity.AbstractActionBarActivity; import cgeo.geocaching.enumerations.LoadFlags; -import cgeo.geocaching.geopoint.Geopoint; -import cgeo.geocaching.geopoint.Units; +import cgeo.geocaching.location.Geopoint; +import cgeo.geocaching.location.Units; import cgeo.geocaching.maps.CGeoMap; import cgeo.geocaching.sensors.GeoDirHandler; import cgeo.geocaching.sensors.GpsStatusProvider.Status; diff --git a/main/src/cgeo/geocaching/DataStore.java b/main/src/cgeo/geocaching/DataStore.java index 1aba760..632e13e 100644 --- a/main/src/cgeo/geocaching/DataStore.java +++ b/main/src/cgeo/geocaching/DataStore.java @@ -11,11 +11,11 @@ import cgeo.geocaching.enumerations.LoadFlags.SaveFlag; import cgeo.geocaching.enumerations.LogType; import cgeo.geocaching.enumerations.WaypointType; import cgeo.geocaching.files.LocalStorage; -import cgeo.geocaching.geopoint.Geopoint; -import cgeo.geocaching.geopoint.Viewport; import cgeo.geocaching.list.AbstractList; import cgeo.geocaching.list.PseudoList; import cgeo.geocaching.list.StoredList; +import cgeo.geocaching.location.Geopoint; +import cgeo.geocaching.location.Viewport; import cgeo.geocaching.search.SearchSuggestionCursor; import cgeo.geocaching.settings.Settings; import cgeo.geocaching.ui.dialog.Dialogs; diff --git a/main/src/cgeo/geocaching/Destination.java b/main/src/cgeo/geocaching/Destination.java index 10d51be..1990d5d 100644 --- a/main/src/cgeo/geocaching/Destination.java +++ b/main/src/cgeo/geocaching/Destination.java @@ -1,6 +1,6 @@ package cgeo.geocaching; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; public final class Destination implements ICoordinates { diff --git a/main/src/cgeo/geocaching/EditWaypointActivity.java b/main/src/cgeo/geocaching/EditWaypointActivity.java index d3ee5d0..a091ff7 100644 --- a/main/src/cgeo/geocaching/EditWaypointActivity.java +++ b/main/src/cgeo/geocaching/EditWaypointActivity.java @@ -7,9 +7,9 @@ import cgeo.geocaching.enumerations.CacheType; import cgeo.geocaching.enumerations.LoadFlags; import cgeo.geocaching.enumerations.LoadFlags.SaveFlag; import cgeo.geocaching.enumerations.WaypointType; -import cgeo.geocaching.geopoint.DistanceParser; -import cgeo.geocaching.geopoint.Geopoint; -import cgeo.geocaching.geopoint.GeopointFormatter; +import cgeo.geocaching.location.DistanceParser; +import cgeo.geocaching.location.Geopoint; +import cgeo.geocaching.location.GeopointFormatter; import cgeo.geocaching.sensors.GeoDirHandler; import cgeo.geocaching.sensors.IGeoData; import cgeo.geocaching.settings.Settings; diff --git a/main/src/cgeo/geocaching/Geocache.java b/main/src/cgeo/geocaching/Geocache.java index 76c3b13..e4fba34 100644 --- a/main/src/cgeo/geocaching/Geocache.java +++ b/main/src/cgeo/geocaching/Geocache.java @@ -20,8 +20,8 @@ import cgeo.geocaching.enumerations.LoadFlags.SaveFlag; import cgeo.geocaching.enumerations.LogType; import cgeo.geocaching.enumerations.WaypointType; import cgeo.geocaching.files.GPXParser; -import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.list.StoredList; +import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.network.HtmlImage; import cgeo.geocaching.settings.Settings; import cgeo.geocaching.utils.CancellableHandler; diff --git a/main/src/cgeo/geocaching/ICoordinates.java b/main/src/cgeo/geocaching/ICoordinates.java index b70e4ac..8f78e00 100644 --- a/main/src/cgeo/geocaching/ICoordinates.java +++ b/main/src/cgeo/geocaching/ICoordinates.java @@ -1,6 +1,6 @@ package cgeo.geocaching; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; public interface ICoordinates { diff --git a/main/src/cgeo/geocaching/MainActivity.java b/main/src/cgeo/geocaching/MainActivity.java index 40504fb..d6f9c73 100644 --- a/main/src/cgeo/geocaching/MainActivity.java +++ b/main/src/cgeo/geocaching/MainActivity.java @@ -9,10 +9,10 @@ import cgeo.geocaching.connector.ConnectorFactory; import cgeo.geocaching.connector.capability.ILogin; import cgeo.geocaching.enumerations.CacheType; import cgeo.geocaching.enumerations.StatusCode; -import cgeo.geocaching.geopoint.Geopoint; -import cgeo.geocaching.geopoint.Units; import cgeo.geocaching.list.PseudoList; import cgeo.geocaching.list.StoredList; +import cgeo.geocaching.location.Geopoint; +import cgeo.geocaching.location.Units; import cgeo.geocaching.maps.CGeoMap; import cgeo.geocaching.sensors.GeoDirHandler; import cgeo.geocaching.sensors.GpsStatusProvider; diff --git a/main/src/cgeo/geocaching/NavigateAnyPointActivity.java b/main/src/cgeo/geocaching/NavigateAnyPointActivity.java index e9568ad..5093293 100644 --- a/main/src/cgeo/geocaching/NavigateAnyPointActivity.java +++ b/main/src/cgeo/geocaching/NavigateAnyPointActivity.java @@ -7,9 +7,9 @@ import butterknife.Optional; import cgeo.geocaching.activity.AbstractActionBarActivity; import cgeo.geocaching.activity.INavigationSource; import cgeo.geocaching.apps.cache.navi.NavigationAppFactory; -import cgeo.geocaching.geopoint.DistanceParser; -import cgeo.geocaching.geopoint.Geopoint; -import cgeo.geocaching.geopoint.GeopointFormatter; +import cgeo.geocaching.location.DistanceParser; +import cgeo.geocaching.location.Geopoint; +import cgeo.geocaching.location.GeopointFormatter; import cgeo.geocaching.sensors.GeoDirHandler; import cgeo.geocaching.sensors.IGeoData; import cgeo.geocaching.settings.Settings; diff --git a/main/src/cgeo/geocaching/SearchActivity.java b/main/src/cgeo/geocaching/SearchActivity.java index edd611a..4f21a63 100644 --- a/main/src/cgeo/geocaching/SearchActivity.java +++ b/main/src/cgeo/geocaching/SearchActivity.java @@ -9,8 +9,8 @@ import cgeo.geocaching.connector.ConnectorFactory; import cgeo.geocaching.connector.IConnector; import cgeo.geocaching.connector.capability.ISearchByGeocode; import cgeo.geocaching.connector.trackable.TrackableConnector; -import cgeo.geocaching.geopoint.Geopoint; -import cgeo.geocaching.geopoint.GeopointFormatter; +import cgeo.geocaching.location.Geopoint; +import cgeo.geocaching.location.GeopointFormatter; import cgeo.geocaching.search.AutoCompleteAdapter; import cgeo.geocaching.sensors.IGeoData; import cgeo.geocaching.settings.Settings; diff --git a/main/src/cgeo/geocaching/StaticMapsProvider.java b/main/src/cgeo/geocaching/StaticMapsProvider.java index 030c379..fc950c1 100644 --- a/main/src/cgeo/geocaching/StaticMapsProvider.java +++ b/main/src/cgeo/geocaching/StaticMapsProvider.java @@ -2,7 +2,7 @@ package cgeo.geocaching; import cgeo.geocaching.compatibility.Compatibility; import cgeo.geocaching.files.LocalStorage; -import cgeo.geocaching.geopoint.GeopointFormatter.Format; +import cgeo.geocaching.location.GeopointFormatter.Format; import cgeo.geocaching.network.Network; import cgeo.geocaching.network.Parameters; import cgeo.geocaching.settings.Settings; diff --git a/main/src/cgeo/geocaching/TrackableActivity.java b/main/src/cgeo/geocaching/TrackableActivity.java index 1f48165..3ec81fa 100644 --- a/main/src/cgeo/geocaching/TrackableActivity.java +++ b/main/src/cgeo/geocaching/TrackableActivity.java @@ -10,7 +10,7 @@ import cgeo.geocaching.connector.ConnectorFactory; import cgeo.geocaching.connector.trackable.TrackableConnector; import cgeo.geocaching.connector.trackable.TravelBugConnector; import cgeo.geocaching.enumerations.LogType; -import cgeo.geocaching.geopoint.Units; +import cgeo.geocaching.location.Units; import cgeo.geocaching.network.HtmlImage; import cgeo.geocaching.ui.AbstractCachingPageViewCreator; import cgeo.geocaching.ui.AnchorAwareLinkMovementMethod; diff --git a/main/src/cgeo/geocaching/Waypoint.java b/main/src/cgeo/geocaching/Waypoint.java index 43b24f3..5cfeb29 100644 --- a/main/src/cgeo/geocaching/Waypoint.java +++ b/main/src/cgeo/geocaching/Waypoint.java @@ -2,7 +2,7 @@ package cgeo.geocaching; import cgeo.geocaching.enumerations.LoadFlags; import cgeo.geocaching.enumerations.WaypointType; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.utils.MatcherWrapper; import org.apache.commons.lang3.StringUtils; diff --git a/main/src/cgeo/geocaching/WaypointPopupFragment.java b/main/src/cgeo/geocaching/WaypointPopupFragment.java index 03d95e5..00c7986 100644 --- a/main/src/cgeo/geocaching/WaypointPopupFragment.java +++ b/main/src/cgeo/geocaching/WaypointPopupFragment.java @@ -4,8 +4,8 @@ import butterknife.ButterKnife; import butterknife.InjectView; import cgeo.geocaching.apps.cache.navi.NavigationAppFactory; -import cgeo.geocaching.geopoint.Geopoint; -import cgeo.geocaching.geopoint.Units; +import cgeo.geocaching.location.Geopoint; +import cgeo.geocaching.location.Units; import cgeo.geocaching.sensors.IGeoData; import cgeo.geocaching.ui.CacheDetailsCreator; import cgeo.geocaching.utils.Log; diff --git a/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java b/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java index ec9705c..5e7a5cc 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/AbstractPointNavigationApp.java @@ -5,7 +5,7 @@ import cgeo.geocaching.R; import cgeo.geocaching.Waypoint; import cgeo.geocaching.activity.ActivityMixin; import cgeo.geocaching.apps.AbstractApp; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import android.app.Activity; import android.content.Intent; diff --git a/main/src/cgeo/geocaching/apps/cache/navi/AbstractRadarApp.java b/main/src/cgeo/geocaching/apps/cache/navi/AbstractRadarApp.java index f31d175..2394be0 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/AbstractRadarApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/AbstractRadarApp.java @@ -2,7 +2,7 @@ package cgeo.geocaching.apps.cache.navi; import cgeo.geocaching.Geocache; import cgeo.geocaching.Waypoint; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import android.app.Activity; import android.content.Intent; diff --git a/main/src/cgeo/geocaching/apps/cache/navi/AndroidWearApp.java b/main/src/cgeo/geocaching/apps/cache/navi/AndroidWearApp.java index f083a26..391462b 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/AndroidWearApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/AndroidWearApp.java @@ -4,7 +4,7 @@ import cgeo.geocaching.Geocache; import cgeo.geocaching.Intents; import cgeo.geocaching.R; import cgeo.geocaching.Waypoint; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.utils.ProcessUtils; import android.app.Activity; diff --git a/main/src/cgeo/geocaching/apps/cache/navi/CompassApp.java b/main/src/cgeo/geocaching/apps/cache/navi/CompassApp.java index c79dfad..8e1e4cf 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/CompassApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/CompassApp.java @@ -4,7 +4,7 @@ import cgeo.geocaching.CompassActivity; import cgeo.geocaching.Geocache; import cgeo.geocaching.R; import cgeo.geocaching.Waypoint; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import android.app.Activity; diff --git a/main/src/cgeo/geocaching/apps/cache/navi/GeopointNavigationApp.java b/main/src/cgeo/geocaching/apps/cache/navi/GeopointNavigationApp.java index fe4fd5d..194b229 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/GeopointNavigationApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/GeopointNavigationApp.java @@ -1,6 +1,6 @@ package cgeo.geocaching.apps.cache.navi; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import android.app.Activity; diff --git a/main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java b/main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java index b14ba35..80609ce 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java @@ -4,9 +4,9 @@ import cgeo.geocaching.Geocache; import cgeo.geocaching.R; import cgeo.geocaching.Waypoint; import cgeo.geocaching.activity.ActivityMixin; -import cgeo.geocaching.geopoint.Geopoint; -import cgeo.geocaching.geopoint.GeopointFormatter; -import cgeo.geocaching.geopoint.GeopointFormatter.Format; +import cgeo.geocaching.location.Geopoint; +import cgeo.geocaching.location.GeopointFormatter; +import cgeo.geocaching.location.GeopointFormatter.Format; import cgeo.geocaching.utils.Log; import android.app.Activity; diff --git a/main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsDirectionApp.java b/main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsDirectionApp.java index f5ccef4..3102101 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsDirectionApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsDirectionApp.java @@ -2,7 +2,7 @@ package cgeo.geocaching.apps.cache.navi; import cgeo.geocaching.CgeoApplication; import cgeo.geocaching.R; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.maps.MapProviderFactory; import cgeo.geocaching.sensors.IGeoData; import cgeo.geocaching.utils.Log; diff --git a/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java b/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java index 902eebf..1979fba 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java @@ -1,7 +1,7 @@ package cgeo.geocaching.apps.cache.navi; import cgeo.geocaching.R; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.utils.Log; import android.app.Activity; diff --git a/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java b/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java index 540b025..2355d9d 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java @@ -4,7 +4,7 @@ import cgeo.geocaching.Geocache; import cgeo.geocaching.R; import cgeo.geocaching.Waypoint; import cgeo.geocaching.enumerations.WaypointType; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.maps.CGeoMap; import android.app.Activity; diff --git a/main/src/cgeo/geocaching/apps/cache/navi/MapsWithMeApp.java b/main/src/cgeo/geocaching/apps/cache/navi/MapsWithMeApp.java index ea5aebb..f1a504f 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/MapsWithMeApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/MapsWithMeApp.java @@ -3,7 +3,7 @@ package cgeo.geocaching.apps.cache.navi; import cgeo.geocaching.Geocache; import cgeo.geocaching.R; import cgeo.geocaching.Waypoint; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import com.mapswithme.maps.api.MapsWithMeApi; diff --git a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java index efc988b..db68129 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java @@ -11,7 +11,7 @@ import cgeo.geocaching.apps.cache.WhereYouGoApp; import cgeo.geocaching.apps.cache.navi.GoogleNavigationApp.GoogleNavigationBikeApp; import cgeo.geocaching.apps.cache.navi.GoogleNavigationApp.GoogleNavigationDrivingApp; import cgeo.geocaching.apps.cache.navi.GoogleNavigationApp.GoogleNavigationWalkingApp; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.settings.Settings; import org.eclipse.jdt.annotation.Nullable; diff --git a/main/src/cgeo/geocaching/apps/cache/navi/NavigonApp.java b/main/src/cgeo/geocaching/apps/cache/navi/NavigonApp.java index 024bf37..9f64070 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/NavigonApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/NavigonApp.java @@ -1,7 +1,7 @@ package cgeo.geocaching.apps.cache.navi; import cgeo.geocaching.R; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import android.app.Activity; import android.content.Intent; diff --git a/main/src/cgeo/geocaching/apps/cache/navi/OruxMapsApp.java b/main/src/cgeo/geocaching/apps/cache/navi/OruxMapsApp.java index 4dbfadd..f710333 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/OruxMapsApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/OruxMapsApp.java @@ -1,7 +1,7 @@ package cgeo.geocaching.apps.cache.navi; import cgeo.geocaching.R; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import android.app.Activity; import android.content.Intent; diff --git a/main/src/cgeo/geocaching/apps/cache/navi/PebbleApp.java b/main/src/cgeo/geocaching/apps/cache/navi/PebbleApp.java index a12a38e..f384192 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/PebbleApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/PebbleApp.java @@ -1,7 +1,7 @@ package cgeo.geocaching.apps.cache.navi; import cgeo.geocaching.R; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import android.content.Intent; diff --git a/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java b/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java index 4dbb46c..b78caab 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java @@ -3,8 +3,8 @@ package cgeo.geocaching.apps.cache.navi; import cgeo.geocaching.Geocache; import cgeo.geocaching.R; import cgeo.geocaching.Waypoint; -import cgeo.geocaching.geopoint.Geopoint; -import cgeo.geocaching.geopoint.GeopointFormatter.Format; +import cgeo.geocaching.location.Geopoint; +import cgeo.geocaching.location.GeopointFormatter.Format; import android.app.Activity; import android.content.Intent; diff --git a/main/src/cgeo/geocaching/apps/cache/navi/RadarApp.java b/main/src/cgeo/geocaching/apps/cache/navi/RadarApp.java index 0ee512b..a26edc4 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/RadarApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/RadarApp.java @@ -1,7 +1,7 @@ package cgeo.geocaching.apps.cache.navi; import cgeo.geocaching.R; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import android.content.Intent; diff --git a/main/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java b/main/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java index 4c797a1..584cca9 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java @@ -3,7 +3,7 @@ package cgeo.geocaching.apps.cache.navi; import cgeo.geocaching.CgeoApplication; import cgeo.geocaching.R; import cgeo.geocaching.activity.ActivityMixin; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.utils.ProcessUtils; import android.app.Activity; diff --git a/main/src/cgeo/geocaching/apps/cache/navi/SygicNavigationApp.java b/main/src/cgeo/geocaching/apps/cache/navi/SygicNavigationApp.java index 76b7f0e..00a09e3 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/SygicNavigationApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/SygicNavigationApp.java @@ -1,7 +1,7 @@ package cgeo.geocaching.apps.cache.navi; import cgeo.geocaching.R; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import android.app.Activity; import android.content.Intent; diff --git a/main/src/cgeo/geocaching/connector/AbstractConnector.java b/main/src/cgeo/geocaching/connector/AbstractConnector.java index a5d0407..834167a 100644 --- a/main/src/cgeo/geocaching/connector/AbstractConnector.java +++ b/main/src/cgeo/geocaching/connector/AbstractConnector.java @@ -15,10 +15,11 @@ import cgeo.geocaching.connector.capability.ISearchByOwner; import cgeo.geocaching.connector.capability.ISearchByViewPort; import cgeo.geocaching.enumerations.CacheType; import cgeo.geocaching.enumerations.LogType; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import org.apache.commons.lang3.StringUtils; import org.eclipse.jdt.annotation.NonNull; + import rx.functions.Action1; import java.util.ArrayList; diff --git a/main/src/cgeo/geocaching/connector/ConnectorFactory.java b/main/src/cgeo/geocaching/connector/ConnectorFactory.java index e6ef829..6bbfae0 100644 --- a/main/src/cgeo/geocaching/connector/ConnectorFactory.java +++ b/main/src/cgeo/geocaching/connector/ConnectorFactory.java @@ -21,7 +21,7 @@ import cgeo.geocaching.connector.trackable.GeokretyConnector; import cgeo.geocaching.connector.trackable.TrackableConnector; import cgeo.geocaching.connector.trackable.TravelBugConnector; import cgeo.geocaching.connector.trackable.UnknownTrackableConnector; -import cgeo.geocaching.geopoint.Viewport; +import cgeo.geocaching.location.Viewport; import org.apache.commons.lang3.StringUtils; import org.eclipse.jdt.annotation.NonNull; diff --git a/main/src/cgeo/geocaching/connector/IConnector.java b/main/src/cgeo/geocaching/connector/IConnector.java index e6b6674..c235df4 100644 --- a/main/src/cgeo/geocaching/connector/IConnector.java +++ b/main/src/cgeo/geocaching/connector/IConnector.java @@ -4,7 +4,7 @@ import cgeo.geocaching.Geocache; import cgeo.geocaching.ICache; import cgeo.geocaching.LogCacheActivity; import cgeo.geocaching.enumerations.LogType; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import org.eclipse.jdt.annotation.NonNull; diff --git a/main/src/cgeo/geocaching/connector/capability/ISearchByCenter.java b/main/src/cgeo/geocaching/connector/capability/ISearchByCenter.java index adc36c7..576220d 100644 --- a/main/src/cgeo/geocaching/connector/capability/ISearchByCenter.java +++ b/main/src/cgeo/geocaching/connector/capability/ISearchByCenter.java @@ -2,8 +2,8 @@ package cgeo.geocaching.connector.capability; import cgeo.geocaching.SearchResult; import cgeo.geocaching.connector.IConnector; -import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.loaders.RecaptchaReceiver; +import cgeo.geocaching.location.Geopoint; import org.eclipse.jdt.annotation.NonNull; diff --git a/main/src/cgeo/geocaching/connector/capability/ISearchByViewPort.java b/main/src/cgeo/geocaching/connector/capability/ISearchByViewPort.java index 7981ba8..ef81c4c 100644 --- a/main/src/cgeo/geocaching/connector/capability/ISearchByViewPort.java +++ b/main/src/cgeo/geocaching/connector/capability/ISearchByViewPort.java @@ -3,7 +3,7 @@ package cgeo.geocaching.connector.capability; import cgeo.geocaching.SearchResult; import cgeo.geocaching.connector.IConnector; import cgeo.geocaching.connector.gc.MapTokens; -import cgeo.geocaching.geopoint.Viewport; +import cgeo.geocaching.location.Viewport; import org.eclipse.jdt.annotation.NonNull; diff --git a/main/src/cgeo/geocaching/connector/ec/ECApi.java b/main/src/cgeo/geocaching/connector/ec/ECApi.java index 3e7472e..64177af 100644 --- a/main/src/cgeo/geocaching/connector/ec/ECApi.java +++ b/main/src/cgeo/geocaching/connector/ec/ECApi.java @@ -9,9 +9,9 @@ import cgeo.geocaching.enumerations.LoadFlags.SaveFlag; import cgeo.geocaching.enumerations.LogType; import cgeo.geocaching.enumerations.StatusCode; import cgeo.geocaching.files.GPX10Parser; -import cgeo.geocaching.geopoint.Geopoint; -import cgeo.geocaching.geopoint.Viewport; import cgeo.geocaching.list.StoredList; +import cgeo.geocaching.location.Geopoint; +import cgeo.geocaching.location.Viewport; import cgeo.geocaching.network.Network; import cgeo.geocaching.network.Parameters; import cgeo.geocaching.utils.JsonUtils; diff --git a/main/src/cgeo/geocaching/connector/ec/ECConnector.java b/main/src/cgeo/geocaching/connector/ec/ECConnector.java index a266eee..27b5b54 100644 --- a/main/src/cgeo/geocaching/connector/ec/ECConnector.java +++ b/main/src/cgeo/geocaching/connector/ec/ECConnector.java @@ -16,9 +16,9 @@ import cgeo.geocaching.connector.capability.ISearchByViewPort; import cgeo.geocaching.connector.gc.MapTokens; import cgeo.geocaching.enumerations.LogType; import cgeo.geocaching.enumerations.StatusCode; -import cgeo.geocaching.geopoint.Geopoint; -import cgeo.geocaching.geopoint.Viewport; import cgeo.geocaching.loaders.RecaptchaReceiver; +import cgeo.geocaching.location.Geopoint; +import cgeo.geocaching.location.Viewport; import cgeo.geocaching.settings.Settings; import cgeo.geocaching.settings.SettingsActivity; import cgeo.geocaching.utils.CancellableHandler; diff --git a/main/src/cgeo/geocaching/connector/gc/GCConnector.java b/main/src/cgeo/geocaching/connector/gc/GCConnector.java index 6a96d04..8b714c7 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCConnector.java +++ b/main/src/cgeo/geocaching/connector/gc/GCConnector.java @@ -21,9 +21,9 @@ import cgeo.geocaching.connector.capability.ISearchByKeyword; import cgeo.geocaching.connector.capability.ISearchByOwner; import cgeo.geocaching.connector.capability.ISearchByViewPort; import cgeo.geocaching.enumerations.StatusCode; -import cgeo.geocaching.geopoint.Geopoint; -import cgeo.geocaching.geopoint.Viewport; import cgeo.geocaching.loaders.RecaptchaReceiver; +import cgeo.geocaching.location.Geopoint; +import cgeo.geocaching.location.Viewport; import cgeo.geocaching.network.Network; import cgeo.geocaching.network.Parameters; import cgeo.geocaching.settings.Settings; diff --git a/main/src/cgeo/geocaching/connector/gc/GCMap.java b/main/src/cgeo/geocaching/connector/gc/GCMap.java index 63c42ff..ccb2f0c 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCMap.java +++ b/main/src/cgeo/geocaching/connector/gc/GCMap.java @@ -10,10 +10,10 @@ import cgeo.geocaching.enumerations.LiveMapStrategy.Strategy; import cgeo.geocaching.enumerations.LiveMapStrategy.StrategyFlag; import cgeo.geocaching.enumerations.StatusCode; import cgeo.geocaching.files.ParserException; -import cgeo.geocaching.geopoint.Geopoint; -import cgeo.geocaching.geopoint.GeopointFormatter.Format; -import cgeo.geocaching.geopoint.Units; -import cgeo.geocaching.geopoint.Viewport; +import cgeo.geocaching.location.Geopoint; +import cgeo.geocaching.location.Units; +import cgeo.geocaching.location.Viewport; +import cgeo.geocaching.location.GeopointFormatter.Format; import cgeo.geocaching.network.Parameters; import cgeo.geocaching.settings.Settings; import cgeo.geocaching.utils.Formatter; diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java index c33fedd..b0f8b8e 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCParser.java +++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java @@ -22,9 +22,9 @@ import cgeo.geocaching.enumerations.WaypointType; import cgeo.geocaching.files.LocParser; import cgeo.geocaching.gcvote.GCVote; import cgeo.geocaching.gcvote.GCVoteRating; -import cgeo.geocaching.geopoint.DistanceParser; -import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.loaders.RecaptchaReceiver; +import cgeo.geocaching.location.DistanceParser; +import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.network.Network; import cgeo.geocaching.network.Parameters; import cgeo.geocaching.settings.Settings; diff --git a/main/src/cgeo/geocaching/connector/gc/Tile.java b/main/src/cgeo/geocaching/connector/gc/Tile.java index ff13fe3..17d129e 100644 --- a/main/src/cgeo/geocaching/connector/gc/Tile.java +++ b/main/src/cgeo/geocaching/connector/gc/Tile.java @@ -1,8 +1,8 @@ package cgeo.geocaching.connector.gc; import cgeo.geocaching.ICoordinates; -import cgeo.geocaching.geopoint.Geopoint; -import cgeo.geocaching.geopoint.Viewport; +import cgeo.geocaching.location.Geopoint; +import cgeo.geocaching.location.Viewport; import cgeo.geocaching.network.Network; import cgeo.geocaching.network.Parameters; import cgeo.geocaching.utils.LeastRecentlyUsedSet; diff --git a/main/src/cgeo/geocaching/connector/oc/OCApiLiveConnector.java b/main/src/cgeo/geocaching/connector/oc/OCApiLiveConnector.java index dd25c5e..b56055a 100644 --- a/main/src/cgeo/geocaching/connector/oc/OCApiLiveConnector.java +++ b/main/src/cgeo/geocaching/connector/oc/OCApiLiveConnector.java @@ -15,9 +15,9 @@ import cgeo.geocaching.connector.capability.ISearchByOwner; import cgeo.geocaching.connector.capability.ISearchByViewPort; import cgeo.geocaching.connector.gc.MapTokens; import cgeo.geocaching.connector.oc.UserInfo.UserInfoStatus; -import cgeo.geocaching.geopoint.Geopoint; -import cgeo.geocaching.geopoint.Viewport; import cgeo.geocaching.loaders.RecaptchaReceiver; +import cgeo.geocaching.location.Geopoint; +import cgeo.geocaching.location.Viewport; import cgeo.geocaching.settings.Settings; import cgeo.geocaching.utils.CryptUtils; diff --git a/main/src/cgeo/geocaching/connector/oc/OkapiClient.java b/main/src/cgeo/geocaching/connector/oc/OkapiClient.java index f665a1a..b3f2f39 100644 --- a/main/src/cgeo/geocaching/connector/oc/OkapiClient.java +++ b/main/src/cgeo/geocaching/connector/oc/OkapiClient.java @@ -22,9 +22,9 @@ import cgeo.geocaching.enumerations.LoadFlags.SaveFlag; import cgeo.geocaching.enumerations.LogType; import cgeo.geocaching.enumerations.StatusCode; import cgeo.geocaching.enumerations.WaypointType; -import cgeo.geocaching.geopoint.Geopoint; -import cgeo.geocaching.geopoint.GeopointFormatter; -import cgeo.geocaching.geopoint.Viewport; +import cgeo.geocaching.location.Geopoint; +import cgeo.geocaching.location.GeopointFormatter; +import cgeo.geocaching.location.Viewport; import cgeo.geocaching.network.Network; import cgeo.geocaching.network.OAuth; import cgeo.geocaching.network.OAuthTokens; diff --git a/main/src/cgeo/geocaching/connector/ox/OXConnector.java b/main/src/cgeo/geocaching/connector/ox/OXConnector.java index 7d4cf7f..6bb5bce 100644 --- a/main/src/cgeo/geocaching/connector/ox/OXConnector.java +++ b/main/src/cgeo/geocaching/connector/ox/OXConnector.java @@ -9,9 +9,9 @@ import cgeo.geocaching.connector.capability.ISearchByGeocode; import cgeo.geocaching.connector.capability.ISearchByKeyword; import cgeo.geocaching.connector.capability.ISearchByViewPort; import cgeo.geocaching.connector.gc.MapTokens; -import cgeo.geocaching.geopoint.Geopoint; -import cgeo.geocaching.geopoint.Viewport; import cgeo.geocaching.loaders.RecaptchaReceiver; +import cgeo.geocaching.location.Geopoint; +import cgeo.geocaching.location.Viewport; import cgeo.geocaching.settings.Settings; import cgeo.geocaching.utils.CancellableHandler; diff --git a/main/src/cgeo/geocaching/connector/ox/OpenCachingApi.java b/main/src/cgeo/geocaching/connector/ox/OpenCachingApi.java index 21207ec..c232ef5 100644 --- a/main/src/cgeo/geocaching/connector/ox/OpenCachingApi.java +++ b/main/src/cgeo/geocaching/connector/ox/OpenCachingApi.java @@ -2,10 +2,10 @@ package cgeo.geocaching.connector.ox; import cgeo.geocaching.Geocache; import cgeo.geocaching.enumerations.CacheType; -import cgeo.geocaching.geopoint.Geopoint; -import cgeo.geocaching.geopoint.GeopointFormatter; -import cgeo.geocaching.geopoint.Viewport; import cgeo.geocaching.list.StoredList; +import cgeo.geocaching.location.Geopoint; +import cgeo.geocaching.location.GeopointFormatter; +import cgeo.geocaching.location.Viewport; import cgeo.geocaching.network.Network; import cgeo.geocaching.network.Parameters; import cgeo.geocaching.settings.Settings; diff --git a/main/src/cgeo/geocaching/export/GpxSerializer.java b/main/src/cgeo/geocaching/export/GpxSerializer.java index d3e8887..08c6ef5 100644 --- a/main/src/cgeo/geocaching/export/GpxSerializer.java +++ b/main/src/cgeo/geocaching/export/GpxSerializer.java @@ -7,7 +7,7 @@ import cgeo.geocaching.Trackable; import cgeo.geocaching.Waypoint; import cgeo.geocaching.enumerations.CacheAttribute; import cgeo.geocaching.enumerations.LoadFlags; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.utils.Log; import cgeo.geocaching.utils.SynchronizedDateFormat; import cgeo.geocaching.utils.TextUtils; diff --git a/main/src/cgeo/geocaching/files/GPXParser.java b/main/src/cgeo/geocaching/files/GPXParser.java index bedee43..cd99ae9 100644 --- a/main/src/cgeo/geocaching/files/GPXParser.java +++ b/main/src/cgeo/geocaching/files/GPXParser.java @@ -18,8 +18,8 @@ import cgeo.geocaching.enumerations.LoadFlags.RemoveFlag; import cgeo.geocaching.enumerations.LoadFlags.SaveFlag; import cgeo.geocaching.enumerations.LogType; import cgeo.geocaching.enumerations.WaypointType; -import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.list.StoredList; +import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.utils.CancellableHandler; import cgeo.geocaching.utils.Log; import cgeo.geocaching.utils.MatcherWrapper; diff --git a/main/src/cgeo/geocaching/files/LocParser.java b/main/src/cgeo/geocaching/files/LocParser.java index 6fcd2c3..1cc0c63 100644 --- a/main/src/cgeo/geocaching/files/LocParser.java +++ b/main/src/cgeo/geocaching/files/LocParser.java @@ -4,7 +4,7 @@ import cgeo.geocaching.Geocache; import cgeo.geocaching.SearchResult; import cgeo.geocaching.enumerations.CacheSize; import cgeo.geocaching.enumerations.CacheType; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.utils.CancellableHandler; import cgeo.geocaching.utils.Log; diff --git a/main/src/cgeo/geocaching/filter/DistanceFilter.java b/main/src/cgeo/geocaching/filter/DistanceFilter.java index 3328c72..923f46a 100644 --- a/main/src/cgeo/geocaching/filter/DistanceFilter.java +++ b/main/src/cgeo/geocaching/filter/DistanceFilter.java @@ -4,7 +4,7 @@ import cgeo.geocaching.CgeoApplication; import cgeo.geocaching.Geocache; import cgeo.geocaching.sensors.IGeoData; import cgeo.geocaching.R; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import java.util.ArrayList; import java.util.List; diff --git a/main/src/cgeo/geocaching/geopoint/DistanceParser.java b/main/src/cgeo/geocaching/geopoint/DistanceParser.java deleted file mode 100644 index e3a7482..0000000 --- a/main/src/cgeo/geocaching/geopoint/DistanceParser.java +++ /dev/null @@ -1,51 +0,0 @@ -package cgeo.geocaching.geopoint; - -import cgeo.geocaching.utils.MatcherWrapper; - -import org.apache.commons.lang3.StringUtils; - -import java.util.Locale; -import java.util.regex.Pattern; - -public final class DistanceParser { - - private static final Pattern pattern = Pattern.compile("^([0-9.,]+)[ ]*(m|km|ft|yd|mi|)?$", Pattern.CASE_INSENSITIVE); - - /** - * Parse a distance string composed by a number and an optional suffix - * (such as "1.2km"). - * - * @param distanceText - * the string to analyze - * @return the distance in kilometers - * - * @throws NumberFormatException - * if the given number is invalid - */ - public static float parseDistance(String distanceText, final boolean metricUnit) - throws NumberFormatException { - final MatcherWrapper matcher = new MatcherWrapper(pattern, distanceText); - - if (!matcher.find()) { - throw new NumberFormatException(distanceText); - } - - final float value = Float.parseFloat(matcher.group(1).replace(',', '.')); - final String unit = matcher.group(2).toLowerCase(Locale.US); - - if (unit.equals("m") || (StringUtils.isEmpty(unit) && metricUnit)) { - return value / 1000; - } - if (unit.equals("km")) { - return value; - } - if (unit.equals("yd")) { - return value * IConversion.YARDS_TO_KILOMETER; - } - if (unit.equals("mi")) { - return value * IConversion.MILES_TO_KILOMETER; - } - return value * IConversion.FEET_TO_KILOMETER; - } - -} diff --git a/main/src/cgeo/geocaching/geopoint/Geopoint.java b/main/src/cgeo/geocaching/geopoint/Geopoint.java deleted file mode 100644 index aa7c929..0000000 --- a/main/src/cgeo/geocaching/geopoint/Geopoint.java +++ /dev/null @@ -1,601 +0,0 @@ -package cgeo.geocaching.geopoint; - -import cgeo.geocaching.ICoordinates; -import cgeo.geocaching.R; - -import org.apache.commons.lang3.StringUtils; -import org.eclipse.jdt.annotation.NonNull; - -import android.location.Location; -import android.os.Build; -import android.os.Parcel; -import android.os.Parcelable; - -/** - * Abstraction of geographic point. This class is immutable. - */ -public final class Geopoint implements ICoordinates, Parcelable { - /** - * Reusable default object - */ - public static final @NonNull Geopoint ZERO = new Geopoint(0.0, 0.0); - - private static final double DEG_TO_RAD = Math.PI / 180; - private static final double RAD_TO_DEG = 180 / Math.PI; - private static final float EARTH_RADIUS = 6371.0f; - /** - * JIT bug in Android 4.2.1 - */ - private static final boolean DISTANCE_BROKEN = Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN_MR1; - - private final double latitude; - private final double longitude; - - /** - * Creates new Geopoint with given latitude and longitude (both degree). - * - * @param lat - * latitude - * @param lon - * longitude - */ - public Geopoint(final double lat, final double lon) { - latitude = lat; - longitude = lon; - } - - /** - * Creates new Geopoint with latitude and longitude parsed from string. - * - * @param text - * string to parse - * @throws Geopoint.ParseException - * if the string cannot be parsed - * @see GeopointParser#parse(String) - */ - public Geopoint(@NonNull final String text) { - final Geopoint parsed = GeopointParser.parse(text); - latitude = parsed.latitude; - longitude = parsed.longitude; - } - - /** - * Creates new Geopoint with latitude and longitude parsed from strings. - * - * @param latText - * latitude string to parse - * @param lonText - * longitude string to parse - * @throws Geopoint.ParseException - * if any argument string cannot be parsed - */ - public Geopoint(final String latText, final String lonText) { - this(GeopointParser.parseLatitude(latText), GeopointParser.parseLongitude(lonText)); - } - - /** - * Creates new Geopoint with given Location. - * - * @param loc - * the Location to clone - */ - public Geopoint(final Location loc) { - this(loc.getLatitude(), loc.getLongitude()); - } - - /** - * Create new Geopoint from Parcel. - * - * @param in - * a Parcel to read the saved data from - */ - public Geopoint(final Parcel in) { - latitude = in.readDouble(); - longitude = in.readDouble(); - } - - /** - * Create new Geopoint from individual textual components. - * - * @param latDir - * @param latDeg - * @param latDegFrac - * @param lonDir - * @param lonDeg - * @param lonDegFrac - */ - public Geopoint(final String latDir, final String latDeg, final String latDegFrac, - final String lonDir, final String lonDeg, final String lonDegFrac) { - this(getLatSign(latDir) + latDeg + "." + addZeros(latDegFrac, 5), - getLonSign(lonDir) + lonDeg + "." + addZeros(lonDegFrac, 5)); - } - - /** - * Create new Geopoint from individual textual components. - * - * @param latDir - * @param latDeg - * @param latMin - * @param latMinFrac - * @param lonDir - * @param lonDeg - * @param lonMin - * @param lonMinFrac - */ - public Geopoint(final String latDir, final String latDeg, final String latMin, final String latMinFrac, - final String lonDir, final String lonDeg, final String lonMin, final String lonMinFrac) { - this(latDir + " " + latDeg + " " + latMin + "." + addZeros(latMinFrac, 3), - lonDir + " " + lonDeg + " " + lonMin + "." + addZeros(lonMinFrac, 3)); - } - - /** - * Create new Geopoint from individual textual components. - * - * @param latDir - * @param latDeg - * @param latMin - * @param latSec - * @param latSecFrac - * @param lonDir - * @param lonDeg - * @param lonMin - * @param lonSec - * @param lonSecFrac - */ - public Geopoint(final String latDir, final String latDeg, final String latMin, final String latSec, final String latSecFrac, - final String lonDir, final String lonDeg, final String lonMin, final String lonSec, final String lonSecFrac) { - this(latDir + " " + latDeg + " " + latMin + " " + latSec + "." + addZeros(latSecFrac, 3), - lonDir + " " + lonDeg + " " + lonMin + " " + lonSec + "." + addZeros(lonSecFrac, 3)); - } - - /** - * Get latitude in degree. - * - * @return latitude - */ - public double getLatitude() { - return latitude; - } - - /** - * Get latitude in microdegree. - * - * @return latitude - */ - public int getLatitudeE6() { - return (int) Math.round(latitude * 1E6); - } - - /** - * Get longitude in degree. - * - * @return longitude - */ - public double getLongitude() { - return longitude; - } - - /* - * Return a waypoint which is the copy of this one rounded to the given limit. - * For example, to get a waypoint adapter to a display with 3 digits after the - * seconds decimal point, a rounding factor of 3600*1000 would be appropriate. - */ - Geopoint roundedAt(final long factor) { - return new Geopoint(((double) Math.round(latitude * factor)) / factor, - ((double) Math.round(longitude * factor)) / factor); - } - - /** - * Get longitude in microdegree. - * - * @return longitude - */ - public int getLongitudeE6() { - return (int) Math.round(longitude * 1E6); - } - - /** - * Get distance and bearing from the current point to a target. - * - * @param target - * The target - * @return An array of floats: the distance in meters, then the bearing in degrees - */ - private float[] pathTo(final Geopoint target) { - float[] results = new float[2]; - android.location.Location.distanceBetween(latitude, longitude, target.latitude, target.longitude, results); - return results; - } - - /** - * Calculates distance to given Geopoint in km. - * - * @param point - * target - * @return distance in km - * @throws GeopointException - * if there is an error in distance calculation - */ - public float distanceTo(@NonNull final ICoordinates point) { - final Geopoint otherCoords = point.getCoords(); - if (DISTANCE_BROKEN) { - return (float) (getDistance(latitude, longitude, otherCoords.latitude, otherCoords.longitude) / 1000); - } - return pathTo(otherCoords)[0] / 1000; - } - - /** - * Calculates bearing to given Geopoint in degree. - * - * @param point - * target - * @return bearing in degree, in the [0,360[ range - */ - public float bearingTo(final ICoordinates point) { - // Android library returns a bearing in the [-180;180] range - final float bearing = pathTo(point.getCoords())[1]; - return bearing < 0 ? bearing + 360 : bearing; - } - - /** - * Calculates geopoint from given bearing and distance. - * - * @param bearing - * bearing in degree - * @param distance - * distance in km - * @return the projected geopoint - */ - public Geopoint project(final double bearing, final double distance) { - final double rlat1 = latitude * DEG_TO_RAD; - final double rlon1 = longitude * DEG_TO_RAD; - final double rbearing = bearing * DEG_TO_RAD; - final double rdistance = distance / EARTH_RADIUS; - - final double rlat = Math.asin(Math.sin(rlat1) * Math.cos(rdistance) + Math.cos(rlat1) * Math.sin(rdistance) * Math.cos(rbearing)); - final double rlon = rlon1 + Math.atan2(Math.sin(rbearing) * Math.sin(rdistance) * Math.cos(rlat1), Math.cos(rdistance) - Math.sin(rlat1) * Math.sin(rlat)); - - return new Geopoint(rlat * RAD_TO_DEG, rlon * RAD_TO_DEG); - } - - @Override - public boolean equals(final Object obj) { - if (this == obj) { - return true; - } - if (!(obj instanceof Geopoint)) { - return false; - } - final Geopoint gp = (Geopoint) obj; - return getLatitudeE6() == gp.getLatitudeE6() && getLongitudeE6() == gp.getLongitudeE6(); - } - - @Override - public int hashCode() { - return getLatitudeE6() ^ getLongitudeE6(); - } - - /** - * Returns formatted coordinates. - * - * @param format - * the desired format - * @see GeopointFormatter - * @return formatted coordinates - */ - public String format(GeopointFormatter.Format format) { - return GeopointFormatter.format(format, this); - } - - /** - * Returns formatted coordinates with default format. - * Default format is decimalminutes, e.g. N 52° 36.123 E 010° 03.456 - * - * @return formatted coordinates - */ - @Override - public String toString() { - return format(GeopointFormatter.Format.LAT_LON_DECMINUTE); - } - - abstract public static class GeopointException extends NumberFormatException { - private static final long serialVersionUID = 1L; - - protected GeopointException(String msg) { - super(msg); - } - } - - public static class ParseException extends GeopointException { - private static final long serialVersionUID = 1L; - public final int resource; - - public ParseException(final String msg, final GeopointParser.LatLon faulty) { - super(msg); - resource = faulty == GeopointParser.LatLon.LAT ? R.string.err_parse_lat : R.string.err_parse_lon; - } - } - - @Override - public Geopoint getCoords() { - return this; - } - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(final Parcel dest, final int flags) { - dest.writeDouble(latitude); - dest.writeDouble(longitude); - } - - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - @Override - public Geopoint createFromParcel(final Parcel in) { - return new Geopoint(in); - } - - @Override - public Geopoint[] newArray(final int size) { - return new Geopoint[size]; - } - }; - - /** - * Get latitude character (N or S). - * - * @return - */ - public char getLatDir() { - return latitude >= 0 ? 'N' : 'S'; - } - - /** - * Get longitude character (E or W). - * - * @return - */ - public char getLonDir() { - return longitude >= 0 ? 'E' : 'W'; - } - - /** - * Get the integral non-negative latitude degrees. - * - * @return - */ - public int getLatDeg() { - return getDeg(latitude); - } - - /** - * Get the integral non-negative longitude degrees. - * - * @return - */ - public int getLonDeg() { - return getDeg(longitude); - } - - private static int getDeg(final double deg) { - return (int) Math.abs(deg); - } - - /** - * Get the fractional part of the latitude degrees scaled up by 10^5. - * - * @return - */ - public int getLatDegFrac() { - return getDegFrac(latitude); - } - - /** - * Get the fractional part of the longitude degrees scaled up by 10^5. - * - * @return - */ - public int getLonDegFrac() { - return getDegFrac(longitude); - } - - private static int getDegFrac(final double deg) { - return (int) (Math.round(Math.abs(deg) * 100000) % 100000); - } - - /** - * Get the integral latitude minutes. - * - * @return - */ - public int getLatMin() { - return getMin(latitude); - } - - /** - * Get the integral longitude minutes. - * - * @return - */ - public int getLonMin() { - return getMin(longitude); - } - - private static int getMin(final double deg) { - return ((int) Math.abs(deg * 60)) % 60; - } - - /** - * Get the fractional part of the latitude minutes scaled up by 1000. - * - * @return - */ - public int getLatMinFrac() { - return getMinFrac(latitude); - } - - /** - * Get the fractional part of the longitude minutes scaled up by 1000. - * - * @return - */ - public int getLonMinFrac() { - return getMinFrac(longitude); - } - - private static int getMinFrac(final double deg) { - return (int) (Math.round(Math.abs(deg) * 60000) % 1000); - } - - /** - * Get the latitude minutes. - * - * @return - */ - public double getLatMinRaw() { - return getMinRaw(latitude); - } - - /** - * Get the longitude minutes. - * - * @return - */ - public double getLonMinRaw() { - return getMinRaw(longitude); - } - - private static double getMinRaw(final double deg) { - return (Math.abs(deg) * 60) % 60; - } - - /** - * Get the integral part of the latitude seconds. - * - * @return - */ - public int getLatSec() { - return getSec(latitude); - } - - /** - * Get the integral part of the longitude seconds. - * - * @return - */ - public int getLonSec() { - return getSec(longitude); - } - - private static int getSec(final double deg) { - return ((int) Math.abs(deg * 3600)) % 60; - } - - /** - * Get the fractional part of the latitude seconds scaled up by 1000. - * - * @return - */ - - public int getLatSecFrac() { - return getSecFrac(latitude); - } - - /** - * Get the fractional part of the longitude seconds scaled up by 1000. - * - * @return - */ - - public int getLonSecFrac() { - return getSecFrac(longitude); - } - - private static int getSecFrac(final double deg) { - return (int) (Math.round(Math.abs(deg) * 3600000) % 1000); - } - - /** - * Get the latitude seconds. - * - * @return - */ - public double getLatSecRaw() { - return getSecRaw(latitude); - } - - /** - * Get the longitude seconds. - * - * @return - */ - public double getLonSecRaw() { - return getSecRaw(longitude); - } - - private static double getSecRaw(final double deg) { - return (Math.abs(deg) * 3600) % 60; - } - - private static String addZeros(final String value, final int len) { - return StringUtils.leftPad(value.trim(), len, '0'); - } - - private static String getLonSign(final String lonDir) { - return "W".equalsIgnoreCase(lonDir) ? "-" : ""; - } - - private static String getLatSign(final String latDir) { - return "S".equalsIgnoreCase(latDir) ? "-" : ""; - } - - /** - * Gets distance in meters (workaround for 4.2.1 JIT bug). - */ - public static double getDistance(double lat1, double lon1, double lat2, double lon2) { - // for haversine use R = 6372.8 km instead of 6371 km - double earthRadius = 6372.8; - double dLat = toRadians(lat2 - lat1); - double dLon = toRadians(lon2 - lon1); - double a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + - Math.cos(toRadians(lat1)) * Math.cos(toRadians(lat2)) * - Math.sin(dLon / 2) * Math.sin(dLon / 2); - // simplify haversine - return (2 * earthRadius * 1000 * Math.asin(Math.sqrt(a))); - } - - private static double toRadians(double angdeg) { - return angdeg * DEG_TO_RAD; - } - - /** - * Check whether a latitude built from user supplied data is valid. We accept both N90/S90. - * - * @return true if the latitude looks valid, false otherwise - */ - public static boolean isValidLatitude(final double latitude) { - return latitude >= -90 && latitude <= 90; - } - - /** - * Check whether a longitude from user supplied data is valid. We accept both E180/W180. - * - * @return true if the longitude looks valid, false otherwise - */ - public static boolean isValidLongitude(final double longitude) { - return longitude >= -180 && longitude <= 180; - } - - /** - * Check whether a geopoint built from user supplied data is valid. We accept both N90/S90 and E180/W180. - * - * @return true if the geopoint looks valid, false otherwise - */ - public boolean isValid() { - return isValidLatitude(latitude) && isValidLongitude(longitude); - } - -} diff --git a/main/src/cgeo/geocaching/geopoint/GeopointFormatter.java b/main/src/cgeo/geocaching/geopoint/GeopointFormatter.java deleted file mode 100644 index a6965f9..0000000 --- a/main/src/cgeo/geocaching/geopoint/GeopointFormatter.java +++ /dev/null @@ -1,116 +0,0 @@ -package cgeo.geocaching.geopoint; - -import java.util.Locale; - -/** - * Formatting of Geopoint. - */ -public class GeopointFormatter { - /** - * Predefined formats. - */ - public enum Format { - /** Example: "10,123456 -0,123456" */ - LAT_LON_DECDEGREE, - - /** Example: "10.123456,-0.123456" (unlocalized) */ - LAT_LON_DECDEGREE_COMMA, - - /** Example: "N 10° 12,345 · W 5° 12,345" */ - LAT_LON_DECMINUTE, - - /** Example: "N 10° 12.345 W 5° 12.345" */ - LAT_LON_DECMINUTE_RAW, - - /** Example: "N 10° 12' 34" W 5° 12' 34" */ - LAT_LON_DECSECOND, - - /** Example: "-0.123456" (unlocalized latitude) */ - LAT_DECDEGREE_RAW, - - /** Example: "N 10° 12,345" */ - LAT_DECMINUTE, - - /** Example: "N 10 12,345" */ - LAT_DECMINUTE_RAW, - - /** Example: "-0.123456" (unlocalized longitude) */ - LON_DECDEGREE_RAW, - - /** Example: "W 5° 12,345" */ - LON_DECMINUTE, - - /** Example: "W 5 12,345" */ - LON_DECMINUTE_RAW; - } - - /** - * Formats a Geopoint. - * - * @param gp - * the Geopoint to format - * @param format - * one of the predefined formats - * @return the formatted coordinates - */ - public static String format(final Format format, final Geopoint gp) { - final double latSigned = gp.getLatitude(); - final double lonSigned = gp.getLongitude(); - - switch (format) { - case LAT_LON_DECDEGREE: - return String.format(Locale.getDefault(), "%.6f %.6f", latSigned, lonSigned); - - case LAT_LON_DECDEGREE_COMMA: - return String.format((Locale) null, "%.6f,%.6f", latSigned, lonSigned); - - case LAT_LON_DECMINUTE: { - final Geopoint rgp = gp.roundedAt(60 * 1000); - return String.format(Locale.getDefault(), "%c %02d° %06.3f · %c %03d° %06.3f", - rgp.getLatDir(), rgp.getLatDeg(), rgp.getLatMinRaw(), rgp.getLonDir(), rgp.getLonDeg(), rgp.getLonMinRaw()); - } - - case LAT_LON_DECMINUTE_RAW: { - final Geopoint rgp = gp.roundedAt(60 * 1000); - return String.format((Locale) null, "%c %02d° %06.3f %c %03d° %06.3f", - rgp.getLatDir(), rgp.getLatDeg(), rgp.getLatMinRaw(), rgp.getLonDir(), rgp.getLonDeg(), rgp.getLonMinRaw()); - } - - case LAT_LON_DECSECOND: { - final Geopoint rgp = gp.roundedAt(3600 * 1000); - return String.format(Locale.getDefault(), "%c %02d° %02d' %06.3f\" · %c %03d° %02d' %06.3f\"", - rgp.getLatDir(), rgp.getLatDeg(), rgp.getLatMin(), rgp.getLatSecRaw(), - rgp.getLonDir(), rgp.getLonDeg(), rgp.getLonMin(), rgp.getLonSecRaw()); - } - - case LAT_DECDEGREE_RAW: - return String.format((Locale) null, "%.6f", latSigned); - - case LAT_DECMINUTE: { - final Geopoint rgp = gp.roundedAt(60 * 1000); - return String.format(Locale.getDefault(), "%c %02d° %06.3f", rgp.getLatDir(), rgp.getLatDeg(), rgp.getLatMinRaw()); - } - - case LAT_DECMINUTE_RAW: { - final Geopoint rgp = gp.roundedAt(60 * 1000); - return String.format(Locale.getDefault(), "%c %02d %06.3f", rgp.getLatDir(), rgp.getLatDeg(), rgp.getLatMinRaw()); - } - - case LON_DECDEGREE_RAW: - return String.format((Locale) null, "%.6f", lonSigned); - - case LON_DECMINUTE: { - final Geopoint rgp = gp.roundedAt(60 * 1000); - return String.format(Locale.getDefault(), "%c %03d° %06.3f", rgp.getLonDir(), rgp.getLonDeg(), rgp.getLonMinRaw()); - } - - case LON_DECMINUTE_RAW: { - final Geopoint rgp = gp.roundedAt(60 * 1000); - return String.format(Locale.getDefault(), "%c %03d %06.3f", rgp.getLonDir(), rgp.getLonDeg(), rgp.getLonMinRaw()); - } - - } - throw new IllegalStateException(); // cannot happen, if switch case is enum complete - } - -} diff --git a/main/src/cgeo/geocaching/geopoint/GeopointParser.java b/main/src/cgeo/geocaching/geopoint/GeopointParser.java deleted file mode 100644 index 62d43da..0000000 --- a/main/src/cgeo/geocaching/geopoint/GeopointParser.java +++ /dev/null @@ -1,163 +0,0 @@ -package cgeo.geocaching.geopoint; - -import cgeo.geocaching.utils.MatcherWrapper; - -import org.apache.commons.lang3.StringUtils; -import org.eclipse.jdt.annotation.NonNull; - -import java.util.regex.Pattern; - -/** - * Parse coordinates. - */ -class GeopointParser { - - private static class ResultWrapper { - final double result; - final int matcherPos; - final int matcherLength; - - public ResultWrapper(final double result, int matcherPos, int stringLength) { - this.result = result; - this.matcherPos = matcherPos; - this.matcherLength = stringLength; - } - } - - // ( 1 ) ( 2 ) ( 3 ) ( 4 ) ( 5 ) - private static final Pattern PATTERN_LAT = Pattern.compile("\\b([NS]|)\\s*(\\d+)°?(?:\\s*(\\d+)(?:[.,](\\d+)|'?\\s*(\\d+(?:[.,]\\d+)?)(?:''|\")?)?)?", Pattern.CASE_INSENSITIVE); - private static final Pattern PATTERN_LON = Pattern.compile("\\b([WE]|)\\s*(\\d+)°?(?:\\s*(\\d+)(?:[.,](\\d+)|'?\\s*(\\d+(?:[.,]\\d+)?)(?:''|\")?)?)?", Pattern.CASE_INSENSITIVE); - - private static final Pattern PATTERN_BAD_BLANK = Pattern.compile("(\\d)[,.] (\\d{2,})"); - - enum LatLon { - LAT, - LON - } - - /** - * Parses a pair of coordinates (latitude and longitude) out of a String. - * Accepts following formats and combinations of it: - * X DD - * X DD° - * X DD° MM - * X DD° MM.MMM - * X DD° MM SS - * - * as well as: - * DD.DDDDDDD - * - * Both . and , are accepted, also variable count of spaces (also 0) - * - * @param text - * the string to parse - * @return an Geopoint with parsed latitude and longitude - * @throws Geopoint.ParseException - * if lat or lon could not be parsed - */ - public static Geopoint parse(@NonNull final String text) { - final ResultWrapper latitudeWrapper = parseHelper(text, LatLon.LAT); - // cut away the latitude part when parsing the longitude - final ResultWrapper longitudeWrapper = parseHelper(text.substring(latitudeWrapper.matcherPos + latitudeWrapper.matcherLength), LatLon.LON); - - if (longitudeWrapper.matcherPos - (latitudeWrapper.matcherPos + latitudeWrapper.matcherLength) >= 10) { - throw new Geopoint.ParseException("Distance between latitude and longitude text is to large.", LatLon.LON); - } - - final double lat = latitudeWrapper.result; - final double lon = longitudeWrapper.result; - if (!Geopoint.isValidLatitude(lat)) { - throw new Geopoint.ParseException(text, LatLon.LAT); - } - if (!Geopoint.isValidLongitude(lon)) { - throw new Geopoint.ParseException(text, LatLon.LON); - } - return new Geopoint(lat, lon); - } - - /** - * Helper for coordinates-parsing - * - * @param text - * @param latlon - * @return - */ - private static ResultWrapper parseHelper(final String text, final LatLon latlon) { - - MatcherWrapper matcher = new MatcherWrapper(PATTERN_BAD_BLANK, text); - String replaceSpaceAfterComma = matcher.replaceAll("$1.$2"); - - final Pattern pattern = LatLon.LAT == latlon ? PATTERN_LAT : PATTERN_LON; - matcher = new MatcherWrapper(pattern, replaceSpaceAfterComma); - - try { - return new ResultWrapper(Double.valueOf(replaceSpaceAfterComma), 0, text.length()); - } catch (NumberFormatException ignored) { - // fall through to advanced parsing - } - - if (matcher.find()) { - final double sign = matcher.group(1).equalsIgnoreCase("S") || matcher.group(1).equalsIgnoreCase("W") ? -1.0 : 1.0; - final double degree = Integer.valueOf(matcher.group(2)).doubleValue(); - - double minutes = 0.0; - double seconds = 0.0; - - if (null != matcher.group(3)) { - minutes = Integer.valueOf(matcher.group(3)).doubleValue(); - - if (null != matcher.group(4)) { - seconds = Double.parseDouble("0." + matcher.group(4)) * 60.0; - } else if (null != matcher.group(5)) { - seconds = Double.parseDouble(matcher.group(5).replace(",", ".")); - } - } - - return new ResultWrapper(sign * (degree + minutes / 60.0 + seconds / 3600.0), matcher.start(), matcher.group().length()); - - } - - // Nothing found with "N 52...", try to match string as decimal degree parts (i.e. multiple doubles) - try { - final String[] items = StringUtils.split(text.trim()); - if (items.length > 0 && items.length <= 2) { - final int index = (latlon == LatLon.LON ? items.length - 1 : 0); - final String textPart = items[index]; - final int pos = (latlon == LatLon.LON ? text.lastIndexOf(textPart) : text.indexOf(textPart)); - return new ResultWrapper(Double.parseDouble(textPart), pos, textPart.length()); - } - } catch (NumberFormatException ignored) { - // The right exception will be raised below. - } - - throw new Geopoint.ParseException("Could not parse coordinates as " + latlon + ": \"" + text + "\"", latlon); - } - - /** - * Parses latitude out of a given string. - * - * @see #parse(String) - * @param text - * the string to be parsed - * @return the latitude as decimal degree - * @throws Geopoint.ParseException - * if latitude could not be parsed - */ - public static double parseLatitude(final String text) { - return parseHelper(text, LatLon.LAT).result; - } - - /** - * Parses longitude out of a given string. - * - * @see #parse(String) - * @param text - * the string to be parsed - * @return the longitude as decimal degree - * @throws Geopoint.ParseException - * if longitude could not be parsed - */ - public static double parseLongitude(final String text) { - return parseHelper(text, LatLon.LON).result; - } -} diff --git a/main/src/cgeo/geocaching/geopoint/IConversion.java b/main/src/cgeo/geocaching/geopoint/IConversion.java deleted file mode 100644 index b1cbffd..0000000 --- a/main/src/cgeo/geocaching/geopoint/IConversion.java +++ /dev/null @@ -1,13 +0,0 @@ -package cgeo.geocaching.geopoint; - -public interface IConversion { - public static final float MILES_TO_KILOMETER = 1.609344f; - public static final float FEET_TO_KILOMETER = 0.0003048f; - public static final float YARDS_TO_KILOMETER = 0.0009144f; - /** - * Factor used to calculate distance from meters to foot; - *

- * ft = m * METERS_TO_FEET; - */ - public static final double METERS_TO_FEET = 3.2808399d; -} diff --git a/main/src/cgeo/geocaching/geopoint/Units.java b/main/src/cgeo/geocaching/geopoint/Units.java deleted file mode 100644 index c657ede..0000000 --- a/main/src/cgeo/geocaching/geopoint/Units.java +++ /dev/null @@ -1,62 +0,0 @@ -package cgeo.geocaching.geopoint; - -import cgeo.geocaching.settings.Settings; - -import org.apache.commons.lang3.tuple.ImmutablePair; - -import java.util.Locale; - -public class Units { - - public static ImmutablePair scaleDistance(final double distanceKilometers) { - double distance; - String units; - if (Settings.useImperialUnits()) { - distance = distanceKilometers / IConversion.MILES_TO_KILOMETER; - if (distance >= 0.1) { - units = "mi"; - } else { - distance *= 5280; - units = "ft"; - } - } else { - if (distanceKilometers >= 1) { - distance = distanceKilometers; - units = "km"; - } else { - distance = distanceKilometers * 1000; - units = "m"; - } - } - return new ImmutablePair<>(distance, units); - } - - public static String getDistanceFromKilometers(final Float distanceKilometers) { - if (distanceKilometers == null) { - return "?"; - } - - final ImmutablePair scaled = scaleDistance(distanceKilometers); - String formatString; - if (scaled.left >= 100) { - formatString = "%.0f"; - } else if (scaled.left >= 10) { - formatString = "%.1f"; - } else { - formatString = "%.2f"; - } - - return String.format(formatString + " %s", scaled.left, scaled.right); - } - - public static String getDistanceFromMeters(float meters) { - return getDistanceFromKilometers(meters / 1000f); - } - - public static String getSpeed(final float kilometersPerHour) { - if (Settings.useImperialUnits()) { - return String.format(Locale.US, "%.0f mph", kilometersPerHour / IConversion.MILES_TO_KILOMETER); - } - return String.format(Locale.US, "%.0f km/h", kilometersPerHour); - } -} diff --git a/main/src/cgeo/geocaching/geopoint/Viewport.java b/main/src/cgeo/geocaching/geopoint/Viewport.java deleted file mode 100644 index a48b0a1..0000000 --- a/main/src/cgeo/geocaching/geopoint/Viewport.java +++ /dev/null @@ -1,192 +0,0 @@ -package cgeo.geocaching.geopoint; - -import cgeo.geocaching.ICoordinates; - -import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.jdt.annotation.Nullable; - -import java.util.Collection; - -public final class Viewport { - - public final @NonNull Geopoint center; - public final @NonNull Geopoint bottomLeft; - public final @NonNull Geopoint topRight; - - public Viewport(final @NonNull ICoordinates point1, final @NonNull ICoordinates point2) { - final Geopoint gp1 = point1.getCoords(); - final Geopoint gp2 = point2.getCoords(); - this.bottomLeft = new Geopoint(Math.min(gp1.getLatitude(), gp2.getLatitude()), - Math.min(gp1.getLongitude(), gp2.getLongitude())); - this.topRight = new Geopoint(Math.max(gp1.getLatitude(), gp2.getLatitude()), - Math.max(gp1.getLongitude(), gp2.getLongitude())); - this.center = new Geopoint((gp1.getLatitude() + gp2.getLatitude()) / 2, - (gp1.getLongitude() + gp2.getLongitude()) / 2); - } - - public Viewport(final @NonNull ICoordinates center, final double latSpan, final double lonSpan) { - this.center = center.getCoords(); - final double centerLat = this.center.getLatitude(); - final double centerLon = this.center.getLongitude(); - final double latHalfSpan = Math.abs(latSpan) / 2; - final double lonHalfSpan = Math.abs(lonSpan) / 2; - bottomLeft = new Geopoint(centerLat - latHalfSpan, centerLon - lonHalfSpan); - topRight = new Geopoint(centerLat + latHalfSpan, centerLon + lonHalfSpan); - } - - public double getLatitudeMin() { - return bottomLeft.getLatitude(); - } - - public double getLatitudeMax() { - return topRight.getLatitude(); - } - - public double getLongitudeMin() { - return bottomLeft.getLongitude(); - } - - public double getLongitudeMax() { - return topRight.getLongitude(); - } - - public @NonNull - Geopoint getCenter() { - return center; - } - - public double getLatitudeSpan() { - return getLatitudeMax() - getLatitudeMin(); - } - - public double getLongitudeSpan() { - return getLongitudeMax() - getLongitudeMin(); - } - - /** - * Check whether a point is contained in this viewport. - * - * @param point - * the coordinates to check - * @return true if the point is contained in this viewport, false otherwise or if the point contains no coordinates - */ - public boolean contains(final @NonNull ICoordinates point) { - final Geopoint coords = point.getCoords(); - return coords != null - && coords.getLongitudeE6() >= bottomLeft.getLongitudeE6() - && coords.getLongitudeE6() <= topRight.getLongitudeE6() - && coords.getLatitudeE6() >= bottomLeft.getLatitudeE6() - && coords.getLatitudeE6() <= topRight.getLatitudeE6(); - } - - /** - * Count the number of points present in the viewport. - * - * @param points a collection of (possibly null) points - * @return the number of non-null points in the viewport - */ - public int count(final @NonNull Collection points) { - int total = 0; - for (ICoordinates point: points) { - if (point != null && contains(point)) { - total += 1; - } - } - return total; - } - - @Override - public String toString() { - return "(" + bottomLeft.toString() + "," + topRight.toString() + ")"; - } - - /** - * Check whether another viewport is fully included into the current one. - * - * @param vp - * the other viewport - * @return true if the viewport is fully included into this one, false otherwise - */ - public boolean includes(final @NonNull Viewport vp) { - return contains(vp.bottomLeft) && contains(vp.topRight); - } - - /** - * Return the "where" part of the string appropriate for a SQL query. - * - * @param dbTable - * the database table to use as prefix, or null if no prefix is required - * @return the string without the "where" keyword - */ - public StringBuilder sqlWhere(@Nullable final String dbTable) { - final String prefix = dbTable == null ? "" : (dbTable + "."); - return new StringBuilder(prefix).append("latitude >= ").append(getLatitudeMin()).append(" and ") - .append(prefix).append("latitude <= ").append(getLatitudeMax()).append(" and ") - .append(prefix).append("longitude >= ").append(getLongitudeMin()).append(" and ") - .append(prefix).append("longitude <= ").append(getLongitudeMax()); - } - - /** - * Return a widened or shrunk viewport. - * - * @param factor - * multiplicative factor for the latitude and longitude span (> 1 to widen, < 1 to shrink) - * @return a widened or shrunk viewport - */ - public @NonNull - Viewport resize(final double factor) { - return new Viewport(getCenter(), getLatitudeSpan() * factor, getLongitudeSpan() * factor); - } - - /** - * Return the smallest viewport containing all the given points. - * - * @param points - * a set of points. Point with null coordinates (or null themselves) will be ignored - * @return the smallest viewport containing the non-null coordinates, or null if no coordinates are non-null - */ - static public @Nullable - Viewport containing(final Collection points) { - boolean valid = false; - double latMin = Double.MAX_VALUE; - double latMax = -Double.MAX_VALUE; - double lonMin = Double.MAX_VALUE; - double lonMax = -Double.MAX_VALUE; - for (final ICoordinates point : points) { - if (point != null) { - final Geopoint coords = point.getCoords(); - if (coords != null) { - valid = true; - final double latitude = coords.getLatitude(); - final double longitude = coords.getLongitude(); - latMin = Math.min(latMin, latitude); - latMax = Math.max(latMax, latitude); - lonMin = Math.min(lonMin, longitude); - lonMax = Math.max(lonMax, longitude); - } - } - } - if (!valid) { - return null; - } - return new Viewport(new Geopoint(latMin, lonMin), new Geopoint(latMax, lonMax)); - } - - @Override - public boolean equals(final Object other) { - if (this == other) { - return true; - } - if (!(other instanceof Viewport)) { - return false; - } - final Viewport vp = (Viewport) other; - return bottomLeft.equals(vp.bottomLeft) && topRight.equals(vp.topRight); - } - - @Override - public int hashCode() { - return bottomLeft.hashCode() ^ topRight.hashCode(); - } - -} diff --git a/main/src/cgeo/geocaching/loaders/CoordsGeocacheListLoader.java b/main/src/cgeo/geocaching/loaders/CoordsGeocacheListLoader.java index c2d92bf..2549b7b 100644 --- a/main/src/cgeo/geocaching/loaders/CoordsGeocacheListLoader.java +++ b/main/src/cgeo/geocaching/loaders/CoordsGeocacheListLoader.java @@ -3,9 +3,10 @@ package cgeo.geocaching.loaders; import cgeo.geocaching.SearchResult; import cgeo.geocaching.connector.ConnectorFactory; import cgeo.geocaching.connector.capability.ISearchByCenter; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import org.eclipse.jdt.annotation.NonNull; + import rx.functions.Func1; import android.content.Context; diff --git a/main/src/cgeo/geocaching/loaders/HistoryGeocacheListLoader.java b/main/src/cgeo/geocaching/loaders/HistoryGeocacheListLoader.java index fdb35f2..74d5e8a 100644 --- a/main/src/cgeo/geocaching/loaders/HistoryGeocacheListLoader.java +++ b/main/src/cgeo/geocaching/loaders/HistoryGeocacheListLoader.java @@ -3,7 +3,7 @@ package cgeo.geocaching.loaders; import cgeo.geocaching.DataStore; import cgeo.geocaching.SearchResult; import cgeo.geocaching.enumerations.CacheType; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.settings.Settings; import android.content.Context; diff --git a/main/src/cgeo/geocaching/loaders/OfflineGeocacheListLoader.java b/main/src/cgeo/geocaching/loaders/OfflineGeocacheListLoader.java index 0d5af6a..04d720e 100644 --- a/main/src/cgeo/geocaching/loaders/OfflineGeocacheListLoader.java +++ b/main/src/cgeo/geocaching/loaders/OfflineGeocacheListLoader.java @@ -3,7 +3,7 @@ package cgeo.geocaching.loaders; import cgeo.geocaching.DataStore; import cgeo.geocaching.Intents; import cgeo.geocaching.SearchResult; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.settings.Settings; import android.content.Context; diff --git a/main/src/cgeo/geocaching/location/DistanceParser.java b/main/src/cgeo/geocaching/location/DistanceParser.java new file mode 100644 index 0000000..1fb8fc7 --- /dev/null +++ b/main/src/cgeo/geocaching/location/DistanceParser.java @@ -0,0 +1,51 @@ +package cgeo.geocaching.location; + +import cgeo.geocaching.utils.MatcherWrapper; + +import org.apache.commons.lang3.StringUtils; + +import java.util.Locale; +import java.util.regex.Pattern; + +public final class DistanceParser { + + private static final Pattern pattern = Pattern.compile("^([0-9.,]+)[ ]*(m|km|ft|yd|mi|)?$", Pattern.CASE_INSENSITIVE); + + /** + * Parse a distance string composed by a number and an optional suffix + * (such as "1.2km"). + * + * @param distanceText + * the string to analyze + * @return the distance in kilometers + * + * @throws NumberFormatException + * if the given number is invalid + */ + public static float parseDistance(String distanceText, final boolean metricUnit) + throws NumberFormatException { + final MatcherWrapper matcher = new MatcherWrapper(pattern, distanceText); + + if (!matcher.find()) { + throw new NumberFormatException(distanceText); + } + + final float value = Float.parseFloat(matcher.group(1).replace(',', '.')); + final String unit = matcher.group(2).toLowerCase(Locale.US); + + if (unit.equals("m") || (StringUtils.isEmpty(unit) && metricUnit)) { + return value / 1000; + } + if (unit.equals("km")) { + return value; + } + if (unit.equals("yd")) { + return value * IConversion.YARDS_TO_KILOMETER; + } + if (unit.equals("mi")) { + return value * IConversion.MILES_TO_KILOMETER; + } + return value * IConversion.FEET_TO_KILOMETER; + } + +} diff --git a/main/src/cgeo/geocaching/location/Geopoint.java b/main/src/cgeo/geocaching/location/Geopoint.java new file mode 100644 index 0000000..ad693ca --- /dev/null +++ b/main/src/cgeo/geocaching/location/Geopoint.java @@ -0,0 +1,601 @@ +package cgeo.geocaching.location; + +import cgeo.geocaching.ICoordinates; +import cgeo.geocaching.R; + +import org.apache.commons.lang3.StringUtils; +import org.eclipse.jdt.annotation.NonNull; + +import android.location.Location; +import android.os.Build; +import android.os.Parcel; +import android.os.Parcelable; + +/** + * Abstraction of geographic point. This class is immutable. + */ +public final class Geopoint implements ICoordinates, Parcelable { + /** + * Reusable default object + */ + public static final @NonNull Geopoint ZERO = new Geopoint(0.0, 0.0); + + private static final double DEG_TO_RAD = Math.PI / 180; + private static final double RAD_TO_DEG = 180 / Math.PI; + private static final float EARTH_RADIUS = 6371.0f; + /** + * JIT bug in Android 4.2.1 + */ + private static final boolean DISTANCE_BROKEN = Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN_MR1; + + private final double latitude; + private final double longitude; + + /** + * Creates new Geopoint with given latitude and longitude (both degree). + * + * @param lat + * latitude + * @param lon + * longitude + */ + public Geopoint(final double lat, final double lon) { + latitude = lat; + longitude = lon; + } + + /** + * Creates new Geopoint with latitude and longitude parsed from string. + * + * @param text + * string to parse + * @throws Geopoint.ParseException + * if the string cannot be parsed + * @see GeopointParser#parse(String) + */ + public Geopoint(@NonNull final String text) { + final Geopoint parsed = GeopointParser.parse(text); + latitude = parsed.latitude; + longitude = parsed.longitude; + } + + /** + * Creates new Geopoint with latitude and longitude parsed from strings. + * + * @param latText + * latitude string to parse + * @param lonText + * longitude string to parse + * @throws Geopoint.ParseException + * if any argument string cannot be parsed + */ + public Geopoint(final String latText, final String lonText) { + this(GeopointParser.parseLatitude(latText), GeopointParser.parseLongitude(lonText)); + } + + /** + * Creates new Geopoint with given Location. + * + * @param loc + * the Location to clone + */ + public Geopoint(final Location loc) { + this(loc.getLatitude(), loc.getLongitude()); + } + + /** + * Create new Geopoint from Parcel. + * + * @param in + * a Parcel to read the saved data from + */ + public Geopoint(final Parcel in) { + latitude = in.readDouble(); + longitude = in.readDouble(); + } + + /** + * Create new Geopoint from individual textual components. + * + * @param latDir + * @param latDeg + * @param latDegFrac + * @param lonDir + * @param lonDeg + * @param lonDegFrac + */ + public Geopoint(final String latDir, final String latDeg, final String latDegFrac, + final String lonDir, final String lonDeg, final String lonDegFrac) { + this(getLatSign(latDir) + latDeg + "." + addZeros(latDegFrac, 5), + getLonSign(lonDir) + lonDeg + "." + addZeros(lonDegFrac, 5)); + } + + /** + * Create new Geopoint from individual textual components. + * + * @param latDir + * @param latDeg + * @param latMin + * @param latMinFrac + * @param lonDir + * @param lonDeg + * @param lonMin + * @param lonMinFrac + */ + public Geopoint(final String latDir, final String latDeg, final String latMin, final String latMinFrac, + final String lonDir, final String lonDeg, final String lonMin, final String lonMinFrac) { + this(latDir + " " + latDeg + " " + latMin + "." + addZeros(latMinFrac, 3), + lonDir + " " + lonDeg + " " + lonMin + "." + addZeros(lonMinFrac, 3)); + } + + /** + * Create new Geopoint from individual textual components. + * + * @param latDir + * @param latDeg + * @param latMin + * @param latSec + * @param latSecFrac + * @param lonDir + * @param lonDeg + * @param lonMin + * @param lonSec + * @param lonSecFrac + */ + public Geopoint(final String latDir, final String latDeg, final String latMin, final String latSec, final String latSecFrac, + final String lonDir, final String lonDeg, final String lonMin, final String lonSec, final String lonSecFrac) { + this(latDir + " " + latDeg + " " + latMin + " " + latSec + "." + addZeros(latSecFrac, 3), + lonDir + " " + lonDeg + " " + lonMin + " " + lonSec + "." + addZeros(lonSecFrac, 3)); + } + + /** + * Get latitude in degree. + * + * @return latitude + */ + public double getLatitude() { + return latitude; + } + + /** + * Get latitude in microdegree. + * + * @return latitude + */ + public int getLatitudeE6() { + return (int) Math.round(latitude * 1E6); + } + + /** + * Get longitude in degree. + * + * @return longitude + */ + public double getLongitude() { + return longitude; + } + + /* + * Return a waypoint which is the copy of this one rounded to the given limit. + * For example, to get a waypoint adapter to a display with 3 digits after the + * seconds decimal point, a rounding factor of 3600*1000 would be appropriate. + */ + Geopoint roundedAt(final long factor) { + return new Geopoint(((double) Math.round(latitude * factor)) / factor, + ((double) Math.round(longitude * factor)) / factor); + } + + /** + * Get longitude in microdegree. + * + * @return longitude + */ + public int getLongitudeE6() { + return (int) Math.round(longitude * 1E6); + } + + /** + * Get distance and bearing from the current point to a target. + * + * @param target + * The target + * @return An array of floats: the distance in meters, then the bearing in degrees + */ + private float[] pathTo(final Geopoint target) { + float[] results = new float[2]; + android.location.Location.distanceBetween(latitude, longitude, target.latitude, target.longitude, results); + return results; + } + + /** + * Calculates distance to given Geopoint in km. + * + * @param point + * target + * @return distance in km + * @throws GeopointException + * if there is an error in distance calculation + */ + public float distanceTo(@NonNull final ICoordinates point) { + final Geopoint otherCoords = point.getCoords(); + if (DISTANCE_BROKEN) { + return (float) (getDistance(latitude, longitude, otherCoords.latitude, otherCoords.longitude) / 1000); + } + return pathTo(otherCoords)[0] / 1000; + } + + /** + * Calculates bearing to given Geopoint in degree. + * + * @param point + * target + * @return bearing in degree, in the [0,360[ range + */ + public float bearingTo(final ICoordinates point) { + // Android library returns a bearing in the [-180;180] range + final float bearing = pathTo(point.getCoords())[1]; + return bearing < 0 ? bearing + 360 : bearing; + } + + /** + * Calculates geopoint from given bearing and distance. + * + * @param bearing + * bearing in degree + * @param distance + * distance in km + * @return the projected geopoint + */ + public Geopoint project(final double bearing, final double distance) { + final double rlat1 = latitude * DEG_TO_RAD; + final double rlon1 = longitude * DEG_TO_RAD; + final double rbearing = bearing * DEG_TO_RAD; + final double rdistance = distance / EARTH_RADIUS; + + final double rlat = Math.asin(Math.sin(rlat1) * Math.cos(rdistance) + Math.cos(rlat1) * Math.sin(rdistance) * Math.cos(rbearing)); + final double rlon = rlon1 + Math.atan2(Math.sin(rbearing) * Math.sin(rdistance) * Math.cos(rlat1), Math.cos(rdistance) - Math.sin(rlat1) * Math.sin(rlat)); + + return new Geopoint(rlat * RAD_TO_DEG, rlon * RAD_TO_DEG); + } + + @Override + public boolean equals(final Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof Geopoint)) { + return false; + } + final Geopoint gp = (Geopoint) obj; + return getLatitudeE6() == gp.getLatitudeE6() && getLongitudeE6() == gp.getLongitudeE6(); + } + + @Override + public int hashCode() { + return getLatitudeE6() ^ getLongitudeE6(); + } + + /** + * Returns formatted coordinates. + * + * @param format + * the desired format + * @see GeopointFormatter + * @return formatted coordinates + */ + public String format(GeopointFormatter.Format format) { + return GeopointFormatter.format(format, this); + } + + /** + * Returns formatted coordinates with default format. + * Default format is decimalminutes, e.g. N 52° 36.123 E 010° 03.456 + * + * @return formatted coordinates + */ + @Override + public String toString() { + return format(GeopointFormatter.Format.LAT_LON_DECMINUTE); + } + + abstract public static class GeopointException extends NumberFormatException { + private static final long serialVersionUID = 1L; + + protected GeopointException(String msg) { + super(msg); + } + } + + public static class ParseException extends GeopointException { + private static final long serialVersionUID = 1L; + public final int resource; + + public ParseException(final String msg, final GeopointParser.LatLon faulty) { + super(msg); + resource = faulty == GeopointParser.LatLon.LAT ? R.string.err_parse_lat : R.string.err_parse_lon; + } + } + + @Override + public Geopoint getCoords() { + return this; + } + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(final Parcel dest, final int flags) { + dest.writeDouble(latitude); + dest.writeDouble(longitude); + } + + public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { + @Override + public Geopoint createFromParcel(final Parcel in) { + return new Geopoint(in); + } + + @Override + public Geopoint[] newArray(final int size) { + return new Geopoint[size]; + } + }; + + /** + * Get latitude character (N or S). + * + * @return + */ + public char getLatDir() { + return latitude >= 0 ? 'N' : 'S'; + } + + /** + * Get longitude character (E or W). + * + * @return + */ + public char getLonDir() { + return longitude >= 0 ? 'E' : 'W'; + } + + /** + * Get the integral non-negative latitude degrees. + * + * @return + */ + public int getLatDeg() { + return getDeg(latitude); + } + + /** + * Get the integral non-negative longitude degrees. + * + * @return + */ + public int getLonDeg() { + return getDeg(longitude); + } + + private static int getDeg(final double deg) { + return (int) Math.abs(deg); + } + + /** + * Get the fractional part of the latitude degrees scaled up by 10^5. + * + * @return + */ + public int getLatDegFrac() { + return getDegFrac(latitude); + } + + /** + * Get the fractional part of the longitude degrees scaled up by 10^5. + * + * @return + */ + public int getLonDegFrac() { + return getDegFrac(longitude); + } + + private static int getDegFrac(final double deg) { + return (int) (Math.round(Math.abs(deg) * 100000) % 100000); + } + + /** + * Get the integral latitude minutes. + * + * @return + */ + public int getLatMin() { + return getMin(latitude); + } + + /** + * Get the integral longitude minutes. + * + * @return + */ + public int getLonMin() { + return getMin(longitude); + } + + private static int getMin(final double deg) { + return ((int) Math.abs(deg * 60)) % 60; + } + + /** + * Get the fractional part of the latitude minutes scaled up by 1000. + * + * @return + */ + public int getLatMinFrac() { + return getMinFrac(latitude); + } + + /** + * Get the fractional part of the longitude minutes scaled up by 1000. + * + * @return + */ + public int getLonMinFrac() { + return getMinFrac(longitude); + } + + private static int getMinFrac(final double deg) { + return (int) (Math.round(Math.abs(deg) * 60000) % 1000); + } + + /** + * Get the latitude minutes. + * + * @return + */ + public double getLatMinRaw() { + return getMinRaw(latitude); + } + + /** + * Get the longitude minutes. + * + * @return + */ + public double getLonMinRaw() { + return getMinRaw(longitude); + } + + private static double getMinRaw(final double deg) { + return (Math.abs(deg) * 60) % 60; + } + + /** + * Get the integral part of the latitude seconds. + * + * @return + */ + public int getLatSec() { + return getSec(latitude); + } + + /** + * Get the integral part of the longitude seconds. + * + * @return + */ + public int getLonSec() { + return getSec(longitude); + } + + private static int getSec(final double deg) { + return ((int) Math.abs(deg * 3600)) % 60; + } + + /** + * Get the fractional part of the latitude seconds scaled up by 1000. + * + * @return + */ + + public int getLatSecFrac() { + return getSecFrac(latitude); + } + + /** + * Get the fractional part of the longitude seconds scaled up by 1000. + * + * @return + */ + + public int getLonSecFrac() { + return getSecFrac(longitude); + } + + private static int getSecFrac(final double deg) { + return (int) (Math.round(Math.abs(deg) * 3600000) % 1000); + } + + /** + * Get the latitude seconds. + * + * @return + */ + public double getLatSecRaw() { + return getSecRaw(latitude); + } + + /** + * Get the longitude seconds. + * + * @return + */ + public double getLonSecRaw() { + return getSecRaw(longitude); + } + + private static double getSecRaw(final double deg) { + return (Math.abs(deg) * 3600) % 60; + } + + private static String addZeros(final String value, final int len) { + return StringUtils.leftPad(value.trim(), len, '0'); + } + + private static String getLonSign(final String lonDir) { + return "W".equalsIgnoreCase(lonDir) ? "-" : ""; + } + + private static String getLatSign(final String latDir) { + return "S".equalsIgnoreCase(latDir) ? "-" : ""; + } + + /** + * Gets distance in meters (workaround for 4.2.1 JIT bug). + */ + public static double getDistance(double lat1, double lon1, double lat2, double lon2) { + // for haversine use R = 6372.8 km instead of 6371 km + double earthRadius = 6372.8; + double dLat = toRadians(lat2 - lat1); + double dLon = toRadians(lon2 - lon1); + double a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + + Math.cos(toRadians(lat1)) * Math.cos(toRadians(lat2)) * + Math.sin(dLon / 2) * Math.sin(dLon / 2); + // simplify haversine + return (2 * earthRadius * 1000 * Math.asin(Math.sqrt(a))); + } + + private static double toRadians(double angdeg) { + return angdeg * DEG_TO_RAD; + } + + /** + * Check whether a latitude built from user supplied data is valid. We accept both N90/S90. + * + * @return true if the latitude looks valid, false otherwise + */ + public static boolean isValidLatitude(final double latitude) { + return latitude >= -90 && latitude <= 90; + } + + /** + * Check whether a longitude from user supplied data is valid. We accept both E180/W180. + * + * @return true if the longitude looks valid, false otherwise + */ + public static boolean isValidLongitude(final double longitude) { + return longitude >= -180 && longitude <= 180; + } + + /** + * Check whether a geopoint built from user supplied data is valid. We accept both N90/S90 and E180/W180. + * + * @return true if the geopoint looks valid, false otherwise + */ + public boolean isValid() { + return isValidLatitude(latitude) && isValidLongitude(longitude); + } + +} diff --git a/main/src/cgeo/geocaching/location/GeopointFormatter.java b/main/src/cgeo/geocaching/location/GeopointFormatter.java new file mode 100644 index 0000000..599b6c7 --- /dev/null +++ b/main/src/cgeo/geocaching/location/GeopointFormatter.java @@ -0,0 +1,116 @@ +package cgeo.geocaching.location; + +import java.util.Locale; + +/** + * Formatting of Geopoint. + */ +public class GeopointFormatter { + /** + * Predefined formats. + */ + public enum Format { + /** Example: "10,123456 -0,123456" */ + LAT_LON_DECDEGREE, + + /** Example: "10.123456,-0.123456" (unlocalized) */ + LAT_LON_DECDEGREE_COMMA, + + /** Example: "N 10° 12,345 · W 5° 12,345" */ + LAT_LON_DECMINUTE, + + /** Example: "N 10° 12.345 W 5° 12.345" */ + LAT_LON_DECMINUTE_RAW, + + /** Example: "N 10° 12' 34" W 5° 12' 34" */ + LAT_LON_DECSECOND, + + /** Example: "-0.123456" (unlocalized latitude) */ + LAT_DECDEGREE_RAW, + + /** Example: "N 10° 12,345" */ + LAT_DECMINUTE, + + /** Example: "N 10 12,345" */ + LAT_DECMINUTE_RAW, + + /** Example: "-0.123456" (unlocalized longitude) */ + LON_DECDEGREE_RAW, + + /** Example: "W 5° 12,345" */ + LON_DECMINUTE, + + /** Example: "W 5 12,345" */ + LON_DECMINUTE_RAW; + } + + /** + * Formats a Geopoint. + * + * @param gp + * the Geopoint to format + * @param format + * one of the predefined formats + * @return the formatted coordinates + */ + public static String format(final Format format, final Geopoint gp) { + final double latSigned = gp.getLatitude(); + final double lonSigned = gp.getLongitude(); + + switch (format) { + case LAT_LON_DECDEGREE: + return String.format(Locale.getDefault(), "%.6f %.6f", latSigned, lonSigned); + + case LAT_LON_DECDEGREE_COMMA: + return String.format((Locale) null, "%.6f,%.6f", latSigned, lonSigned); + + case LAT_LON_DECMINUTE: { + final Geopoint rgp = gp.roundedAt(60 * 1000); + return String.format(Locale.getDefault(), "%c %02d° %06.3f · %c %03d° %06.3f", + rgp.getLatDir(), rgp.getLatDeg(), rgp.getLatMinRaw(), rgp.getLonDir(), rgp.getLonDeg(), rgp.getLonMinRaw()); + } + + case LAT_LON_DECMINUTE_RAW: { + final Geopoint rgp = gp.roundedAt(60 * 1000); + return String.format((Locale) null, "%c %02d° %06.3f %c %03d° %06.3f", + rgp.getLatDir(), rgp.getLatDeg(), rgp.getLatMinRaw(), rgp.getLonDir(), rgp.getLonDeg(), rgp.getLonMinRaw()); + } + + case LAT_LON_DECSECOND: { + final Geopoint rgp = gp.roundedAt(3600 * 1000); + return String.format(Locale.getDefault(), "%c %02d° %02d' %06.3f\" · %c %03d° %02d' %06.3f\"", + rgp.getLatDir(), rgp.getLatDeg(), rgp.getLatMin(), rgp.getLatSecRaw(), + rgp.getLonDir(), rgp.getLonDeg(), rgp.getLonMin(), rgp.getLonSecRaw()); + } + + case LAT_DECDEGREE_RAW: + return String.format((Locale) null, "%.6f", latSigned); + + case LAT_DECMINUTE: { + final Geopoint rgp = gp.roundedAt(60 * 1000); + return String.format(Locale.getDefault(), "%c %02d° %06.3f", rgp.getLatDir(), rgp.getLatDeg(), rgp.getLatMinRaw()); + } + + case LAT_DECMINUTE_RAW: { + final Geopoint rgp = gp.roundedAt(60 * 1000); + return String.format(Locale.getDefault(), "%c %02d %06.3f", rgp.getLatDir(), rgp.getLatDeg(), rgp.getLatMinRaw()); + } + + case LON_DECDEGREE_RAW: + return String.format((Locale) null, "%.6f", lonSigned); + + case LON_DECMINUTE: { + final Geopoint rgp = gp.roundedAt(60 * 1000); + return String.format(Locale.getDefault(), "%c %03d° %06.3f", rgp.getLonDir(), rgp.getLonDeg(), rgp.getLonMinRaw()); + } + + case LON_DECMINUTE_RAW: { + final Geopoint rgp = gp.roundedAt(60 * 1000); + return String.format(Locale.getDefault(), "%c %03d %06.3f", rgp.getLonDir(), rgp.getLonDeg(), rgp.getLonMinRaw()); + } + + } + throw new IllegalStateException(); // cannot happen, if switch case is enum complete + } + +} diff --git a/main/src/cgeo/geocaching/location/GeopointParser.java b/main/src/cgeo/geocaching/location/GeopointParser.java new file mode 100644 index 0000000..85a74e1 --- /dev/null +++ b/main/src/cgeo/geocaching/location/GeopointParser.java @@ -0,0 +1,163 @@ +package cgeo.geocaching.location; + +import cgeo.geocaching.utils.MatcherWrapper; + +import org.apache.commons.lang3.StringUtils; +import org.eclipse.jdt.annotation.NonNull; + +import java.util.regex.Pattern; + +/** + * Parse coordinates. + */ +class GeopointParser { + + private static class ResultWrapper { + final double result; + final int matcherPos; + final int matcherLength; + + public ResultWrapper(final double result, int matcherPos, int stringLength) { + this.result = result; + this.matcherPos = matcherPos; + this.matcherLength = stringLength; + } + } + + // ( 1 ) ( 2 ) ( 3 ) ( 4 ) ( 5 ) + private static final Pattern PATTERN_LAT = Pattern.compile("\\b([NS]|)\\s*(\\d+)°?(?:\\s*(\\d+)(?:[.,](\\d+)|'?\\s*(\\d+(?:[.,]\\d+)?)(?:''|\")?)?)?", Pattern.CASE_INSENSITIVE); + private static final Pattern PATTERN_LON = Pattern.compile("\\b([WE]|)\\s*(\\d+)°?(?:\\s*(\\d+)(?:[.,](\\d+)|'?\\s*(\\d+(?:[.,]\\d+)?)(?:''|\")?)?)?", Pattern.CASE_INSENSITIVE); + + private static final Pattern PATTERN_BAD_BLANK = Pattern.compile("(\\d)[,.] (\\d{2,})"); + + enum LatLon { + LAT, + LON + } + + /** + * Parses a pair of coordinates (latitude and longitude) out of a String. + * Accepts following formats and combinations of it: + * X DD + * X DD° + * X DD° MM + * X DD° MM.MMM + * X DD° MM SS + * + * as well as: + * DD.DDDDDDD + * + * Both . and , are accepted, also variable count of spaces (also 0) + * + * @param text + * the string to parse + * @return an Geopoint with parsed latitude and longitude + * @throws Geopoint.ParseException + * if lat or lon could not be parsed + */ + public static Geopoint parse(@NonNull final String text) { + final ResultWrapper latitudeWrapper = parseHelper(text, LatLon.LAT); + // cut away the latitude part when parsing the longitude + final ResultWrapper longitudeWrapper = parseHelper(text.substring(latitudeWrapper.matcherPos + latitudeWrapper.matcherLength), LatLon.LON); + + if (longitudeWrapper.matcherPos - (latitudeWrapper.matcherPos + latitudeWrapper.matcherLength) >= 10) { + throw new Geopoint.ParseException("Distance between latitude and longitude text is to large.", LatLon.LON); + } + + final double lat = latitudeWrapper.result; + final double lon = longitudeWrapper.result; + if (!Geopoint.isValidLatitude(lat)) { + throw new Geopoint.ParseException(text, LatLon.LAT); + } + if (!Geopoint.isValidLongitude(lon)) { + throw new Geopoint.ParseException(text, LatLon.LON); + } + return new Geopoint(lat, lon); + } + + /** + * Helper for coordinates-parsing + * + * @param text + * @param latlon + * @return + */ + private static ResultWrapper parseHelper(final String text, final LatLon latlon) { + + MatcherWrapper matcher = new MatcherWrapper(PATTERN_BAD_BLANK, text); + String replaceSpaceAfterComma = matcher.replaceAll("$1.$2"); + + final Pattern pattern = LatLon.LAT == latlon ? PATTERN_LAT : PATTERN_LON; + matcher = new MatcherWrapper(pattern, replaceSpaceAfterComma); + + try { + return new ResultWrapper(Double.valueOf(replaceSpaceAfterComma), 0, text.length()); + } catch (NumberFormatException ignored) { + // fall through to advanced parsing + } + + if (matcher.find()) { + final double sign = matcher.group(1).equalsIgnoreCase("S") || matcher.group(1).equalsIgnoreCase("W") ? -1.0 : 1.0; + final double degree = Integer.valueOf(matcher.group(2)).doubleValue(); + + double minutes = 0.0; + double seconds = 0.0; + + if (null != matcher.group(3)) { + minutes = Integer.valueOf(matcher.group(3)).doubleValue(); + + if (null != matcher.group(4)) { + seconds = Double.parseDouble("0." + matcher.group(4)) * 60.0; + } else if (null != matcher.group(5)) { + seconds = Double.parseDouble(matcher.group(5).replace(",", ".")); + } + } + + return new ResultWrapper(sign * (degree + minutes / 60.0 + seconds / 3600.0), matcher.start(), matcher.group().length()); + + } + + // Nothing found with "N 52...", try to match string as decimal degree parts (i.e. multiple doubles) + try { + final String[] items = StringUtils.split(text.trim()); + if (items.length > 0 && items.length <= 2) { + final int index = (latlon == LatLon.LON ? items.length - 1 : 0); + final String textPart = items[index]; + final int pos = (latlon == LatLon.LON ? text.lastIndexOf(textPart) : text.indexOf(textPart)); + return new ResultWrapper(Double.parseDouble(textPart), pos, textPart.length()); + } + } catch (NumberFormatException ignored) { + // The right exception will be raised below. + } + + throw new Geopoint.ParseException("Could not parse coordinates as " + latlon + ": \"" + text + "\"", latlon); + } + + /** + * Parses latitude out of a given string. + * + * @see #parse(String) + * @param text + * the string to be parsed + * @return the latitude as decimal degree + * @throws Geopoint.ParseException + * if latitude could not be parsed + */ + public static double parseLatitude(final String text) { + return parseHelper(text, LatLon.LAT).result; + } + + /** + * Parses longitude out of a given string. + * + * @see #parse(String) + * @param text + * the string to be parsed + * @return the longitude as decimal degree + * @throws Geopoint.ParseException + * if longitude could not be parsed + */ + public static double parseLongitude(final String text) { + return parseHelper(text, LatLon.LON).result; + } +} diff --git a/main/src/cgeo/geocaching/location/IConversion.java b/main/src/cgeo/geocaching/location/IConversion.java new file mode 100644 index 0000000..f7f0e36 --- /dev/null +++ b/main/src/cgeo/geocaching/location/IConversion.java @@ -0,0 +1,13 @@ +package cgeo.geocaching.location; + +public interface IConversion { + public static final float MILES_TO_KILOMETER = 1.609344f; + public static final float FEET_TO_KILOMETER = 0.0003048f; + public static final float YARDS_TO_KILOMETER = 0.0009144f; + /** + * Factor used to calculate distance from meters to foot; + *

+ * ft = m * METERS_TO_FEET; + */ + public static final double METERS_TO_FEET = 3.2808399d; +} diff --git a/main/src/cgeo/geocaching/location/Units.java b/main/src/cgeo/geocaching/location/Units.java new file mode 100644 index 0000000..511537a --- /dev/null +++ b/main/src/cgeo/geocaching/location/Units.java @@ -0,0 +1,62 @@ +package cgeo.geocaching.location; + +import cgeo.geocaching.settings.Settings; + +import org.apache.commons.lang3.tuple.ImmutablePair; + +import java.util.Locale; + +public class Units { + + public static ImmutablePair scaleDistance(final double distanceKilometers) { + double distance; + String units; + if (Settings.useImperialUnits()) { + distance = distanceKilometers / IConversion.MILES_TO_KILOMETER; + if (distance >= 0.1) { + units = "mi"; + } else { + distance *= 5280; + units = "ft"; + } + } else { + if (distanceKilometers >= 1) { + distance = distanceKilometers; + units = "km"; + } else { + distance = distanceKilometers * 1000; + units = "m"; + } + } + return new ImmutablePair<>(distance, units); + } + + public static String getDistanceFromKilometers(final Float distanceKilometers) { + if (distanceKilometers == null) { + return "?"; + } + + final ImmutablePair scaled = scaleDistance(distanceKilometers); + String formatString; + if (scaled.left >= 100) { + formatString = "%.0f"; + } else if (scaled.left >= 10) { + formatString = "%.1f"; + } else { + formatString = "%.2f"; + } + + return String.format(formatString + " %s", scaled.left, scaled.right); + } + + public static String getDistanceFromMeters(float meters) { + return getDistanceFromKilometers(meters / 1000f); + } + + public static String getSpeed(final float kilometersPerHour) { + if (Settings.useImperialUnits()) { + return String.format(Locale.US, "%.0f mph", kilometersPerHour / IConversion.MILES_TO_KILOMETER); + } + return String.format(Locale.US, "%.0f km/h", kilometersPerHour); + } +} diff --git a/main/src/cgeo/geocaching/location/Viewport.java b/main/src/cgeo/geocaching/location/Viewport.java new file mode 100644 index 0000000..e482828 --- /dev/null +++ b/main/src/cgeo/geocaching/location/Viewport.java @@ -0,0 +1,192 @@ +package cgeo.geocaching.location; + +import cgeo.geocaching.ICoordinates; + +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.jdt.annotation.Nullable; + +import java.util.Collection; + +public final class Viewport { + + public final @NonNull Geopoint center; + public final @NonNull Geopoint bottomLeft; + public final @NonNull Geopoint topRight; + + public Viewport(final @NonNull ICoordinates point1, final @NonNull ICoordinates point2) { + final Geopoint gp1 = point1.getCoords(); + final Geopoint gp2 = point2.getCoords(); + this.bottomLeft = new Geopoint(Math.min(gp1.getLatitude(), gp2.getLatitude()), + Math.min(gp1.getLongitude(), gp2.getLongitude())); + this.topRight = new Geopoint(Math.max(gp1.getLatitude(), gp2.getLatitude()), + Math.max(gp1.getLongitude(), gp2.getLongitude())); + this.center = new Geopoint((gp1.getLatitude() + gp2.getLatitude()) / 2, + (gp1.getLongitude() + gp2.getLongitude()) / 2); + } + + public Viewport(final @NonNull ICoordinates center, final double latSpan, final double lonSpan) { + this.center = center.getCoords(); + final double centerLat = this.center.getLatitude(); + final double centerLon = this.center.getLongitude(); + final double latHalfSpan = Math.abs(latSpan) / 2; + final double lonHalfSpan = Math.abs(lonSpan) / 2; + bottomLeft = new Geopoint(centerLat - latHalfSpan, centerLon - lonHalfSpan); + topRight = new Geopoint(centerLat + latHalfSpan, centerLon + lonHalfSpan); + } + + public double getLatitudeMin() { + return bottomLeft.getLatitude(); + } + + public double getLatitudeMax() { + return topRight.getLatitude(); + } + + public double getLongitudeMin() { + return bottomLeft.getLongitude(); + } + + public double getLongitudeMax() { + return topRight.getLongitude(); + } + + public @NonNull + Geopoint getCenter() { + return center; + } + + public double getLatitudeSpan() { + return getLatitudeMax() - getLatitudeMin(); + } + + public double getLongitudeSpan() { + return getLongitudeMax() - getLongitudeMin(); + } + + /** + * Check whether a point is contained in this viewport. + * + * @param point + * the coordinates to check + * @return true if the point is contained in this viewport, false otherwise or if the point contains no coordinates + */ + public boolean contains(final @NonNull ICoordinates point) { + final Geopoint coords = point.getCoords(); + return coords != null + && coords.getLongitudeE6() >= bottomLeft.getLongitudeE6() + && coords.getLongitudeE6() <= topRight.getLongitudeE6() + && coords.getLatitudeE6() >= bottomLeft.getLatitudeE6() + && coords.getLatitudeE6() <= topRight.getLatitudeE6(); + } + + /** + * Count the number of points present in the viewport. + * + * @param points a collection of (possibly null) points + * @return the number of non-null points in the viewport + */ + public int count(final @NonNull Collection points) { + int total = 0; + for (ICoordinates point: points) { + if (point != null && contains(point)) { + total += 1; + } + } + return total; + } + + @Override + public String toString() { + return "(" + bottomLeft.toString() + "," + topRight.toString() + ")"; + } + + /** + * Check whether another viewport is fully included into the current one. + * + * @param vp + * the other viewport + * @return true if the viewport is fully included into this one, false otherwise + */ + public boolean includes(final @NonNull Viewport vp) { + return contains(vp.bottomLeft) && contains(vp.topRight); + } + + /** + * Return the "where" part of the string appropriate for a SQL query. + * + * @param dbTable + * the database table to use as prefix, or null if no prefix is required + * @return the string without the "where" keyword + */ + public StringBuilder sqlWhere(@Nullable final String dbTable) { + final String prefix = dbTable == null ? "" : (dbTable + "."); + return new StringBuilder(prefix).append("latitude >= ").append(getLatitudeMin()).append(" and ") + .append(prefix).append("latitude <= ").append(getLatitudeMax()).append(" and ") + .append(prefix).append("longitude >= ").append(getLongitudeMin()).append(" and ") + .append(prefix).append("longitude <= ").append(getLongitudeMax()); + } + + /** + * Return a widened or shrunk viewport. + * + * @param factor + * multiplicative factor for the latitude and longitude span (> 1 to widen, < 1 to shrink) + * @return a widened or shrunk viewport + */ + public @NonNull + Viewport resize(final double factor) { + return new Viewport(getCenter(), getLatitudeSpan() * factor, getLongitudeSpan() * factor); + } + + /** + * Return the smallest viewport containing all the given points. + * + * @param points + * a set of points. Point with null coordinates (or null themselves) will be ignored + * @return the smallest viewport containing the non-null coordinates, or null if no coordinates are non-null + */ + static public @Nullable + Viewport containing(final Collection points) { + boolean valid = false; + double latMin = Double.MAX_VALUE; + double latMax = -Double.MAX_VALUE; + double lonMin = Double.MAX_VALUE; + double lonMax = -Double.MAX_VALUE; + for (final ICoordinates point : points) { + if (point != null) { + final Geopoint coords = point.getCoords(); + if (coords != null) { + valid = true; + final double latitude = coords.getLatitude(); + final double longitude = coords.getLongitude(); + latMin = Math.min(latMin, latitude); + latMax = Math.max(latMax, latitude); + lonMin = Math.min(lonMin, longitude); + lonMax = Math.max(lonMax, longitude); + } + } + } + if (!valid) { + return null; + } + return new Viewport(new Geopoint(latMin, lonMin), new Geopoint(latMax, lonMax)); + } + + @Override + public boolean equals(final Object other) { + if (this == other) { + return true; + } + if (!(other instanceof Viewport)) { + return false; + } + final Viewport vp = (Viewport) other; + return bottomLeft.equals(vp.bottomLeft) && topRight.equals(vp.topRight); + } + + @Override + public int hashCode() { + return bottomLeft.hashCode() ^ topRight.hashCode(); + } + +} diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java index 25d4785..0f3337c 100644 --- a/main/src/cgeo/geocaching/maps/CGeoMap.java +++ b/main/src/cgeo/geocaching/maps/CGeoMap.java @@ -20,9 +20,9 @@ import cgeo.geocaching.enumerations.LiveMapStrategy.Strategy; import cgeo.geocaching.enumerations.LoadFlags; import cgeo.geocaching.enumerations.LoadFlags.RemoveFlag; import cgeo.geocaching.enumerations.WaypointType; -import cgeo.geocaching.geopoint.Geopoint; -import cgeo.geocaching.geopoint.Viewport; import cgeo.geocaching.list.StoredList; +import cgeo.geocaching.location.Geopoint; +import cgeo.geocaching.location.Viewport; import cgeo.geocaching.maps.interfaces.CachesOverlayItemImpl; import cgeo.geocaching.maps.interfaces.GeoPointImpl; import cgeo.geocaching.maps.interfaces.MapActivityImpl; diff --git a/main/src/cgeo/geocaching/maps/CachesOverlay.java b/main/src/cgeo/geocaching/maps/CachesOverlay.java index 3c6109e..96912ab 100644 --- a/main/src/cgeo/geocaching/maps/CachesOverlay.java +++ b/main/src/cgeo/geocaching/maps/CachesOverlay.java @@ -10,7 +10,7 @@ import cgeo.geocaching.activity.Progress; import cgeo.geocaching.connector.gc.GCMap; import cgeo.geocaching.enumerations.CacheType; import cgeo.geocaching.enumerations.LoadFlags; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.maps.interfaces.CachesOverlayItemImpl; import cgeo.geocaching.maps.interfaces.GeoPointImpl; import cgeo.geocaching.maps.interfaces.ItemizedOverlayImpl; diff --git a/main/src/cgeo/geocaching/maps/PositionDrawer.java b/main/src/cgeo/geocaching/maps/PositionDrawer.java index 08244ef..6a45e62 100644 --- a/main/src/cgeo/geocaching/maps/PositionDrawer.java +++ b/main/src/cgeo/geocaching/maps/PositionDrawer.java @@ -2,7 +2,7 @@ package cgeo.geocaching.maps; import cgeo.geocaching.CgeoApplication; import cgeo.geocaching.R; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.maps.interfaces.GeoPointImpl; import cgeo.geocaching.maps.interfaces.MapItemFactory; import cgeo.geocaching.maps.interfaces.MapProjectionImpl; diff --git a/main/src/cgeo/geocaching/maps/ScaleDrawer.java b/main/src/cgeo/geocaching/maps/ScaleDrawer.java index 95c987d..04398b4 100644 --- a/main/src/cgeo/geocaching/maps/ScaleDrawer.java +++ b/main/src/cgeo/geocaching/maps/ScaleDrawer.java @@ -1,8 +1,8 @@ package cgeo.geocaching.maps; import cgeo.geocaching.CgeoApplication; -import cgeo.geocaching.geopoint.Geopoint; -import cgeo.geocaching.geopoint.Units; +import cgeo.geocaching.location.Geopoint; +import cgeo.geocaching.location.Units; import cgeo.geocaching.maps.interfaces.GeoPointImpl; import cgeo.geocaching.maps.interfaces.MapViewImpl; diff --git a/main/src/cgeo/geocaching/maps/google/v1/GoogleGeoPoint.java b/main/src/cgeo/geocaching/maps/google/v1/GoogleGeoPoint.java index 2f540ad..7fbfac2 100644 --- a/main/src/cgeo/geocaching/maps/google/v1/GoogleGeoPoint.java +++ b/main/src/cgeo/geocaching/maps/google/v1/GoogleGeoPoint.java @@ -1,6 +1,6 @@ package cgeo.geocaching.maps.google.v1; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.maps.interfaces.GeoPointImpl; import com.google.android.maps.GeoPoint; diff --git a/main/src/cgeo/geocaching/maps/google/v1/GoogleMapItemFactory.java b/main/src/cgeo/geocaching/maps/google/v1/GoogleMapItemFactory.java index d7e9380..5fedf69 100644 --- a/main/src/cgeo/geocaching/maps/google/v1/GoogleMapItemFactory.java +++ b/main/src/cgeo/geocaching/maps/google/v1/GoogleMapItemFactory.java @@ -1,7 +1,7 @@ package cgeo.geocaching.maps.google.v1; import cgeo.geocaching.IWaypoint; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.maps.interfaces.CachesOverlayItemImpl; import cgeo.geocaching.maps.interfaces.GeoPointImpl; import cgeo.geocaching.maps.interfaces.MapItemFactory; diff --git a/main/src/cgeo/geocaching/maps/google/v1/GoogleMapView.java b/main/src/cgeo/geocaching/maps/google/v1/GoogleMapView.java index b07f561..d474e1d 100644 --- a/main/src/cgeo/geocaching/maps/google/v1/GoogleMapView.java +++ b/main/src/cgeo/geocaching/maps/google/v1/GoogleMapView.java @@ -2,7 +2,7 @@ package cgeo.geocaching.maps.google.v1; import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; -import cgeo.geocaching.geopoint.Viewport; +import cgeo.geocaching.location.Viewport; import cgeo.geocaching.maps.CachesOverlay; import cgeo.geocaching.maps.PositionAndScaleOverlay; import cgeo.geocaching.maps.interfaces.GeneralOverlay; diff --git a/main/src/cgeo/geocaching/maps/interfaces/MapItemFactory.java b/main/src/cgeo/geocaching/maps/interfaces/MapItemFactory.java index 22c6698..f69de03 100644 --- a/main/src/cgeo/geocaching/maps/interfaces/MapItemFactory.java +++ b/main/src/cgeo/geocaching/maps/interfaces/MapItemFactory.java @@ -1,7 +1,7 @@ package cgeo.geocaching.maps.interfaces; import cgeo.geocaching.IWaypoint; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; public interface MapItemFactory { diff --git a/main/src/cgeo/geocaching/maps/interfaces/MapViewImpl.java b/main/src/cgeo/geocaching/maps/interfaces/MapViewImpl.java index 4a6d733..0560ad4 100644 --- a/main/src/cgeo/geocaching/maps/interfaces/MapViewImpl.java +++ b/main/src/cgeo/geocaching/maps/interfaces/MapViewImpl.java @@ -1,6 +1,6 @@ package cgeo.geocaching.maps.interfaces; -import cgeo.geocaching.geopoint.Viewport; +import cgeo.geocaching.location.Viewport; import cgeo.geocaching.maps.CachesOverlay; import cgeo.geocaching.maps.PositionAndScaleOverlay; diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeGeoPoint.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeGeoPoint.java index 197bd76..298cb90 100644 --- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeGeoPoint.java +++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeGeoPoint.java @@ -1,6 +1,6 @@ package cgeo.geocaching.maps.mapsforge; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.maps.interfaces.GeoPointImpl; import org.mapsforge.core.GeoPoint; diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapItemFactory.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapItemFactory.java index 4ade09c..ccfd023 100644 --- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapItemFactory.java +++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapItemFactory.java @@ -1,7 +1,7 @@ package cgeo.geocaching.maps.mapsforge; import cgeo.geocaching.IWaypoint; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.maps.interfaces.CachesOverlayItemImpl; import cgeo.geocaching.maps.interfaces.GeoPointImpl; import cgeo.geocaching.maps.interfaces.MapItemFactory; diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapView.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapView.java index 81dafb4..73d87b0 100644 --- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapView.java +++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapView.java @@ -1,7 +1,7 @@ package cgeo.geocaching.maps.mapsforge; import cgeo.geocaching.R; -import cgeo.geocaching.geopoint.Viewport; +import cgeo.geocaching.location.Viewport; import cgeo.geocaching.maps.CachesOverlay; import cgeo.geocaching.maps.PositionAndScaleOverlay; import cgeo.geocaching.maps.interfaces.GeneralOverlay; diff --git a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeGeoPoint.java b/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeGeoPoint.java index c801e3f..72aceb0 100644 --- a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeGeoPoint.java +++ b/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeGeoPoint.java @@ -1,6 +1,6 @@ package cgeo.geocaching.maps.mapsforge.v024; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.maps.interfaces.GeoPointImpl; import org.mapsforge.android.mapsold.GeoPoint; diff --git a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapItemFactory024.java b/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapItemFactory024.java index 4f1d34c..23d94d9 100644 --- a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapItemFactory024.java +++ b/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapItemFactory024.java @@ -1,7 +1,7 @@ package cgeo.geocaching.maps.mapsforge.v024; import cgeo.geocaching.IWaypoint; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.maps.interfaces.CachesOverlayItemImpl; import cgeo.geocaching.maps.interfaces.GeoPointImpl; import cgeo.geocaching.maps.interfaces.MapItemFactory; diff --git a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapView024.java b/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapView024.java index 8dd15fc..42c55fe 100644 --- a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapView024.java +++ b/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapView024.java @@ -1,7 +1,7 @@ package cgeo.geocaching.maps.mapsforge.v024; import cgeo.geocaching.R; -import cgeo.geocaching.geopoint.Viewport; +import cgeo.geocaching.location.Viewport; import cgeo.geocaching.maps.CachesOverlay; import cgeo.geocaching.maps.PositionAndScaleOverlay; import cgeo.geocaching.maps.interfaces.GeneralOverlay; diff --git a/main/src/cgeo/geocaching/sensors/GeoData.java b/main/src/cgeo/geocaching/sensors/GeoData.java index 13f5450..a7dc03d 100644 --- a/main/src/cgeo/geocaching/sensors/GeoData.java +++ b/main/src/cgeo/geocaching/sensors/GeoData.java @@ -1,7 +1,7 @@ package cgeo.geocaching.sensors; import cgeo.geocaching.enumerations.LocationProviderType; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.utils.Log; import org.eclipse.jdt.annotation.Nullable; diff --git a/main/src/cgeo/geocaching/sensors/IGeoData.java b/main/src/cgeo/geocaching/sensors/IGeoData.java index b78b805..e6b7685 100644 --- a/main/src/cgeo/geocaching/sensors/IGeoData.java +++ b/main/src/cgeo/geocaching/sensors/IGeoData.java @@ -1,7 +1,7 @@ package cgeo.geocaching.sensors; import cgeo.geocaching.enumerations.LocationProviderType; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import android.location.Location; diff --git a/main/src/cgeo/geocaching/settings/Settings.java b/main/src/cgeo/geocaching/settings/Settings.java index a3421cb..241d036 100644 --- a/main/src/cgeo/geocaching/settings/Settings.java +++ b/main/src/cgeo/geocaching/settings/Settings.java @@ -9,8 +9,8 @@ import cgeo.geocaching.connector.gc.GCConstants; import cgeo.geocaching.enumerations.CacheType; import cgeo.geocaching.enumerations.LiveMapStrategy.Strategy; import cgeo.geocaching.enumerations.LogType; -import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.list.StoredList; +import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.maps.CGeoMap.MapMode; import cgeo.geocaching.maps.MapProviderFactory; import cgeo.geocaching.maps.google.v1.GoogleMapProvider; diff --git a/main/src/cgeo/geocaching/sorting/DistanceComparator.java b/main/src/cgeo/geocaching/sorting/DistanceComparator.java index 3da5736..f400583 100644 --- a/main/src/cgeo/geocaching/sorting/DistanceComparator.java +++ b/main/src/cgeo/geocaching/sorting/DistanceComparator.java @@ -1,7 +1,7 @@ package cgeo.geocaching.sorting; import cgeo.geocaching.Geocache; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import java.util.ArrayList; import java.util.List; diff --git a/main/src/cgeo/geocaching/speech/SpeechService.java b/main/src/cgeo/geocaching/speech/SpeechService.java index 11e10c1..4eb50e3 100644 --- a/main/src/cgeo/geocaching/speech/SpeechService.java +++ b/main/src/cgeo/geocaching/speech/SpeechService.java @@ -3,7 +3,7 @@ package cgeo.geocaching.speech; import cgeo.geocaching.Intents; import cgeo.geocaching.R; import cgeo.geocaching.activity.ActivityMixin; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.sensors.GeoDirHandler; import cgeo.geocaching.sensors.IGeoData; import cgeo.geocaching.settings.Settings; diff --git a/main/src/cgeo/geocaching/speech/TextFactory.java b/main/src/cgeo/geocaching/speech/TextFactory.java index 4b87f1a..4d59b72 100644 --- a/main/src/cgeo/geocaching/speech/TextFactory.java +++ b/main/src/cgeo/geocaching/speech/TextFactory.java @@ -2,8 +2,8 @@ package cgeo.geocaching.speech; import cgeo.geocaching.CgeoApplication; import cgeo.geocaching.R; -import cgeo.geocaching.geopoint.Geopoint; -import cgeo.geocaching.geopoint.IConversion; +import cgeo.geocaching.location.Geopoint; +import cgeo.geocaching.location.IConversion; import cgeo.geocaching.settings.Settings; import cgeo.geocaching.utils.AngleUtils; diff --git a/main/src/cgeo/geocaching/twitter/Twitter.java b/main/src/cgeo/geocaching/twitter/Twitter.java index 253d91f..c6f4ee6 100644 --- a/main/src/cgeo/geocaching/twitter/Twitter.java +++ b/main/src/cgeo/geocaching/twitter/Twitter.java @@ -6,8 +6,8 @@ import cgeo.geocaching.Geocache; import cgeo.geocaching.LogEntry; import cgeo.geocaching.Trackable; import cgeo.geocaching.enumerations.LoadFlags; -import cgeo.geocaching.geopoint.Geopoint; -import cgeo.geocaching.geopoint.GeopointFormatter.Format; +import cgeo.geocaching.location.Geopoint; +import cgeo.geocaching.location.GeopointFormatter.Format; import cgeo.geocaching.network.Network; import cgeo.geocaching.network.OAuth; import cgeo.geocaching.network.OAuthTokens; diff --git a/main/src/cgeo/geocaching/ui/AddressListAdapter.java b/main/src/cgeo/geocaching/ui/AddressListAdapter.java index 81b6c23..691c8d2 100644 --- a/main/src/cgeo/geocaching/ui/AddressListAdapter.java +++ b/main/src/cgeo/geocaching/ui/AddressListAdapter.java @@ -5,8 +5,8 @@ import butterknife.InjectView; import cgeo.geocaching.CacheListActivity; import cgeo.geocaching.CgeoApplication; import cgeo.geocaching.R; -import cgeo.geocaching.geopoint.Geopoint; -import cgeo.geocaching.geopoint.Units; +import cgeo.geocaching.location.Geopoint; +import cgeo.geocaching.location.Units; import org.apache.commons.lang3.StringUtils; diff --git a/main/src/cgeo/geocaching/ui/CacheDetailsCreator.java b/main/src/cgeo/geocaching/ui/CacheDetailsCreator.java index 7db3592..1834b4e 100644 --- a/main/src/cgeo/geocaching/ui/CacheDetailsCreator.java +++ b/main/src/cgeo/geocaching/ui/CacheDetailsCreator.java @@ -7,7 +7,7 @@ import cgeo.geocaching.Geocache; import cgeo.geocaching.R; import cgeo.geocaching.Waypoint; import cgeo.geocaching.connector.ConnectorFactory; -import cgeo.geocaching.geopoint.Units; +import cgeo.geocaching.location.Units; import cgeo.geocaching.utils.Formatter; import org.apache.commons.lang3.StringUtils; diff --git a/main/src/cgeo/geocaching/ui/CacheListAdapter.java b/main/src/cgeo/geocaching/ui/CacheListAdapter.java index 8cb2177..ae449ec 100644 --- a/main/src/cgeo/geocaching/ui/CacheListAdapter.java +++ b/main/src/cgeo/geocaching/ui/CacheListAdapter.java @@ -9,7 +9,7 @@ import cgeo.geocaching.R; import cgeo.geocaching.enumerations.CacheListType; import cgeo.geocaching.enumerations.CacheType; import cgeo.geocaching.filter.IFilter; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.sensors.IGeoData; import cgeo.geocaching.settings.Settings; import cgeo.geocaching.sorting.CacheComparator; diff --git a/main/src/cgeo/geocaching/ui/CompassMiniView.java b/main/src/cgeo/geocaching/ui/CompassMiniView.java index 50823fd..a811fa0 100644 --- a/main/src/cgeo/geocaching/ui/CompassMiniView.java +++ b/main/src/cgeo/geocaching/ui/CompassMiniView.java @@ -1,7 +1,7 @@ package cgeo.geocaching.ui; import cgeo.geocaching.R; -import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.location.Geopoint; import cgeo.geocaching.settings.Settings; import cgeo.geocaching.utils.AngleUtils; diff --git a/main/src/cgeo/geocaching/ui/CoordinatesFormatSwitcher.java b/main/src/cgeo/geocaching/ui/CoordinatesFormatSwitcher.java index 299256c..581942a 100644 --- a/main/src/cgeo/geocaching/ui/CoordinatesFormatSwitcher.java +++ b/main/src/cgeo/geocaching/ui/CoordinatesFormatSwitcher.java @@ -1,7 +1,7 @@ package cgeo.geocaching.ui; -import cgeo.geocaching.geopoint.Geopoint; -import cgeo.geocaching.geopoint.GeopointFormatter; +import cgeo.geocaching.location.Geopoint; +import cgeo.geocaching.location.GeopointFormatter; import android.view.View; import android.view.View.OnClickListener; diff --git a/main/src/cgeo/geocaching/ui/DistanceView.java b/main/src/cgeo/geocaching/ui/DistanceView.java index a61fc4d..b5e47e1 100644 --- a/main/src/cgeo/geocaching/ui/DistanceView.java +++ b/main/src/cgeo/geocaching/ui/DistanceView.java @@ -1,7 +1,7 @@ package cgeo.geocaching.ui; -import cgeo.geocaching.geopoint.Geopoint; -import cgeo.geocaching.geopoint.Units; +import cgeo.geocaching.location.Geopoint; +import cgeo.geocaching.location.Units; import org.eclipse.jdt.annotation.NonNull; diff --git a/main/src/cgeo/geocaching/ui/dialog/CoordinatesInputDialog.java b/main/src/cgeo/geocaching/ui/dialog/CoordinatesInputDialog.java index 283b7fd..cc3bff5 100644 --- a/main/src/cgeo/geocaching/ui/dialog/CoordinatesInputDialog.java +++ b/main/src/cgeo/geocaching/ui/dialog/CoordinatesInputDialog.java @@ -6,9 +6,9 @@ import cgeo.geocaching.Geocache; import cgeo.geocaching.R; import cgeo.geocaching.activity.AbstractActivity; import cgeo.geocaching.activity.Keyboard; -import cgeo.geocaching.geopoint.Geopoint; -import cgeo.geocaching.geopoint.Geopoint.ParseException; -import cgeo.geocaching.geopoint.GeopointFormatter; +import cgeo.geocaching.location.Geopoint; +import cgeo.geocaching.location.GeopointFormatter; +import cgeo.geocaching.location.Geopoint.ParseException; import cgeo.geocaching.sensors.IGeoData; import cgeo.geocaching.settings.Settings; import cgeo.geocaching.settings.Settings.CoordInputFormatEnum; -- cgit v1.1