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

@nbbj/stroll

v2.3.0

Published

NodeJS computational library for finding the optimal walking path to be as exposed to nature as possible.

Downloads

12

Readme

first path

Generic badge Generic badge Generic badge NPM

npm npm bundle size npm npm2

GitHub issues David Azure DevOps builds GitHub last commit

This is a computational library which finds the most nature-filled walks/paths that can be taken in order to stimulate creativity and boost mental health. Pathfinding is performed via Weighted Graph computation, with weights being given for characteristics such as proximity to parks, and amount of nature in the field of view.

Originally started at the TT West AEC Hackathon in Seattle, 2019.

Proof of Concept

Currently, the library computes paths within the boundaries of the user-defined grid (created from the user's origin and desired radius). Future development will target more route-finding options such as loops, distance constraints, sun/shade preferences, etc.

first path

Usage

To use this module, install locally using the command below, or clone this repository and import the .js files directly from source.

npm i @nbbj/stroll

Environment Variables & API Provisioning

Before using this module, the GMAPS_KEY environment variable must be set on your machine with your specific Google Maps API Key. Additionally, you must provision your Google account for access to these specific Google Maps APIs: Directions API, Geocoding API, Maps JavaScript API, Places API, and Street View Static API.

This package will not working without the following configurations and provisions, so please make sure to check those settings if you are getting errors.

User API Usage Notice

Please be advised that this module will request Google Street View images from the Google Maps API, and therefore WILL incur a cost. Managing the cost and/or other API-specific limits/resource constraints are entirely the responsibility of the user using this module.

Imports

Imports can be done through the aggregating index.js file or via individual members.

Full Import

const stroll = require('./index.js'); // from source
const stroll = require('@nbbj/stroll') // from npm

// es6
import * as Stroll from "../src"; // from source
import * as Stroll from from "@nbbj/stroll"; // from npm

Individual Import

// from source
const Color = require('./Color');
const Place = require('./Place');
const Weather = require('./Weather');

const { Route } = require('@nbbj/stroll');
const { Color } = require('@nbbj/stroll');
import { Weather, Place, Color, Route } from "@nbbj/stroll"; // es6

Methods

The collection below is just a sample of methods and may be out of date. For the most recent examples, please see the samples folder in the root directory of this repository.

Pathfinding Data

Building graphs and calculating paths of travel.

// Create a custom grid around a origin lat/long
let grid = Geometry.PointGrid(47.660273, -122.409887, 1, 0.5);

Graph.GetData(grid) // get data for each lat/long point on the grid
  .then(grid => Graph.Create(grid, 0.9)) // create the weighted graph from the grid data
  .then(graph => Route.PathsAll(graph)) // find all possible paths
  .then(paths => Route.ParsePaths(paths)) // return sorted paths
  .then(results => {
    console.log(results); // do something with results (array of all possible paths)
  }).catch(err => console.error(err));

Place Data

Place data for nearby public parks/green amenities. Used for finding public parks and other notable green spaces near any point on earth (lat/long).

Place.ParkSearch(47.660273, -122.409887, 1000).then(results => {
  console.log(results);
});

Weather Data

Weather data analysis. Currently not used in the nature score calculation, but itended to be added.

let sunData = Weather.SunPositionToday(47.6694956, -122.31547389999999);
console.log(sunData);

Color Palette Analysis

Color palette analysis in field of view. Used for calculating how much of the visible color palette at any point on earth (lat/long) is green (nature).

Color.Palette(46.414382, 10.013988, 151.78).then(colors => {
  console.log(colors);
});
Color.PaletteNames(46.414382, 10.013988).then(names => {
  console.log(names);
})
Color.PaletteAnalysis(47.660259, -122.408417).then(result => {
  console.log(result);
})

Working Model

The working model to compute the "Nature Score" of a given point in the urban environment is composed of the following:

  1. Green Score - What percentage of an image's dominant color palette is green in color.
  2. Park Score - How many public parks/green spaces are near the given point, as computed by Google Maps.

Next steps for development are to add the following criteria to the "Nature Score" computation:

  1. Trees - Use a ML model with transfer learning to recognize natural feature such as trees, lakes, etc. which may not be captured by the "Green Score" in the color palette.
  2. Sun/Shade - Compute "sunny-ness"/"shady-ness" of a given route.
  3. Rain/Cover - Compute a route based on cover during a rain event.

Development

Building

The module can be built by running npm run build in the root directory of this repository. Documentation is built using the Documentation module from npm, and by running npm run docs in the root directory of this repository. This will create markdown and HTML documentaion.

Testing

Testing is handled using jest and code coverage is evaluated using nyc. Tests can be initiated by running npm test in the root directory of this repository.

Commands

The following commands are available during development.

npm test # run tests with Jest
npm run coverage # run tests with coverage and open it on browser
npm run lint # lint code
npm run docs # generate docs
npm run build # transpile code