The building is the most important cartographic entity in Situm. Buildings can represent any venue and contain all other cartographic elements, such as floors (with floorplans), points of interest, geofences, etc.


For detailed information on buildings, 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 Building methods and Situm SDK Building model.



Fetching all the buildings of your account


The following code snippet shows how to retrieve the buildings of your account and output their information on the application Log. 


//Fetches all the buildings in your account
SitumSdk.communicationManager().fetchBuildings(new Handler<Collection<Building>>() {

    @Override
    public void onSuccess(Collection<Building> buildings) {
        //Receives all the buildings and loops over them
        for (Building building: buildings){
            Log.i(TAG, "Building ID: " + building.getIdentifier());
            Log.i(TAG, "Name: " + building.getName()+ "\n");
            Log.i(TAG, "Address: " + building.getAddress());
            Log.i(TAG, "InfoHTML: " + building.getInfoHtml());
            Log.i(TAG, "BuildingPictureURL: " + building.getPictureUrl());
            Log.i(TAG, "BuildingPictureThumbnailURL " + building.getPictureThumbUrl());
            Log.i(TAG, "CustomFields: " + building.getCustomFields());

            Log.i(TAG, "Center. Lat=" + building.getCenter().getLatitude() + " Lng=" + building.getCenter().getLongitude());
            Log.i(TAG, "Dimensions. Height: " + building.getDimensions().getHeight() + ". Width: " + building.getDimensions().getWidth());
            Log.i(TAG, "Rotation. Degrees=" + building.getRotation().degrees() + " Radians=" + building.getRotation().radians());

            Log.i(TAG, "Bounds:");
            Log.i(TAG, "   NW (TopLeft [1]): Lat=" + building.getBounds().getNorthWest().getLatitude() + " Lng=" + building.getBounds().getNorthWest().getLongitude());
            Log.i(TAG, "   NE (TopRight [2]): Lat=" + building.getBounds().getNorthEast().getLatitude() + " Lng=" + building.getBounds().getNorthEast().getLongitude());
            Log.i(TAG, "   SE (BottomRight [3]): Lat=" + building.getBounds().getSouthEast().getLatitude() + " Lng=" + building.getBounds().getSouthEast().getLongitude());
            Log.i(TAG, "   SW (BottomLeft [4]): Lat=" + building.getBounds().getSouthWest().getLatitude() + " Lng=" + building.getBounds().getSouthWest().getLongitude());
            Log.i(TAG, "BoundsRotated:");
            Log.i(TAG, "   NW (TopLeft [1]): Lat=" + building.getBoundsRotated().getNorthWest().getLatitude() + " Lng=" + building.getBoundsRotated().getNorthWest().getLongitude());
            Log.i(TAG, "   NE (TopRight [2]): Lat=" + building.getBoundsRotated().getNorthEast().getLatitude() + " Lng=" + building.getBoundsRotated().getNorthEast().getLongitude());
            Log.i(TAG, "   SE (BottomRight [3]): Lat=" + building.getBoundsRotated().getSouthEast().getLatitude() + " Lng=" + building.getBoundsRotated().getSouthEast().getLongitude());
            Log.i(TAG, "   SW (BottomLeft [4]): Lat=" + building.getBoundsRotated().getSouthWest().getLatitude() + " Lng=" + building.getBoundsRotated().getSouthWest().getLongitude()+ "\n");

        }
    }

    @Override
    public void onFailure(Error error) {
Log.e(TAG, "Error: " + error );
    }
});


In the previous code snippet, we are receiving a Collection of Building objects (the buildings in the user account), and we loop over them to print their properties. Your application logs should be something like this:

 


...
Building ID: 8377
Name: Situm HQ
Address: Rúa do Restollal, nº 32 Edificio Paxonal, Planta 4, Of. 401 15702, Santiago de Compostela, A Coruña, Spain
InfoHTML: <p><strong>Welcome to Situm!</strong></p><p><br></p>
BuildingPictureURL: URL{value='/uploads/building/8377/6d8423b9-61b5-4015-a0aa-0faf3c9c66cc.png', isAbsolute=false}
BuildingPictureThumbnailURL URL{value='/uploads/building/8377/6d8423b9-61b5-4015-a0aa-0faf3c9c66cc.png', isAbsolute=false}
CustomFields: {external_cms_id=102301, show_in_app=true}
Center. Lat=42.872352462867 Lng=-8.56324909758796
Dimensions. Height: 43.9411738292689. Width: 73.273936306327
Rotation. Degrees=170.58184697387247 Radians=2.9772148738272
Bounds:
   NW (TopLeft [1]): Lat=42.87255023533293 Lng=-8.56369747820446
   NE (TopRight [2]): Lat=42.87255023533293 Lng=-8.562800717024437
   SE (BottomRight [3]): Lat=42.87215469039859 Lng=-8.562800717024437
   SW (BottomLeft [4]): Lat=42.87215469039859 Lng=-8.56369747820446
BoundsRotated:
   NW (TopLeft [1]): Lat=42.872211323414874 Lng=-8.562762760777817
   NE (TopRight [2]): Lat=42.87210338912287 Lng=-8.56364743390568
   SE (BottomRight [3]): Lat=42.872493602247964 Lng=-8.563735434357707
   SW (BottomLeft [4]): Lat=42.87260153653997 Lng=-8.562850761229845
...


Let's examine them in detail.


Building Details: Identifier, Name, Address...


The first information you will notice in the log is the Building Identifier. This is the identifier that Situm Platform automatically assigns automatically to your building when you create it. You may also know the identifier of a particular building by taking a look at the building URL in Situm Dashboard.


Building ID: 8377


Following, a number of lines contain other basic building information: the building's name, address, free HTML information (intruduced using our Rich Text HTML editor), a picture of the building (both at full resolution and its thumbnail version), and all the custom-field key-value pairs that you may have created. 



Name: Situm HQ
Address: Rúa do Restollal, nº 32 Edificio Paxonal, Planta 4, Of. 401 15702, Santiago de Compostela, A Coruña, Spain
InfoHTML: <p><strong>Welcome to Situm!</strong></p><p><br></p>
BuildingPictureURL: URL{value='/uploads/building/8377/6d8423b9-61b5-4015-a0aa-0faf3c9c66cc.png', isAbsolute=false}
BuildingPictureThumbnailURL URL{value='/uploads/building/8377/6d8423b9-61b5-4015-a0aa-0faf3c9c66cc.png', isAbsolute=false}
CustomFields: {external_cms_id=102301, show_in_app=true}


All this information can be edited from the building editor of Situm Dashboard, as shown in the following picture:




Building Cartography information: center (location), rotation, corners


Finally, the most important building information: where it is, how is it oriented and where are its bounds (corners). 

The following image will help to clarify the previous information. On the left, we see a floorplan whose dimensions have been adjusted to the building's dimensions, but that has not been rotated yet. On the right, we see the same floorplan after it has been rotated to fit with the building's silhouette. 


First, take a look at the left image. Notice that the building's margins (blue lines) form a rectangle defined by the margins of the floorplan. Since all floorplans have the same size, the width & height of the building are exactly the width & height of this rectangle before it has been rotated. Likewise, the location of the building (center) is exactly the location of the center point of this rectangle. 



Center. Lat=42.872352462867 Lng=-8.56324909758796
Dimensions. Height: 43.9411738292689. Width: 73.273936306327


The location of the building's corners (bounds) also matches the location of the corners of this rectangle. Now, take a look at the right image. The floorplan has been rotated 170.58 degrees counter-clockwise. This does not change the center of the building, nor its width or height, but it does change the location of the building's bounds. For convenience, Situm SDK provides their location before and after rotation.


Rotation. Degrees=170.58184697387247 Radians=2.9772148738272
Bounds:
   NW (TopLeft [1]): Lat=42.87255023533293 Lng=-8.56369747820446
   NE (TopRight [2]): Lat=42.87255023533293 Lng=-8.562800717024437
   SE (BottomRight [3]): Lat=42.87215469039859 Lng=-8.562800717024437
   SW (BottomLeft [4]): Lat=42.87215469039859 Lng=-8.56369747820446
BoundsRotated:
   NW (TopLeft [1]): Lat=42.872211323414874 Lng=-8.562762760777817
   NE (TopRight [2]): Lat=42.87210338912287 Lng=-8.56364743390568
   SE (BottomRight [3]): Lat=42.872493602247964 Lng=-8.563735434357707
   SW (BottomLeft [4]): Lat=42.87260153653997 Lng=-8.562850761229845