0.0.4 • Published 10 months ago

gtfs-polygon-filter v0.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

gtfs-polygon-filter

Filters routes in a GTFS feed based on whether they overlap with a GeoJSON Polygon (or MultiPolygon).

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 any of the provided polygons.

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

install

npm i gtfs-polygon-filter

use

import gtfsPolygonFilter from 'gtfs-polygon-filter'
import { openDb } from 'gtfs'
import totallyAwesomePolygyon from './somewhere'

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

const routesThatAreAtLeastTwoThirdsInsideMyPolygon = await gtfsPolygonFilter({
  polygon: totallyAwesomePolygon,
  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

0.0.4

10 months ago

0.0.3

10 months ago

0.0.2

10 months ago

0.0.1

10 months ago