@nsc-earth-2/calculation is a calculation and analysis based on Cesium. It supports calculation and analysis of distance, area and angle. It is simple and convenient to use.
Install via npm:
npm install @nsc-earth-2/calculation --save
Import the @nsc-earth-2/calculation
module in your project, then instantiate the calculation class for calculate.
Used for floor area calculations.
import { Viewer } from "cesium";
import { GroundSurfaceArea } from "@nsc-earth-2/calculation";
const viewer = new Viewer("cesiumContainer");
const areaSurface = new GroundSurfaceArea(viewer, 10);
Used for calculation of projected area.
import { ShadowArea } from "@nsc-earth-2/calculation";
const area = new ShadowArea(positions);
Used for surface-to-ground distance calculations.
import { GroundSurfaceDistance } from "@nsc-earth-2/calculation";
const surfaceDistance = new GroundSurfaceDistance();
Used for horizontal distance calculations.
import { HorizontalDistance } from "@nsc-earth-2/calculation";
const distanceSurfaceMeasure = new HorizontalDistance(positions);
Distance calculation for tilt.
import { SlopeDistance } from "@nsc-earth-2/calculation";
const distanceSurfaceMeasure = new SlopeDistance(positions);
Used for calculation of slope angle.
import { SlopeAngleCalculate } from "@nsc-earth-2/calculation";
const distanceSurfaceMeasure = new SlopeAngleCalculate(positions);
Used for floor area calculations.
Create a GroundSurfaceArea Instance
Parameters:
-
splitNum
(optional):interpolated values,default 10,type isnumber
。
Calculate the area of a polygon that touches the ground.
Parameters:
-
positions
:An array composed of points. Each point is an array of longitude,latitude and height in the form of[lon,lat,height]。 -
unit
:determined by the parameters passed in Return value:area, the unit is specified by the parameter, and the default is meters.
Used for projected area calculations
Create a ShadowArea Instance
Calculate the projected area of a polygon.
Parameters:
-
positions
:An array composed of points. Each point is an array of longitude,latitude and height in the form of[lon,lat,height]。 -
unit
:determined by the parameters passed in
Return value:area, the unit is specified by the parameter, and the default is meters
.
Used for horizontal distance calculations.
Create a HorizontalDistance Instance
Calculate the horizontal distance of a collection of points.
Parameters:
-
points
:An array composed of points. Each point is an array of longitude,latitude and height in the form of[lon,lat,height]。 -
unit
:Unit, default is meters.
Return value:The total horizontal distance, the unit is specified by the parameter, and the default is meters.
Used for surface-to-ground distance calculations.
Create a GroundSurfaceDistance Instance
Calculate the ground-gluing distance of a point set.
Parameters:
-
points
:An array composed of points. Each point is an array of longitude,latitude and height in the form of[lon,lat,height]。 -
unit
:Unit, default is meters.
Return value:The total distance of the point set to the ground, the unit is specified by the parameter, and the default is meters.
Used to calculate the slope angle between two points.
Create a SlopeAngleCalculate Instance
Calculate the slope value at two points.
Parameters:
-
startPoint
:Array consisting of points,[lon,lat,height]。 -
endPoint
:Array consisting of points,[lon,lat,height]。
Return value:The slope value between two points.
- This tool is based on Cesium and requires the Cesium library to be imported into the project.
- Please make sure you understand the basics of Cesium and how to create a Viewer before using the measuring tool.
- Before using the measuring tool, other operations that may affect the interaction, such as camera roaming and scene rotation, should be stopped.
- Please be aware of the performance of the browser during use. Excessive drawing may cause the browser to crash or freeze.
- The current version only supports distance and area measurement. If you need to implement other functions, you can extend it yourself.
- The tool code is open source. If you have any questions or suggestions, please submit an issue or PR on the GitHub project page.