DiscoverTenerife
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
gpsController Class Reference

class that handles the access to the GPS sensor of the current dispositive. This class follows the singleton pattern, so its only one instance during each excecution. More...

Inheritance diagram for gpsController:

Public Member Functions

double getLatitude ()
 getter of the latitude_ property. More...
 
double getLongitude ()
 getter of the longitude_ property. More...
 
double getAltitude ()
 getter of the altitude_ property. More...
 
double CalculateDistance (double latitudeA, double longitudeA, double latitudeB, double longitudeB)
 this method returns the distance between the two geographical points given on the choosen distance. It expects that the given parameters are on Hexadecimal notation, it converts them on sexagecimal using the sexagecimalToRadian method. It checks the distanceInKM method of optionsController class to choose on which unit it has to return the distance. More...
 
double CalculateDistanceToUser (double latitudeA, double longitudeA)
 it calls the CalculateDistance method with the given coordenades and the user current coordenades. More...
 
string getcurrentZoneOfUser ()
 it calls the getZoneOf method with the user coordenades and returns what that method returns. More...
 
bool gpsIsRunning ()
 getter of the gpsIsRunning_ property. More...
 

Static Public Attributes

static gpsController gpsControllerInstance_
 reference to the gpsController instance More...
 

Private Member Functions

void Awake ()
 
void CreatePermissionList ()
 
void AskForPermissions ()
 
void OnApplicationFocus (bool focus)
 this method is called each time the application either focus in or focus out. If the application is focusing in and the isItPermissionTime property is true it calls the AskForPermissions method. If the application is focusing in it starts the Input.Location process. If the application is focusing out it stops the Input.Location process. More...
 
void Update ()
 
double sexagecimalToRadian (double sexagecimal)
 this method converts the given sexagecimal number to his radian number equivalent. More...
 

Private Attributes

bool isItPermissionTime
 true if its time to ask permission, false in other case More...
 
Stack< string > permissions
 Stack<string> that contains all the permissions we have to ask. More...
 
bool gpsIsRunning_
 true if the gps is avaible, false in other case. More...
 
double longitude_
 double that stores the longitude number of the current user current gps location. More...
 
double latitude_
 double that stores the latitude number of the current user current gps location. More...
 
double altitude_
 double that stores the altitude number of the current user current gps location. More...
 
double defaultLatitude_ = 0
 double that stores the default value for the latitude part of the user coordenades More...
 
double defaultLongitude_ = 0
 double that stores the default value for the longitude part of the user coordenades More...
 
double defaultAltitude_ = 255
 double that stores the default value for the altitude part of the user coordenades More...
 

Detailed Description

class that handles the access to the GPS sensor of the current dispositive. This class follows the singleton pattern, so its only one instance during each excecution.

Member Function Documentation

◆ AskForPermissions()

void gpsController.AskForPermissions ( )
private

This method if the permissions stack property is empty, it calls the CreatePermissionList first. In other case, ask for each permission that is on the permissions property. When it finish, it sets the isItPermissionTime to false.

◆ Awake()

void gpsController.Awake ( )
private

This method is called before the first frame. If there is another gpsController, it destroy this instance and return nothing. Other case, it set the gpsControllerInstance_ static property as a reference of this gameObject. It also instantiate the rest of the properties, calls the CreatePermissionList method and start the gps location process.

◆ CalculateDistance()

double gpsController.CalculateDistance ( double  latitudeA,
double  longitudeA,
double  latitudeB,
double  longitudeB 
)

this method returns the distance between the two geographical points given on the choosen distance. It expects that the given parameters are on Hexadecimal notation, it converts them on sexagecimal using the sexagecimalToRadian method. It checks the distanceInKM method of optionsController class to choose on which unit it has to return the distance.

Parameters
doublethat contains the latitude of the first point.
doublethat contains the longitude of the first point.
doublethat contains the latitude of the second point.
doublethat contains the longitude of the second point.
Returns
double the distance on the choosen unit.

◆ CalculateDistanceToUser()

double gpsController.CalculateDistanceToUser ( double  latitudeA,
double  longitudeA 
)

it calls the CalculateDistance method with the given coordenades and the user current coordenades.

Parameters
doublethat contains the latitude of the point.
doublethat contains the longitude of the point.
Returns
double that contains the distance between the user and the given point on the choosen unit.

◆ CreatePermissionList()

void gpsController.CreatePermissionList ( )
private

This method set the isItPermissionTime attribute as true, add both the CoarseLocation and the FineLocation permissions to the permissions property, and then, call the AskForPermissions method of gpsController.

◆ getAltitude()

double gpsController.getAltitude ( )

getter of the altitude_ property.

Returns
the altitude_ property value.

◆ getcurrentZoneOfUser()

string gpsController.getcurrentZoneOfUser ( )

it calls the getZoneOf method with the user coordenades and returns what that method returns.

Returns
string current zone of the current user.

◆ getLatitude()

double gpsController.getLatitude ( )

getter of the latitude_ property.

Returns
the latitude_ property value.

◆ getLongitude()

double gpsController.getLongitude ( )

getter of the longitude_ property.

Returns
the longitude_ property value.

◆ gpsIsRunning()

bool gpsController.gpsIsRunning ( )

getter of the gpsIsRunning_ property.

Returns
true if the gps is running, false in other case.

◆ OnApplicationFocus()

void gpsController.OnApplicationFocus ( bool  focus)
private

this method is called each time the application either focus in or focus out. If the application is focusing in and the isItPermissionTime property is true it calls the AskForPermissions method. If the application is focusing in it starts the Input.Location process. If the application is focusing out it stops the Input.Location process.

Parameters
booltrue if the application is focusing in, false if the application is focusing out.

◆ sexagecimalToRadian()

double gpsController.sexagecimalToRadian ( double  sexagecimal)
private

this method converts the given sexagecimal number to his radian number equivalent.

Parameters
doublesexagecimal number to convert.
Returns
double radian conversion of the given number.

◆ Update()

void gpsController.Update ( )
private

This method is called on each frame.

  • If the user has given both CoarseLocation and FineLocation permissions, the gps service is active on the user's device and LocationService is running, it sets the gpsIsRunning_ property to true, gets the latitude, the longitude and the altitude of the user then it checks if the current user hasnt stablished its base, if that is the case it set the user base as the current latitude and longitude and call the writeUserData method of firebaseHandler.
  • If that is not the case, it sets the gpsIsRunning_ as false and it sets the latitude_, longitude_ and altitude_ as the default ones.

Member Data Documentation

◆ altitude_

double gpsController.altitude_
private

double that stores the altitude number of the current user current gps location.

◆ defaultAltitude_

double gpsController.defaultAltitude_ = 255
private

double that stores the default value for the altitude part of the user coordenades

◆ defaultLatitude_

double gpsController.defaultLatitude_ = 0
private

double that stores the default value for the latitude part of the user coordenades

◆ defaultLongitude_

double gpsController.defaultLongitude_ = 0
private

double that stores the default value for the longitude part of the user coordenades

◆ gpsControllerInstance_

gpsController gpsController.gpsControllerInstance_
static

reference to the gpsController instance

◆ gpsIsRunning_

bool gpsController.gpsIsRunning_
private

true if the gps is avaible, false in other case.

◆ isItPermissionTime

bool gpsController.isItPermissionTime
private

true if its time to ask permission, false in other case

◆ latitude_

double gpsController.latitude_
private

double that stores the latitude number of the current user current gps location.

◆ longitude_

double gpsController.longitude_
private

double that stores the longitude number of the current user current gps location.

◆ permissions

Stack<string> gpsController.permissions
private

Stack<string> that contains all the permissions we have to ask.


The documentation for this class was generated from the following file: