@nsc-earth-2/calculation
v1.0.3
Published
@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.
Downloads
6
Readme
@nsc-earth-2/calculation
@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
Install via npm:
npm install @nsc-earth-2/calculation --save
Usage
Import the @nsc-earth-2/calculation
module in your project, then instantiate the calculation class for calculate.
GroundSurfaceArea
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);
ShadowArea
Used for calculation of projected area.
import { ShadowArea } from "@nsc-earth-2/calculation";
const area = new ShadowArea(positions);
GroundSurfaceDistance
Used for surface-to-ground distance calculations.
import { GroundSurfaceDistance } from "@nsc-earth-2/calculation";
const surfaceDistance = new GroundSurfaceDistance();
HorizontalDistance
Used for horizontal distance calculations.
import { HorizontalDistance } from "@nsc-earth-2/calculation";
const distanceSurfaceMeasure = new HorizontalDistance(positions);
SlopeDistance
Distance calculation for tilt.
import { SlopeDistance } from "@nsc-earth-2/calculation";
const distanceSurfaceMeasure = new SlopeDistance(positions);
SlopeAngleCalculate
Used for calculation of slope angle.
import { SlopeAngleCalculate } from "@nsc-earth-2/calculation";
const distanceSurfaceMeasure = new SlopeAngleCalculate(positions);
API
GroundSurfaceArea
Used for floor area calculations.
Constructor
constructor(viewer: Viewer, splitNum?: number)
Create a GroundSurfaceArea Instance
Parameters:
splitNum
(optional):interpolated values,default 10,type isnumber
。
Methods
getSurfaceArea(positions:[],unit?:CalculationUnits ): number
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.
ShadowArea
Used for projected area calculations
Constructor
constructor()
Create a ShadowArea Instance
Methods
getAreaByTurf(positions:[],unit?:CalculationUnits ): number
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
.
HorizontalDistance
Used for horizontal distance calculations.
Constructor
constructor()
Create a HorizontalDistance Instance
Methods
getSumHorizontalDistance(points: any, unit: CalculationUnits): number
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.
GroundSurfaceDistance
Used for surface-to-ground distance calculations.
Constructor
constructor()
Create a GroundSurfaceDistance Instance
Methods
async getSumStraightDistance(points: [any],unit: CalculationUnits): Promise<number>
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.
SlopeAngleCalculate
Used to calculate the slope angle between two points.
Constructor
constructor()
Create a SlopeAngleCalculate Instance
Methods
getSlopeAngle(startPoint: any, endPoint: any): number
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.
Notes
- 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.