Package com.cmput301w23t09.qrhunter.map
Class QRLocation
- java.lang.Object
-
- com.cmput301w23t09.qrhunter.map.QRLocation
-
- All Implemented Interfaces:
java.io.Serializable
public class QRLocation extends java.lang.Object implements java.io.Serializable
Holds a QR code's location, created from a location string stored in the database- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description QRLocation(java.lang.String locStr)
Creates a QRLocation object based on a location stringQRLocation(java.lang.String region, double lat, double lon)
Creates a QRLocation object from a set of coordinates.QRLocation(java.lang.String region, android.location.Location location)
Creates a QRLocation object based on an existing location object
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
distanceTo(QRLocation other)
Calculates distance between this QRLocation and another QRLocation using Haversine's formuladouble
getLatitude()
Retrieve the latitudejava.lang.String
getLocationString()
Converts the Location object to a string that can be stored on Firebasedouble
getLongitude()
Retrieve the longitudejava.lang.String
getRegion()
Retrieve the region
-
-
-
Constructor Detail
-
QRLocation
public QRLocation(java.lang.String locStr)
Creates a QRLocation object based on a location string- Parameters:
locStr
- Location string
-
QRLocation
public QRLocation(java.lang.String region, android.location.Location location)
Creates a QRLocation object based on an existing location object- Parameters:
region
- Name of the regionlocation
- Location object
-
QRLocation
public QRLocation(java.lang.String region, double lat, double lon)
Creates a QRLocation object from a set of coordinates.- Parameters:
region
- regionlat
- Latitudelon
- Longitude
-
-
Method Detail
-
getLocationString
public java.lang.String getLocationString()
Converts the Location object to a string that can be stored on Firebase- Returns:
- A string in the format "latitude;longitude"
-
getLatitude
public double getLatitude()
Retrieve the latitude- Returns:
- Returns QRLocation's latitude
-
getLongitude
public double getLongitude()
Retrieve the longitude- Returns:
- Returns QRLocation's longitude
-
getRegion
public java.lang.String getRegion()
Retrieve the region- Returns:
- region
-
distanceTo
public double distanceTo(QRLocation other)
Calculates distance between this QRLocation and another QRLocation using Haversine's formulaAdapted From: https://stackoverflow.com/a/27943 By: user1921 (no longer exists) (2008-08-26) Edited By: Deduplicator (https://stackoverflow.com/users/3204551/deduplicator) (2014-07-31) License: CC BY-SA
- Parameters:
other
- The other QRLocation to calculate distance to- Returns:
- The distance between this and other (in metres)
-
-