@oriient/coordinates-convert
v1.0.0
Published
Coordinates conversion utilities for Oriient system
Downloads
62
Readme
@oriient/coordinates-convert
This package enables to convert from Oriient building local coordinates to geodetic (lat, long, alt aligned to google maps) coordinates. It also includes some utility functions that support general coordinates convertion for non Oriient related functionality, such as converting from ENU coordinates system to WGS 84 or to ECEF.
Also supports convertion of Oriient building coordinates to ENU.
The building data can be obtained form Oriient's REST API
Usage
All the examples below are using building data that can be obtained from REST API. For simplicity, here the building data is the following variables:
const buildingToEnuRotation = 284;
const buildingOrigin = {
latitude: 32.06866,
longitude: 34.79419,
altitude: 0,
};
Converting Oriient's building coordinates to geodetic ones
const { buildingCoordinatesToLatLng } = require('@oriient/coordinates-convert');
// The buildingToEnuRotation and buildingOrigin can be obtained from oriient REST API
const { lat, lng, alt } = buildingCoordinatesToLatLng(
buildingToEnuRotation,
buildingOrigin.latitude,
buildingOrigin.longitude,
buildingOrigin.altitude,
{ x: 100, y: 50, height: 0 } // coordinates to convert
);
console.log(`lat: ${lat}, lng: ${lng}, alt: ${alt}`);
Converting Oriient's building coordinates to ENU ones
const { e, n } = buildingToENU(buildingToEnuRotation, { x: 100, y: 50 });
console.log(`e:${e}, n:${n}`);
Converting from ENU to ECEF
const { x, y, z } = enuToECEF({
enuE: -24.32259675383305,
enuN: 1.09125667407583e2,
enuU: 0,
buildingLat: buildingOrigin.latitude,
buildingLng: buildingOrigin.longitude,
buildingAlt: buildingOrigin.altitude,
});
console.log(`x:${x}, y:${y}, z: ${z}`);
converting from ENU to geodetic
const {lat, lng, alt} = enuToGeodetic(-24.32259675383305, 1.09125667407583e2, 0, buildingOrigin.latitude, buildingOrigin.longitude, buildingOrigin.altitude);
console.log(`lat:${lat} lng: ${lng} alt: ${alt}`);