Skip to content

How to Migrate a Building to Another Site Using the PATCH /api/v8/buildings/{buildingInternalIdentifier} API

With the release of Pointr Cloud v8.14, the PATCH /api/v8/buildings/{buildingInternalIdentifier} API has been introduced, enabling the transfer of a building from one site to another. This document provides a comprehensive guide on how to use this API, supported by the Pointr Cloud Dashboard.

Initial State of Site and Buildings

In this scenario, there are two distinct sites in Pointr Cloud, each containing one building. The goal of this guide is to demonstrate the migration of Building2 from its current location in Site2 to Site1, showcasing the functionality of the PATCH API.

Site1 - Building1: This image illustrates the initial state of Building1 located within Site1.

Site2 - Building2: This image illustrates the initial state of Building2, which will be migrated to Site1.

Migrating a Building to Another Site

Get building details to be migrated

To initiate the migration, the PATCH /api/v8/buildings/{buildingInternalIdentifier} API will be utilized. Before migrating the building, it is crucial to retrieve the necessary building details using the appropriate GET Site/Building API endpoints.

In this example, we will use the GET /api/v8/buildings/{buildingInternalIdentifier}/draft endpoint to obtain the details for the building to be migrated. Specifically, we will fetch the data for the building with the internal identifier “2” by making the following request: /api/v8/buildings/2/draft. The relevant response is displayed below:

Example of the response data for Building2:

Updating Site Coordinates to Encapsulate the Migrated Building

If the building’s coordinates fall outside the boundaries of the target site, it will be necessary to update the site’s coordinates to include the building. This can be accomplished by using the Pointr Cloud Dashboard or PATCH /api/v8/sites/{siteInternalIdentifier} API. Both examples are provided below

Updating the Site Geometry via Pointr Cloud Dashboard

  1. Click the “Edit” button on the site that needs updating to cover the building that will be migrated.

  2. Click the “Clear” button to remove the current site geometry.

  3. Select “Rectangle” or “Polygon” to draw the new geometry for the site.

  4. Draw the new geometry and right-click to save the drawn shape.

  5. Click “Save” to confirm and save the updated geometry.

  6. See the updated Site Geometry after saving

Updating the Site Geometry via PATCH /api/v8/sites/{siteInternalIdentifier} API

Alternatively, the PATCH /api/v8/sites/{siteInternalIdentifier} API endpoint can be used to update the site’s coordinates programmatically, ensuring that it encapsulates the building to be migrated.

Migrate the building to another site

Once the Result section of the GET Building response is obtained, it should be used as the payload for the PATCH /api/v8/buildings/{buildingInternalIdentifier} request. The payload must be formatted as JSON, and the Site Internal Identifier of the new site should be added in the following format: “siteInternalIdentifier”: {Desired New Site Internal Identifier}. This is demonstrated in the example below:

Warning

Only the Result section of the GET Building API response should be utilized in the subsequent PATCH request.

If site coordinates accurately cover the building, the API will return a success response, confirming that the building has been successfully migrated to the target site.

Screenshot confirming that the building has been successfully migrated to the new site:

Warning

Ensure that the building being migrated is located within the geographical boundaries of the target site’s coordinates. If the building’s coordinates lie outside of the desired site, the API will return an error, as shown in the following example. Please follow this documentation to see how to update the site coordinates to prevent this error.

Deleting an Empty Site After Building Migration

After a building has been successfully migrated to another site, the original site may be left empty without any associated buildings. If the original site is no longer needed, it is advisable to delete the empty site. This can be done either through the Pointr Cloud Dashboard or by using the DELETE /api/v8/sites/{siteInternalIdentifier} API endpoint.

Deleting the Site via Pointr Cloud Dashboard

The Pointr Cloud Dashboard provides an easy-to-use interface for deleting a site that no longer contains buildings. Follow these steps to delete the site:

  1. Find the existing site of the building that has been migrated.

  2. Click “Edit” on the site that will be deleted. Navigate to the “Danger Zone,” then click “Delete” followed by “Yes, continue” to confirm the deletion.

  3. Confirm the site has been deleted.

Deleting the Site via DELETE /api/v8/sites/{siteInternalIdentifier} API

Alternatively, the empty site can be deleted programmatically by using the DELETE /api/v8/sites/{siteInternalIdentifier} API. This process is demonstrated below:

Final State After Deleting the Empty Site

As shown in the final image below, the empty site has been successfully deleted, and the building has been successfully migrated to another site.


Last update: October 18, 2024
Back to top