public class

GeoJsonPointLocationProvider

extends Object
implements LocationProvider
java.lang.Object
   ↳ com.steerpath.sdk.location.GeoJsonPointLocationProvider

Class Overview

Publishes Locations from given FeatureCollection. FeatureCollection must contain Points.

Useful for testing.

Summary

[Expand]
Inherited Constants
From interface com.steerpath.sdk.location.LocationProvider
Public Constructors
GeoJsonPointLocationProvider(FeatureCollection featureCollection, int intervalInMillis, boolean isLooping)
Constructor.
Public Methods
Location getLastLocation()
Retrieve the last location that the FusedLocationProvider is aware of.
String getName()
Returns the name of this LocationProvider.
Location getUserLocation()
Retrieve the current location that the FusedLocationProvider is aware of.
boolean hasUserLocation()
Check if Location of the user is currently known.
void removeLocationUpdates(LocationListener listener)
Stop listening location updates.
void requestLocationUpdates(LocationListener listener)
Start receiving location updates on the listener.
void requestLocationUpdates(LocationRequest request, LocationListener listener)
Start receiving location updates on the listener.
boolean requiresBluetooth()
Returns true if this LocationProvider depends on Bluetooth.
boolean requiresGps()
Returns true if this LocationProvider depends on GPS (Location services enabled).
static FeatureCollection toFeatureCollection(List<Location> locations)
Creates FeatureCollection from list of Locations.
static FeatureCollection toFeatureCollection(String geoJson)
Creates FeatureCollection from geojson String.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.steerpath.sdk.location.LocationProvider

Public Constructors

public GeoJsonPointLocationProvider (FeatureCollection featureCollection, int intervalInMillis, boolean isLooping)

Constructor.

Parameters
intervalInMillis update interval
isLooping true if should start from the beginning after reaching the final Feature.

Public Methods

public Location getLastLocation ()

Retrieve the last location that the FusedLocationProvider is aware of. Returns non-null object even if location has actually been lost. This method depends on requestLocationUpdates(LocationListener). If no listener is registered, positioning engine is actually stopped and getUserLocation() returns null.

Returns
  • the best location this class is aware of, or null if none is known. Returns null if permissions are not granted.

public String getName ()

Returns the name of this LocationProvider.

public Location getUserLocation ()

Retrieve the current location that the FusedLocationProvider is aware of. Returns null if location has actually been lost. This method depends on requestLocationUpdates(LocationListener). If no listener is registered, positioning engine is actually stopped and getUserLocation() returns null.

Returns
  • null if current location is lost.

public boolean hasUserLocation ()

Check if Location of the user is currently known.

public void removeLocationUpdates (LocationListener listener)

Stop listening location updates.

public void requestLocationUpdates (LocationListener listener)

Start receiving location updates on the listener. This will use the default settings for a location request.

When app is done listening location updates, removeLocationUpdates(LocationListener) should be called to avoid memory leaks. Positioning thread stays alive until pairing removeLocationUpdates() is called. Ideally, requestLocationUpdates() - removeLocationUpdates() should follow Activity/Fragment onStart() - onStop() lifecycle. If location updates are not removed, positioning stays alive when app is backgrounded potentially draining the battery.

Parameters
listener the listener which will receive the location updates.

public void requestLocationUpdates (LocationRequest request, LocationListener listener)

Start receiving location updates on the listener. This will automatically enable the required location providers if possible.

When app is done listening location updates, removeLocationUpdates(LocationListener) should be called to avoid memory leaks. Positioning thread stays alive until pairing removeLocationUpdates() is called. Ideally, requestLocationUpdates() - removeLocationUpdates() should follow Activity/Fragment onStart() - onStop() lifecycle. If location updates are not removed, positioning stays alive when app is backgrounded potentially draining the battery.

Parameters
request the update request specifying which providers to enable
listener the listener which will receive the location updates.

public boolean requiresBluetooth ()

Returns true if this LocationProvider depends on Bluetooth.

public boolean requiresGps ()

Returns true if this LocationProvider depends on GPS (Location services enabled).

public static FeatureCollection toFeatureCollection (List<Location> locations)

Creates FeatureCollection from list of Locations.

public static FeatureCollection toFeatureCollection (String geoJson)

Creates FeatureCollection from geojson String.

Sample:
{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Point","coordinates":[24.8124109,60.220988]},"properties":{"layerIndex":2,"buildingRef":"431"}},{"type":"Feature","geometry":{"type":"Point","coordinates":[24.8124427,60.22095]},"properties":{"layerIndex":2,"buildingRef":"431"}},{"type":"Feature","geometry":{"type":"Point","coordinates":[24.8124234,60.2209286]},"properties":{"layerIndex":2,"buildingRef":"431"}}]}