Coordinate System
Optional
Needed if your app displays a map or uses geographic coordinates.
Coordinates of all the objects in the system (Device Position, Regions, Proximity Triggers, and Location Tags) are defined relative to the corresponding building coordinate system.
Building Coordinate System
Oriient uses a right hand coordinate system in meters for each building. A positive X coordinate goes to the right, and a positive Y coordinate goes upward. The origin of the coordinate system is in the bottom left corner of the first image uploaded when creating a map related to a building.
Important
UIKit Coordinate System starts from the top left; Oriient Coordinate System starts from the bottom left.
Geographic coordinates
To enable conversion between a building coordinates system and geographic coordinates it is necessary to provide information about the building location.
Specifically, use REST to define:
-
Geographic coordinates of the building coordinates system origin (
IPSBuilding.origin); -
Rotation of the building relative to ENU coordinates system (
IPSBuilding.rotationToENU).
If these values are provided correctly every position update will contain geographic coordinates (as well as coordinates relative to the building coordinates system) and it will be possible to convert any coordinate from a building coordinate system to geographic coordinates using one of two helper functions of IPSPositioning:
Floor Images
A floor image is the visual representation of a floor in a building. Request it using IPSCore.getFloorMapById() with the building ID and floor ID. The result is an IPSFloorImageData object, which contains the floor image's:
- Unique ID,
IPSFloorImageData.id; - Name,
IPSFloorImageData.name; - Image,
IPSFloorImageData.image— an IPSFloorImage, which is either.bitmap(image:)holding aUIImage, or.svg(image:)holding an IPSFloorSvgImage with the SVGdataand the image bounds (width,height); - Pixel-to-meter ratio (how many pixels of the image correspond to one meter),
IPSFloorImageData.pixelToMeter; - Width and height of the area represented by the image, in meters,
IPSFloorImageData.widthInMetersandIPSFloorImageData.heightInMeters; - Offset of the image's bottom-left corner from the building coordinate system origin, in meters,
IPSFloorImageData.offset; - Preferred initial rotation of the image, in degrees (may be
nil),IPSFloorImageData.preferredInitialRotation; - Sign marks to present on the map,
IPSFloorImageData.signMarks(see IPSSignMark).
IPSCore.getFloorMapById(
buildingId: building.id,
floorId: floor.id,
onSuccess: { floorImageData in
switch floorImageData.image {
case .bitmap(let image):
// image: UIImage
break
case .svg(let svgImage):
let svgData = svgImage.data
}
},
onError: { error in
}
)
Deprecated APIs
IPSCore.getMapById() is deprecated since SDK 8.5.0, and IPSMap and IPSFloor.defaultMapId since SDK 8.8.0. Use IPSCore.getFloorMapById() with the floor ID instead.
Coordinates Conversion for Visualization
Using the floor image's pixel-to-meter ratio, height and offset, you can easily convert coordinates from meters relative to a building's coordinates system to pixels relative to the image, and use the resulting value to arrange correctly the objects on a mobile device screen.
// Convert a coordinate in meters relative a building coordinate system to
// UIKit point relative to the floor image.
func convertOriientCoordinateToUIKitPoint(coordinate: IPSCoordinate, floorImageData: IPSFloorImageData) -> CGPoint {
let pixelToMeter = CGFloat(floorImageData.pixelToMeter)
let heightInMeters = CGFloat(floorImageData.heightInMeters)
// first, apply the image's offset from the building's origin. It is in meters.
let coordinatesWithOffset = CGPoint(x: coordinate.x - floorImageData.offset.x, y: coordinate.y - floorImageData.offset.y)
// second, convert from meters to pixels using `pixelToMeter`
// and to UIKit coordinate system moving the origin from bottom-left to top-left
return CGPoint(x: coordinatesWithOffset.x * pixelToMeter, y: (heightInMeters - coordinatesWithOffset.y) * pixelToMeter)
}
Device Position
A device's position is always defined relative to a building coordinate system. The contents of a position update are described in Manage Device's Position Updates.
Important
In case there is information about the building geographic location (See Geographic coordinates) each position will also contain valid latitude, longitude, altitude and azimuth values. Otherwise, the values will be equal to IPSUnknownValue.