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

sun-horizon

v1.1.4

Published

Horizon profile and sun path form a lat lng point

Downloads

27

Readme

sun-horizon 🌄

License Version Build Status

🌄 Get Horizon profile based on topography from a (latitude, longitude) point.

🙌🏻 This module is heavily based on node-hgt.

☕️ Support

🏁 Install

npm install sun-horizon

🏃‍♂️ Usage

✅ Call init() function before any other operations.

🗄 sun-horizon uses a cache directory of HGT files (default sun-horizon-data/).

💻 This module supports javascript or typescirpt.

const sunHorizon = require('sun-horizon');

sunHorizon.init();
const horizon = await sunHorizon.getHorizon({"lat": 45, "lng": 5});

or

import { getHorizon, init } from 'sun-horizon';

init();
const horizon = await getHorizon({lat: 45, lng: 5});

Types

LatLng

{
  lat: number;
  lng: number;
}

HorizonOptions

{
  azimuthOptions?: AzimuthOptions;
  highestPointOptions?: HighestPointOptions;
}

AzimuthOptions

{
  azimuthStart?: number; // degree, 0 is North, 90 Eeast
  azimuthEnd?: number; // degree
  azimuthTick?: number; // degree
}

HighestPointOptions

{
  distanceMax?: number; // meter
  distanceTick?: number; // meter
}

HorizonPoint

{
  azimuth: number; // degree
  angle: number; // degree, 0 is same elevation as origin
  altitude: number; // meter

  latLng?: LatLng;
}

Horizon

{
  origin: LatLng;
  elevationProfile: HorizonPoint[];
}

CacheData

{
  bytes: number;
  files: number;
}

Functions

init

init(cacheDirectory?: string): void

Initialize module and create the required cache directory (default is sun-horizon-data/) + populate with a .gitignore file.

getHorizon

getHorizon(origin: LatLng, options?: HorizonOptions): Promise<Horizon>
const grenoble: LatLng = {
  lat: 45.185739,
  lng: 5.736236
}
const horizon = await getHorizon(grenoble);
console.log(horizon.elevationProfile.map(point => point.altitude));

highestPointInAzimuth

highestPointInAzimuth(origin: LatLng, azimuth: number, options?: HighestPointOptions): Promise<HorizonPoint>
const origin: LatLng = {
  lat: 45.185739,
  lng: 5.736236
}
const azimuth = 90; // East
const point = await highestPointInAzimuth(origin, azimuth);

getAltitude

getAltitude(latLng: LatLng): Promise<number>
const origin: LatLng = {
  lat: 45.185739,
  lng: 5.736236
}
const altitude = await getAltitude(origin); // in meter

getCacheData

Return number of files and total size in bytes. (See CacheData)

getCacheData(): Promise<CacheData>
const cache = await getCacheData();

cleanCache

Delete all .hgt cache files and return number of deleted files.

cleanCache(): Promise<number>
const deletedFiles = await cleanCache();