gtfs-osm-filter

0.0.3 • Public • Published

gtfs-osm-filter

Filters routes in a GTFS feed based on whether they overlap with an OpenStreetMap relation (like a city, country or neighbourhood).

To find the OSM relation ID of a place, search for it on OpenStreetMap, then go to https://polygons.openstreetmap.fr/ and submit the relation ID to make sure the geometry of the area you want to cover has been generated.

It includes a route in the returned array, if overlapRatio (0.5 by default) of the stops on the route are within the bounds of the provided area.

Works with node-gtfs, requires an already open database connection to work.

install

npm i gtfs-osm-filter

use

import gtfsOsmFilter from 'gtfs-osm-filter'
import { openDb } from 'gtfs'

openDb(config) // see how to do this in node-gtfs readme

const routesThatAreAtLeastTwoThirdsInsideBerlin = await gtfsOsmFilter({
  relation: '62422' // Berlin, Germany
  routesFilter: {
    agency_id: '123', // gets passed into gtfs/getRoutes, to avoid looping through all routes in GTFS feed
  },
  overlapRatio: 0.67,
})

// [
//   {
//     route_id: 'cool_route',
//     agency_id: '123',
//     route_short_name: 'Cool Route',
//     ...
//   },
// ]

More detailed example here

Package Sidebar

Install

npm i gtfs-osm-filter

Weekly Downloads

0

Version

0.0.3

License

MIT

Unpacked Size

3.22 kB

Total Files

3

Last publish

Collaborators

  • zorapeteri