Class 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 string
      QRLocation​(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 formula
      double getLatitude()
      Retrieve the latitude
      java.lang.String getLocationString()
      Converts the Location object to a string that can be stored on Firebase
      double getLongitude()
      Retrieve the longitude
      java.lang.String getRegion()
      Retrieve the region
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 region
        location - Location object
      • QRLocation

        public QRLocation​(java.lang.String region,
                          double lat,
                          double lon)
        Creates a QRLocation object from a set of coordinates.
        Parameters:
        region - region
        lat - Latitude
        lon - 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 formula

        Adapted 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)