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-search-data-export

v1.1.1

Published

A library for Node.js to generate offline search data for use in a public transport app.

Downloads

17

Readme

osm-search-data-export

A library for Node.js to generate offline search data for use in a public transport app.

NPM version Package dependencies GitHub license

Motivation

This project is part of a set of tools to provide travel data in countries where public transport works on demand and neither bus stops nor timetables exist. Check out https://github.com/trufi-association

Usage

Node.js

const searchDataExport = require('osm-search-data-export');
const {
  pbfInput,
  overpassInput,
  memoryInput,
  multiOutput,
  jsonOutput,
  jsonCompactOutput,
  sqliteOutput,
  memoryOutput,
} = searchDataExport;

// Read from PBF and output as compact JSON
searchDataExport(
  pbfInput({ inPath: './data.pbf' }),
  jsonCompactOutput({ outPath: './search-compact.json'})
);

// Get fresh data from Overpass API and output into JSON and SQLite
searchDataExport(
  overpassInput({ bbox: '-21.604769,-64.819679,-21.477032,-64.631195' }), // Tarija
  multiOutput(
    jsonOutput({ outPath: './search.json'}),
    sqliteOutput({ outPath: './search.db' }),
    jsonCompactOutput({ outPath: './search-compact.json'}),
  )
);

// Transform data without the file system and use a custom config to control included objects
const result = {};
const myConfig = {
  // Only include certain POIs
  poiTypeTags: [
    'amenity',
    'shop',
  ],
  // Only include motorways
  pathTypes: [
    'motorway',
  ],
};
searchDataExport(
  memoryInput({ data: [ /* ... */ ]}),
  memoryOutput({ outRef: result }),
  myConfig
);

CLI

$ osm-search-data-export --input pbf --inpath data.pbf --output json --outpath search.json
; Wrote to file search.json
$ osm-search-data-export --input overpass --bbox -21.604769,-64.819679,-21.477032,-64.631195 --output sqlite --outpath search.db
; Wrote to file search.db

Run osm-search-data-export --help for more details.

Docker

docker build . --tag osm-search-data-export:latest

docker run --volume /tmp:/data osm-search-data-export \
  --input overpass --bbox "-21.604769,-64.819679,-21.477032,-64.631195" \
  --output json --outpath /data/search.json
           
; Wrote to file /tmp/search.json

Input types

  • json - JSON file that holds an array of OSM objects
  • overpass - Fetch OSM data from Overpass using a bounding box
  • pbf - OSM data in PBF export file
  • memory - Use data from a local variable

Output types

  • json - Write search data to a JSON file
  • json-compact - Write search data to a JSON file in a more compact style
  • sqlite - Write search data into a SQLite db file');
  • memory - Write data into a local variable
  • multi - Wraps multiple outputs

Config

Please consult src/config.js for a list of whitelisted types that will be included in the resulting file. See Usage on information on how to override these values.