Couple with AdsumClientApi
AdsumReactNativeMap requires AdsumClientApi in order to load data from Adsum REST API.
3D Elements and Entities
The 3D Elements is linked to Adsum Data Model using:
The AdsumReactNativeMap does not deal with AdsumClientApi entities to keep them decoupled. Only AdsumNativeMap#init escapes this rule as it uses AdsumClientApi to consume AdsumClientApi data to initiate AdsumReactNativeMap.
Place
A Place is the entity used to link the 3D Model to the Data Model. The Place refers to a location on the Map which can be:
- A Building
- A Space
- A point on the Site plane
- A point on a Floor plane
All AdsumObject3D have a placeId
property in that matches the AdsumClientApi Place#id property.
Note that the AdsumObject3D, which not created at initialisation, will not be present in AdsumClientApi unless you managed it yourself.
Find a Place from AdsumObject3D
const getPlaceFromAdsumObject = async (adsumObject3D) => {
const placeId = await adsumObject3D.getPlaceId();
return entityManager.getRepository("Place").get(placeId);
};
Example can be found here
Find an AdsumObject3D for a given place
const getAdsumObject3DFromPlace = (place) => {
if (place.shape_id !== null) {
// Prefer getSpace over using .spaces as it will return null if not found
return adsumRnMap.objectManager.getSpace(place.shape_id);
} else if (place.building_id !== null) {
// Prefer getBuilding over using .building as it will return null if not found
return adsumRnMap.objectManager.getBuilding(place.building_id);
} else if (place.custom_objects.size > 0) {
return adsumRnMap.objectManager.getLabel(place.custom_objects.at(0).value);
}
return null;
};
CustomObject
The CustomObject contained the data used to generate LabelObject, so as CustomObject and LabelObject are abstract, you will use the following children classes:
- Picto will lead to a LabelImage
- Label will lead to a LabelText
CustomObject is the naming used in AdsumClientApi for the data layer, while LabelObject is used in AdsumReactNativeMap to represent the 3D layer.
Some CustomObject property have a big impact on the rendering into LabelObject:
- CustomObject#orientation_mode will match with LabelObject#orientationMode property
- CustomObject#autoscale will match with LabelObject#autoScale property
- CustomObject#priority will define the level of details of the LabelObject, the LabelObject will only be visible if the camera is close enough. If priority is equals to 0, then this behavior is disabled
- CustomObject#permanent_display will define if the LabelObject will be visible by default.
Poi
POIs are not directly linked to the map but the Poi#places property will be used to uniquely identify POIs on the map.
Get path to Poi
This can be used for example to draw a path to a Poi.
import { Path } from "@adactive/adsum-react-native-map";
// sometime a Poi may have multiple places like toilets, we want in that case to go to the closest one !
const getBestPathToPoi = async (poi) => {
const places = entityManager.getRepository("Place").getList(poi.places);
let shortestPath = null;
for(const place of places) {
const path = new Path(null, adsumRnMap.wayfindingManager.locationRepository.get(place.id));
await adsumRnMap.wayfindingManager.computePath(path);
if (shortestPath === null || shortestPath.getDistance() > path.getDistance()) {
shortestPath = path;
}
}
return shortestPath;
}