Migration

IndoorAtlas SDK 3.x Migration to GroundSage SDK Guide

IndoorAtlas SDK 3.x is latest IndoorAtlas location services. If your project was previously using IndoorAtlas SDK, it is recommended that you now use GroundSage SDK directly. All apis from IndoorAtlas SDK will be wrapped into GroundSage SDK. Please DO NOT call any apis from IndoorAtlas SDK. This guide will provide you to migrate to GroundSage SDK.

Migration

The following IndoorAtls equivalent function/properties are not available in GroundSage SDK.

lockFloor(floor)
unlockFloor()
lockIndoors(lockIndoor)

Location updates

To start updating location and region monitoring, you can do following from IndoorAtlas SDK 3.x.

fun startLocationUpdates() {
    var locationManager = IALocationManager.create(this)
    val request = IALocationRequest.create()
    locationManager?.requestLocationUpdates(request, this)
    locationManager?.registerRegionListener(this)
}

In order to do the same thing as above, you can do following from GroundSage SDK.

fun startLocationAndRegionUpdateExample() {
    val mgr = IAGSManager.getInstance(this)
    // start receiving location updates & monitor region changes
    mgr.registerLocationListener(mIALocationListener)
    mgr.registerRegionListener(mRegionListener)
    mgr.startSubscription()
}

Wayfinding

To start wayfinding, you can do following from GroundSage SDK.

private lateinit var iaWayfindingRequest: IAWayfindingRequest
private val iaWayfindingListener:IAWayfindingListener = object : IAWayfindingListener {
    override fun onWayfindingUpdate(route: IARoute?) {
        TODO("Not yet implemented")
    }
}

/**
 * Start wayfinding example
 */
fun startWayfindingExample() {
    val mgr = IAGSManager.getInstance(this)
    iaWayfindingRequest = IAWayfindingRequest.Builder()
        .withFloor(floor)
        .withLatitude(latitude)
        .withLongitude(longitude)
        .build()
    mgr.requestWayfindingUpdates(iaWayfindingRequest, iaWayfindingListener)
}

/**
 * Stop wayfinding example
 */
fun stopWayfindingExample() {
    val mgr = IAGSManager.getInstance(this)
    mgr.removeWayfindingUpdates()
}

Geofence

To add geofences, you can do following from GroundSage SDK.

private var mIAGeofenceRequest: IAGeofenceRequest? = null
private val mIAGeofenceListener: IAGeofenceListener = object: IAGeofenceListener {
    override fun onGeofencesTriggered(event: IAGeofenceEvent?) {
        TODO("Not yet implemented")
    }
}

/**
 * Geofences example
 */
fun addGeofencesExample(latitude: Double, longitude: Double) {
    // Add a circular geofence by adding points with a 5 m radius clockwise
    val radius = GEOFENCE_RADIUS_METERS
    val edgeCount = 12
    val EARTH_RADIUS_METERS = 6.371e6
    val latPerMeter = 1.0 / (EARTH_RADIUS_METERS * Math.PI / 180)
    val lonPerMeter = latPerMeter / Math.cos(Math.PI / 180.0 * latitude)
    val edges = ArrayList<DoubleArray>()
    for (i in 0 until edgeCount) {
        val angle = -2 * Math.PI * i / edgeCount
        val lat = latitude + radius * latPerMeter * Math.sin(angle)
        val lon = longitude + radius * lonPerMeter * Math.cos(angle)
        edges.add(doubleArrayOf(lat, lon))
    }
    val geofenceId = "My geofence " + mRunningGeofenceId++
    Log.d(TAG, "Creating a geofence with id \"$geofenceId\"")
    val geofence = IAGeofence.Builder()
        .withEdges(edges)
        .withId(geofenceId)
        .withName(geofenceId)
        .build()
    Log.i(TAG, "New geofence registered: $geofence")
    val mgr = IAGSManager.getInstance(this)
    mgr.addGeofences(
        IAGeofenceRequest.Builder()
            .withCloudGeofences(true) // listen also geofences defined in app.indooratlas.com
            .withGeofence(geofence)
            .build().also { mIAGeofenceRequest = it }, mIAGeofenceListener
    )
}

/**
 * Remove geofences example
 */
fun removeGeofencesExample() {
    val mgr = IAGSManager.getInstance(this)
    mgr.removeGeofenceUpdates(mIAGeofenceListener)
}

Orientation updates

To request orientation updates, you can do following from GroundSage SDK.

private val mIAOrientationListener: IAOrientationListener = object : IAOrientationListener {
    override fun onHeadingChanged(timestamp: Long, heading: Double) {}
    override fun onOrientationChange(timestamp: Long, quaternion: DoubleArray) {}
}

/**
 * Register orientation listener
 */
fun registerOrientationListener() {
    val mgr = IAGSManager.getInstance(this)
    mgr.registerOrientationListener(IAOrientationRequest(1.0, 0.0), mIAOrientationListener)
}

/**
 * Unregister orientation listener
 */
fun unregisterOrientationListener() {
    val mgr = IAGSManager.getInstance(this)
    mgr.unregisterOrientationListener(mIAOrientationListener)
}