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

globe-elevation

v1.0.5

Published

NodeJS module to retrieve elevation from "Global Land One-km Base Elevation Project"

Downloads

11

Readme

nodejs-globe-elevation

NodeJS module to retrieve elevation from "Global Land One-km Base Elevation Project"

Requirements

You need to download elevation data of the "Global Land One-km Base Elevation Project".

Project's Homepage: http://www.ngdc.noaa.gov/mgg/topo/globe.html

Load GLOBE's data here: https://www.ngdc.noaa.gov/mgg/topo/gltiles.html

Please download and extract GLOBE's files to a directory. This module searches for data files in the folowing paths:

/usr/share/GLOBE-elevation
/usr/share/local/GLOBE-elevation
[current project's directory]/GLOBE-elevation
[current project's directory]/elevation

You may provide any other directory on initializiation.

Installation

Simply install this module with npm

npm install globe-elevation

To install it globally run

npm install -g globe-elevation

Usage

'use strict';
var elevation= require('globe-elevation');
elevation.init({
  dataPath: "path to GLOBE's data files",
  openFileTimout: 1000
});

console.log('Elevation [ 0, 0 ] =? 0:', elevation.getElevation([ 0, 0 ]));
console.log('Elevation at 51.7894(lat), 11.1416(lng) =? 123:', elevation.getElevation({ lat: 51.7894, lng: 11.1416}));
console.log('Elevation at (35.0(lat), -106.6(lng)), (35.1(lat), 106.5(lng)) =? 1624.2:', elevation.getElevation([ { lat: 35.0, lng: -106.6 }, [ () => -106.5, () => 35.1 ] ]));

Initialization

Initialization is optional if your data files are located at one of the above mentioned directories. If not specify it with dataPath.

Furthermore we've optimized file operation for multiple calculations. You may specify with openFileTimeout a timeout in ms, for which any file will be kept open after last access. You may specify 0 to disable this feature (default is 1 second). You should not use much higher values because nodejs waits on process exit for any pending timeout before exiting.

getElevation( location [, onError] )

You may specify a single location or an array of two locations (bounding box).

Any location may be in the format [ lng, lat ] or { lng: lng, lat: lat } or a function returning such values. lat and lng may be functions itselfes returning the corresponding values.

Attention: Please note, that we chose [ lng, lat ] for arrays, because it's MongoDB's internal format for geo locations.

If you specify a bounding box, lng and lat will be iterated over every value inbetween in 1/120 grad steps. The result is the mean value of all elevations.

The optional onError function is called whenever an error occured. It's return value wil be the result of getElevation