Situm provides a complete cartography manager that allows you to create buildings & uploading their floorplans, and manage different cartography elements such as Points of Interest, Geofences and navigation routes. Situm SDK allows to retrieve and operate these (and more) cartography elements from within your application: you will be able to download their information & display it to your users easily and with a few lines of code.   



Before you start


Before we start, please make sure you have a good understanding of our Basic Android app example. We also recommend you to take a deep look at the CommunicationManager, which retrieves all the cartography information from the Situm Platform. Under the hood, the CommunicationManager calls the Situm REST API to retrieve all the information.


Additionally, please make yourself familiar with the most relevant cartography data classes: Building, Floor, Poi, and Geofence.


Ready? Let's go!



The following snippet shows you how to retrieve and inspect the most important cartography information: buildings, floors, points of interest and geofences.


package com.example.situmsdkbasicapp;

import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import java.util.Collection;

import es.situm.sdk.SitumSdk;
import es.situm.sdk.model.cartography.Building;
import es.situm.sdk.model.cartography.BuildingInfo;
import es.situm.sdk.model.cartography.Floor;
import es.situm.sdk.model.cartography.Geofence;
import es.situm.sdk.model.cartography.Poi;
import es.situm.sdk.error.Error;
import es.situm.sdk.utils.Handler;

public class MainActivity extends AppCompatActivity {

    private static final String TAG = MainActivity.class.getSimpleName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //Initialize Situm SDK
        SitumSdk.init(this);

        //Call the communicationManager to fetch all the buildings from Situm REST API
        SitumSdk.communicationManager().fetchBuildings(new Handler<Collection<Building>>() {

            //The onSuccess method receives the Collection of buildings from Situm REST API
            @Override
            public void onSuccess(Collection<Building> buildings) {

                // First, we print the basic info of all the buildings
                Log.i(TAG, "BuildingsBasicInfo = [" + buildings + "]");
                Log.i(TAG, "********************************************");

                //We can go further an loop over all the buildings...
                for (Building building : buildings) {

                    //...and fetch this additional info: floors, indoorPOIs, outdoorPOIs and geofences
                    SitumSdk.communicationManager().fetchBuildingInfo(building.getIdentifier(), new Handler<BuildingInfo>() {

                        //The onSuccess method receives the BuildingInfo data object ...
                        @Override
                        public void onSuccess(BuildingInfo buildingInfo) {

                            //... which contains all the relevant cartography entities associated with the building
                            Building buildingBasicInfo = buildingInfo.getBuilding();
                            Collection<Floor> floors = buildingInfo.getFloors();
                            Collection<Poi> indoorPOIs = buildingInfo.getIndoorPOIs();
                            Collection<Poi> outdoorPOIs = buildingInfo.getOutdoorPOIs();
                            Collection<Geofence> geofences = buildingInfo.getGeofences();

                            Log.i(TAG, "BuildingBasicInfo = [" + buildingBasicInfo + "]");
                            for (Floor floor : floors) Log.i(TAG, "floor = [" + floor + "]");
                            for (Poi indoorPOI : indoorPOIs) Log.i(TAG, "indoorPoi = [" + indoorPOI + "]");
                            for (Poi outdoorPOI : outdoorPOIs) Log.i(TAG, "outdoorPoi = [" + outdoorPOI + "]");
                            for (Geofence geofence : geofences) Log.i(TAG, "geofence = [" + geofence + "]");
                            Log.i(TAG, "------------------------------------------------");
                        }

                        //This onFailure method receives errors that happen during the fetchBuildingInfo network request
                        @Override
                        public void onFailure(Error error) {
                            Log.e(TAG, "Error with msg = [" + error.getMessage() + "]" + " and code = [" + error.getCode() + "]");
                        }

                    });

                }
            }

            //This onFailure method receives errors that happen during the fetchBuildings network request
            @Override
            public void onFailure(Error error) {
                Log.e(TAG, "FAILURE " + error);
            }
        });

    }
}


The previous code snippets shows us how to retrieve the basic information of all the buildings in our account using the  SitumSdk.communicationManager().fetchBuildings method. We receive a collection of Building data objects, each of which contains what we called the basic information of the building: name, rotation, bounds, location, etc. 


Most of the times, we will need more information, such as the floorplans or the Points of Interest. Although these are separate entities from the building, in a way they belong to it (after all, a floor only exists if the building exists). Therefore, Situm SDK provides the utility method  SitumSdk.communicationManager().fetchBuildingInfo, which retrieves for us:

  1. The building floors, exposing them through the BuildingInfo.getFloors method.
  2. The building indoor and outdoor Points of Interest, exposing them through the BuildingInfo.getIndoorPOIs and BuildingInfo.getOutdoorPOIs methods.
  3. The building geofences, exposing them through the BuildingInfo.getGeofences method.