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

query-geo-boundary

v0.3.6

Published

A Node.js module to query the geo (administrative area) boundary from OSM nominatim and/or overpass (with a RegExp & Map based XML parser & geojson builder for geo boundary re-construction, <b>3X</b> faster than <a href="https://github.com/tyrasd/osmtogeo

Downloads

18

Readme

QueryGeoBoundary

A Node.js library to query the geo (administrative area) boundary from OSM nominatim and/or overpass.

Usage

const queryGeoBoundary = require('query-geo-boundary');
queryGeoBoundary(`${geo_name}`).then(boundaries => {
  // your post-processing here
}).catch(err => {
  // your error handling here
});

API

Prototype: queryGeoBoundary(geoName, options)

  • geoName: name of the geo you want to obtain its boundary
  • options: optional. only support source option right now, you can use {source: 'overpass'} to mandata it to go through overpass service (very slow, and has concurrency limitation), by default (and highly-recommended) it will use openstreetmap nominatim service.

Return: an array of osm places with boundary geojson (the place attributes include displayname, lat/lon, boundingbox, and the boundary geojson under "geojson"). A typical result is as below:

  [{"place_id":"158973269",
  "licence":"Data © OpenStreetMap contributors, ODbL 1.0. http://www.openstreetmap.org/copyright",
  "osm_type":"relation",
  "osm_id":"3468769",
  "boundingbox":["35.7163774","36.2834811","118.9952393","119.7232973"],"lat":"35.9989034","lon":"119.342173467495",
  "display_name":"诸城市, 潍坊市, 山东省, 中国",
  "class":"boundary",
  "type":"administrative",
  "importance":0.43599614036271,
  "icon":"https://nominatim.openstreetmap.org/images/mapicons/poi_boundary_administrative.p.20.png",
  "geojson":{"type":"Polygon","coordinates":[[[118.9952393,36.0120809],...,[118.9952393,36.0120809]]]}}]

Notice: 'coz it's very common for an administrative uint has the same name with the others, if you want to get the boundary of exactly that place, please supply as much as possible hierarchical adminstrative information in name, e.g., using "Ikeda, Hokkaido" rather than "Ikeda", or you can solve this kind of ambiguity by introducing human interference.

Node.JS Requirement

  • Node.JS 4.x+ with ES6 features supports

Dependency

  • request - basic version and basic function (can be easily replaced by built-in http module)
  • osm2geojson-lite - a regex and map accelerated xml parsing & geojson reconstruction utility, much faster than xmldom, osmtogeojson in combination to convert an OSM XML to geojson