npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nsc-earth-2/calculation

v1.0.2

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

160

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/calculationmodule 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 is number

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.