Wayfinding Manager
User position
The User location represents the User position on the map. By default it will take the one defined in the Calibration.
Change User position
There are 3 equivalent ways to change the User position depending on the coordinate system.
There are 3 coordinate system used in the AdsumReactNativeMap:
- Global Positioning System (GPS)
- This is the common one, the one you will use the most.
- Adsum 3D system
- This is the one used by the 3D engine, it consist of 3 axes (x, y, z) with z pointing to the sky.
- Universal Transverse Mercator (UTM)
- This is the intermediate system between GPS and Adsum 3D system, the main characteristics of it are:
- This is a Cartesian coordinate system contrary to GPS.
- This consist of 3 axes (E, N, alt) with E matching pointing to the East, N to the North and alt to the sky.
- The unit is in meter
- This is the intermediate system between GPS and Adsum 3D system, the main characteristics of it are:
Change User position using GPS
await adsumRnMap.wayfindingManager.setUserGpsPosition(
{ lat: 48.9019365, long: 2.3156367000000273, alt: 0 },
floorObject // The floorObject on which the user is or null if he is on the Site
);
Asynchronous
Change User position using Adsum Position
await adsumRnMap.wayfindingManager.setUserAdsumPosition(
{ x: 0, y: 0, z: 0 },
floorObjectOrNull // The floorObject on which the user is or null if he is on the Site
);
Asynchronous
By default the position is relative to the floorObject, you can use the third optional parameter to specify that the given position is absolute.
await adsumRnMap.wayfindingManager.setUserAdsumPosition(
{ x: 0, y: 0, z: 0 },
floorObjectOrNull, // The floorObject on which the user is or null if he is on the Site,
true
);
Asynchronous
Change User position using UTM
await adsumRnMap.wayfindingManager.setUserUtmPosition(
{ E: 449845.91, N: 5416780.35, alt: 0 },
floorObject // The floorObject on which the user is or null if he is on the Site
);
Asynchronous
Note: the UTM uses a zone parameter, make sure the given zone match the one of the site.
Get Current User position
You can get the User position in UTM & GPS systems.
It returns null
if the User position isn't set yet.
// Returns Promise<{null|{floor: FloorObject|null, gps: {long: number, lat: number, alt: number }}}, Error>
await adsumRnMap.wayfindingManager.getUserGpsPosition();
Asynchronous
// Returns Promise<{null|{floor: FloorObject|null, utm: {N: number, E: number, alt: number }}}, Error>
await adsumRnMap.wayfindingManager.getUserUtmPosition();
Asynchronous
Observe the Change in User position
You can observe the change in User position changes by registering the WAYFINDING_EVENTS.user.position.didChanged
event.
import { WAYFINDING_EVENTS } from "@adactive/adsum-react-native-map";
adsumRnMap.wayfindingManager.addEventListener(
WAYFINDING_EVENTS.user.position.didChanged,
({ type, floor }) => {
// Do something
}
);
Note: The User position is not sent for performance reasons. You can then use the User position getter if you need them.
Adsum Location
Locations are pre-defined 3D positions, these locations are managed by the LocationRepository.
Get Adsum Location by id
The AdsumLocation#id match the AdsumClientApi.Place#id, which is useful when using the AdsumClientApi.
const placeId = await adsumObject.getPlaceId();
adsumRnMap.wayfindingManager.locationRepository.get(placeId);
Get Adsum Location by AdsumObject
An AdsumLocation can also be an AdsumObject3D, which can be useful to draw a path to a Space for example.
await adsumRnMap.wayfindingManager.locationRepository.getByAdsumObject(adsumObject3D);
Asynchronous
Adsum User Location
There is a special case, the AdsumLocation representing the User position. This is dynamic and updated each time the User position change.
await adsumRnMap.wayfindingManager.locationRepository.getUserLocation();
Asynchronous
Path
Path is used for wayfinding, we will see in the following chapter how to use it to find and display the best way.
Create a Path
A Path is defined by an origin and a destination, respectively identified by from
and to
properties.
You can create a Path from a location to another like this:
import { Path } from "@adactive/adsum-react-native-map";
const path = new Path(fromLocation, toLocation);
Please note that if fromLocation or toLocation is null, then the User Location will be used.
Like this you can create a Path from the User location to another location by:
import { Path } from "@adactive/adsum-react-native-map";
const path = new Path(null, toLocation);
The wheelchair access is managed by the third optional parameter, pmr
. By default it's false, so
to create a Path for wheelchair access you can do:
import { Path } from "@adactive/adsum-react-native-map";
const path = new Path(fromLocation, toLocation, true);
Compute a Path
The Path computing will calculate the best way to go from a location to another considering the wheelchair access value.
await adsumRnMap.wayfindingManager.computePath(path);
Once computed, the Path is not displayed yet, but the object has been updated.
You can get the Path distance in meter using:
path.getDistance();
Note: We can only provide distance meter if the site has been georeferenced in the Studio Editor
PathSections
A PathSection is a part of Path, stick to a FloorObject or the SiteObject. You can retrieve them using Path.getPathSections
The PathSection has the following properties / methods:
from: AdsumLocation
: An AdsumLocation representing the origin of the PathSection (different from the parent Path#from except for the first one).to: AdsumLocation
: An AdsumLocation representing the destination of the PathSection (different from the parent Path#to except for the last one).ground: SiteObject|FloorObject
: The FloorObject or SiteObject on which this PathSection is defined.getDistance(): number
: The distance of that PathSection.
Note: You can have to consecutive PathSection on the same ground. For now it doesn't happen but will be introduce in next releases.
Draw a Path
To draw a Path, you will need to draw each PathSection one by one and eventually change the floor.
async () => {
for(const pathSection of path.getPathSections()) {
const pathSectionFloor = pathSection.ground === adsumRnMap.objectManager.site ? null: pathSection.ground;
// Set the currentFloor
const currentFloor = await adsumRnMap.sceneManager.getCurrentFloor();
if (pathSectionFloor !== currentFloor) {
await adsumRnMap.sceneManager.setCurrentFloor(pathSectionFloor);
}
await adsumRnMap.wayfindingManager.drawPathSection(pathSection);
}
}
You can remove a drawn PathSection by doing:
adsumRnMap.wayfindingManager.removePathSection(pathSection);
Or remove all pathSections of a Path:
adsumRnMap.wayfindingManager.removePath(path);
Update a Path
Sometimes the Path has to be updated, for example when the User position change.
In that case, it's useful to know if the Path need to be recomputed and redrawn. In order to take a
decision you can use getUserDistanceFromPath
which will return the distance in meter:
adsumRnMap.wayfindingManager.getUserDistanceFromPath(path);
Or you can test for a specific PathSection:
await adsumRnMap.wayfindingManager.getUserDistanceFromPathSection(pathSection);
Asynchronous
So you may want to redraw the Path if the User position doesn't match anymore the Path drawn by doing:
import { WAYFINDING_EVENTS } from "@adactive/adsum-react-native-map";
adsumRnMap.wayfindingManager.addEventListener(
WAYFINDING_EVENTS.user.position.didChanged,
async ({ type, floor }) => {
const distanceToPath = adsumRnMap.wayfindingManager.getUserDistanceFromPath(path);
if (distanceToPath > 5) {
await adsumRnMap.wayfindingManager.computePath(path);
for(const pathSection of path.getPathSections()) {
const pathSectionFloor = pathSection.ground === adsumRnMap.objectManager.site ? null: pathSection.ground;
// Set the currentFloor
const currentFloor = await adsumRnMap.sceneManager.getCurrentFloor();
if (pathSectionFloor !== currentFloor) {
await adsumRnMap.sceneManager.setCurrentFloor(pathSectionFloor);
}
await adsumRnMap.wayfindingManager.drawPathSection(pathSection);
}
}
}
);