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

osm-is-area

v1.0.5

Published

determine if an OpenStreetMap entry is an area or not

Downloads

22

Readme

determine if an OpenStreetMap entry is an area or not.

this package uses osm-polygon-features to determine if some closed ways should be treated as polygons or lines.

example

var osmIsArea = require('osm-is-area')

// first and last ref match, but { highway: 'service' } is not an area:

console.log(osmIsArea({
  type: 'way',
  id: 4421943,
  tags: { highway: 'service' },
  refs: [ 27119458, 1764217171, 27119461, 1069372913,
    1764230257, 5530415689, 1764230254, 27119458]
})) // false


// first and last ref match; { waterway: 'riverbank' } is a valid area:

console.log(osmIsArea({
  type: 'way',
  id: 23873915,
  tags: { waterway: 'riverbank' },
  refs: [ 3584796914, 4856390070, 4856390069, 4856390067, 258759210, 997025704, 997024369, 3584796914 ]
})) // true

// first and last ref don't match - not a closed way:

console.log(osmIsArea({
  type: 'way',
  id: 4421935,
  tags: { highway: 'primary', surface: 'asphalt' },
  refs: [ 746891652, 408306337, 27119389, 1687103099, 730024891, 1035333171, 746891666 ]
})) // false

// first and last ref match; { natural: 'wood' } is a valid area:

console.log(osmIsArea({
  type: 'way',
  id: 23874706,
  tags: { name: 'Щербачевский лес', natural: 'wood' },
  refs: [ 1125622707, 1007659859, 1125622501, 1125622605, 1125622588, 1007659898, 1125622707 ]
})) // true

// first and last ref match; { boundary: 'protected area' } is a valid area:

console.log(osmIsArea({
  type: 'way',
  id: 34333478,
  tags: { name: 'Лісовий заказник «Григорівський бір»', boundary: 'protected_area' },
  refs: [ 393849373, 1010883354, 1010883623, 393849376, 1010883341, 393849377, 393849373 ]
})) // true

to try this example on your own machine, clone this repository, navigate to the directory you cloned into, and run npm run example.

api

var osmIsArea = require('osm-is-area')

osmIsArea(entry)

takes an osm entry object and returns true or false.

input osm objects should be formatted as osm-pbf-parser returns them. specifically, this module expects:

  • type - a string specifying 'node', 'way', or 'relation'
  • tags - an object mapping osm tag keys to values
  • refs - an array of osm id's as numbers (only relevant for ways)
  • members - an array of member objects (only relevant for relations)

the only thing that's relevant about the members array is whether it's empty (module will return false if this is the case).

this module assumes that all relations of type 'multipolygon' are areas, and that no other relations are areas. learn more about relation:multipolygon.

license

MIT