In Situm Platform, a building can have a number of Points of Interest that represent significative locations inside or outside of the building. For detailed information on points of interest, you may read their introductory description and how to create them in Situm Dashboard. You may also find interesting their data models as provided by Situm REST API Floor methods and Situm SDK Floor model.
Fetching all the Indoor POIs of a building
Situm allows both indoor POIs (within the floorplan limits) & outdoor POIs (outside the floorplan). The following code snippet shows how to retrieve the indoor POIs of a certain building and output their information on the application Log. For this example, we will use building 8377, which we know from a previous example.
//Fetches all the indoor POIs from the building 8377 SitumSdk.communicationManager().fetchIndoorPOIsFromBuilding("8377", new Handler<Collection<Poi>>() { @Override public void onSuccess(Collection<Poi> pois) { //Receives all the buildings and loops over them for (Poi poi: pois){ Log.i(TAG, "BuildingID: " + poi.getBuildingIdentifier()); Log.i(TAG, "FloorID: " + poi.getFloorIdentifier()); Log.i(TAG, "PoiID: " + poi.getIdentifier()); Log.i(TAG, "Name: " + poi.getName()); Log.i(TAG, "InfoHTML: " + poi.getInfoHtml()); Log.i(TAG, "CustomFields: " + poi.getCustomFields()); Log.i(TAG, "Category:"); Log.i(TAG, " CategoryID: " + poi.getCategory().getIdentifier()); Log.i(TAG, " Code: " + poi.getCategory().getCode()); Log.i(TAG, " NameInLocale: " + poi.getCategory().getName()); Log.i(TAG, " NameInAllLanguages: " + poi.getCategory().getNameAsI18n()); Log.i(TAG, " IconURL (when selected): " + poi.getCategory().getSelectedIconUrl()); Log.i(TAG, " IconURL (when unselected): " + poi.getCategory().getUnselectedIconUrl()); Log.i(TAG, "Position:"); Log.i(TAG, " BuildingID: " + poi.getPosition().getBuildingIdentifier()); Log.i(TAG, " FloorID: " + poi.getPosition().getFloorIdentifier()); Log.i(TAG, " WSG84 Coordinate. Lat=" + poi.getPosition().getCoordinate().getLatitude() + " Lng="+poi.getPosition().getCoordinate().getLongitude()); Log.i(TAG, " Cartesian Coordinate (meters). X= " + poi.getPosition().getCartesianCoordinate().getX() + " Y="+ poi.getPosition().getCartesianCoordinate().getY()); Log.i(TAG, " IsIndoor? " + poi.getPosition().isIndoor()); } } @Override public void onFailure(Error error) { Log.e(TAG, "Error: " + error ); } });
In the previous code snippet, we are receiving a Collection of POI objects (the POIs in Building 8377), and we loop over them to print their properties. Your application logs should be something like this:
... BuildingID: 8377 FloorID: 20541 PoiID: 64478 Name: Shop InfoHTML: <p><b>Welcome to the shop!</b></p> CustomFields: {show_in_app=true} Category: CategoryID: 1206 Code: MC NameInLocale: My Category NameInAllLanguages: I18nString{values={spa=Mi categoría, eng=My Category}} IconURL (when selected): URL{value='/uploads/poicategoryselected/1206/b7bac260-f68d-4554-9054-d8a9be992618.png', isAbsolute=false} IconURL (when unselected): URL{value='/uploads/poicategory/1206/a04cf2b3-5c09-40d1-8dca-3f3d9ae3adde.png', isAbsolute=false} Position: BuildingID: 8377 FloorID: 20541 WSG84 Coordinate. Lat=42.8722187941717 Lng=-8.56361387801399 Cartesian Coordinate (meters). X=68.521411474978 Y=31.7456405070183 IsIndoor? true ... BuildingID: 8377 FloorID: 20541 PoiID: 64479 Name: Entrance InfoHTML: <p>Entrance</p> CustomFields: {} Category: CategoryID: 148 Code: situm-default NameInLocale: No category NameInAllLanguages: I18nString{values={spa=Sin categoría, eng=No category}} IconURL (when selected): URL{value='/uploads/poicategoryselected/148/4c85ebd0-6ff2-4c1d-bad5-1f9f9eedc847.png', isAbsolute=false} IconURL (when unselected): URL{value='/uploads/poicategory/148/8ac8e04f-a6a0-4da5-a08d-02ec33ffdcfb.png', isAbsolute=false} Position: BuildingID: 8377 FloorID: 20541 WSG84 Coordinate. Lat=42.8724016056969 Lng=-8.56283871960868 Cartesian Coordinate (meters). X= 2.72343394626029 Lng=22.0525554105088 IsIndoor? true ...
Let's examine them in detail.
Building and floor Identifier
First, you will notice that the POI data object allows you to retrieve the identifier of the building & floor to which the POI belongs. This is handy if you need this information later in your code.
BuildingID: 8377 FloorID: 20541
POI Identifier
Then, we output the POI identifier.
PoiID: 64478
The POI identifier is automatically generated by Situm Platform when the POI is created. Another way to know the identifier of a floor is by retrieving the POIs from Situm REST API.
POI Name, free HTML information and custom fields
After that, we see the POI name, it free HTML info (filled using our Rich Text Editor) and the POI's custom fields.
Name: Shop InfoHTML: <p><b>Welcome to the shop!</b></p> CustomFields: {show_in_app=true}
All this information can be configured when creating/editing the POI:
POI Category
The previous image shows that each POI can be assigned to a different category. For instance, a POI may be a shop, while other may be a restroom or an information point. Situm Dashboard comes with a predefined set of categories but also allows you to define your own. Categories are specially useful if you want to assign different icons to your POIs when showing them in your app, or if you want to build advanced search/filter utilities.
The POI data object contains a full PoiCategory data object instance, therefore we have access to all the details of the POI's category. This can be seen in the log output:
Category: CategoryID: 1206 Code: MC NameInLocale: My Category NameInAllLanguages: I18nString{values={spa=Mi categoría, eng=My Category}} IconURL (when selected): URL{value='/uploads/poicategoryselected/1206/b7bac260-f68d-4554-9054-d8a9be992618.png', isAbsolute=false} IconURL (when unselected): URL{value='/uploads/poicategory/1206/a04cf2b3-5c09-40d1-8dca-3f3d9ae3adde.png', isAbsolute=false}
The category data includes the identifier of the category, its code, the name of the category (shown in the locale of the smartphone), the name of the category in all the supported languages, and the 2 URLs that will allow you to download the icons of the category (usually, one of them will be shown when the POI icon is selected, and the other when it is unselected).
POI Position
Last but not least, each POI will have a certain location. This location will be provided as an standard Situm Point data object whose info is shown on the log:
Position: BuildingID: 8377 FloorID: 20541 WSG84 Coordinate. Lat=42.8724016056969 Lng=-8.56283871960868 Cartesian Coordinate (meters). X=2.72343394626029 Y=22.0525554105088 IsIndoor? true
Fetching all the Outdoor POIs of a building
Fetching the outdoor POIs of a building is similar to fetching the indoor ones: instead of using the CommunicationManager.fetchIndoorPOIsFromBuilding method, you may use the CommunicationManager.fetchOutdoorPOIsFromBuilding one. The snippet would be like this:
//Fetches all the outdoor POIs from the building 8377 SitumSdk.communicationManager().fetchOutdoorPOIsFromBuilding("8377", new Handler<Collection<Poi>>() { @Override public void onSuccess(Collection<Poi> pois) { //Receives all the buildings and loops over them for (Poi poi: pois){ Log.i(TAG, "BuildingID: " + poi.getBuildingIdentifier()); ... } } @Override public void onFailure(Error error) { Log.e(TAG, "Error: " + error ); } });
You may print all the POI information as in the Indoor POIs example to see a log output like the following one.
BuildingID: 8377 FloorID: -1 PoiID: 64480 Name: OutdoorPOI InfoHTML: CustomFields: {} Category: CategoryID: 148 Code: situm-default NameInLocale: No category NameInAllLanguages: I18nString{values={spa=Sin categoría, eng=No category}} IconURL (when selected): URL{value='/uploads/poicategoryselected/148/4c85ebd0-6ff2-4c1d-bad5-1f9f9eedc847.png', isAbsolute=false} IconURL (when unselected): URL{value='/uploads/poicategory/148/8ac8e04f-a6a0-4da5-a08d-02ec33ffdcfb.png', isAbsolute=false} Position: BuildingID: 8377 FloorID: -1 WSG84 Coordinate. Lat=42.872388178306 Lng=-8.56437136391785 Cartesian Coordinate (meters). X= 0.0 Y=0.0 IsIndoor? false
Notice that since this is an Outdoor POI, the floor identifier is "-1" (since the POI does not belong to any floor) and the POI.getPosition.isIndoor method returns false.
Fetching all the POIs of the user account
Finally, you may be interested on fetching all the POIs of the user account, irregardless of the building where they have been created. You may do it by using the method CommunicationManager.fetchAllPOIsFromUser. This can be useful, for example, if you want to build an utility that is able to search across all the POIs of all the buildings.
//Fetches all the POIs from the user account SitumSdk.communicationManager().fetchAllPOIsFromUser( new Handler<Collection<Poi>>() { @Override public void onSuccess(Collection<Poi> pois) { //Receives all the buildings and loops over them for (Poi poi: pois){ Log.i(TAG, "BuildingID: " + poi.getBuildingIdentifier()); ... } } @Override public void onFailure(Error error) { Log.e(TAG, "Error: " + error ); } });