whichstate

0.1.2 • Public • Published

GitHub Workflow Status npm version npm bundle size

whichState.js

Find out which US state a point (longitude, latitude) is in.

  • Light: < 1 MB
  • Fast: ~0.22 ms
  • Easy to use

Install

npm install whichstate

or

yarn add whichstate

Use

const whichState = require("whichstate");

const stateInitials = whichState.getInitials([-75.149982, 39.948900])
console.log(stateInitials) // PA

const stateName = whichState.getName([-75.149982, 39.948900])
console.log(stateName) // Pennsylvania

Development

Compile yarn compile
Test yarn test
Test Performance yarn performanceTest
Lint yarn lint
Publish to NPM npm publish

Credits

Ray casting algorithm in JS from https://github.com/substack/point-in-polygon
State Boundaries from https://www.census.gov/geographies/mapping-files/time-series/geo/carto-boundary-file.html and https://eric.clst.org/tech/usgeojson/ (simplified with https://mapshaper.org)

Readme

Keywords

none

Package Sidebar

Install

npm i whichstate

Weekly Downloads

2

Version

0.1.2

License

MIT

Unpacked Size

922 kB

Total Files

11

Last publish

Collaborators

  • rdvelazquez_npm