https://github.com/osmlab/osm-stream
Minutely clientside OpenStreetMap changeset streams
https://github.com/osmlab/osm-stream
Last synced: about 1 year ago
JSON representation
Minutely clientside OpenStreetMap changeset streams
- Host: GitHub
- URL: https://github.com/osmlab/osm-stream
- Owner: osmlab
- License: unlicense
- Created: 2013-03-14T19:33:04.000Z (over 13 years ago)
- Default Branch: gh-pages
- Last Pushed: 2023-04-15T11:26:42.000Z (about 3 years ago)
- Last Synced: 2025-04-18T12:10:01.171Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 171 KB
- Stars: 19
- Watchers: 7
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
## OSM Stream
Uses the [Overpass API](http://overpass-api.de/) for
[Augmented Diffs](http://wiki.openstreetmap.org/wiki/Overpass_API/Augmented_Diffs),
loads data with CORS and exposes a stream.
## using
Without browserify: copy `osmstream.js`. That works as an `osmStream` global
and with UMD.
With browserify `npm install osm-stream`
## api
`s.once(function(err, data) { }, [bbox])`
Get one batch of changes right now.
`s.run(function(err, stream), duration, [dir], [bbox], [maxRetries])`
duration is how long between runs: default 1 minute
dir is direction: either `1`, the default, or `-1` for rewind.
maxRetries: How often to retry fetching the current diff before skipping it.
`s.runFn(function(err, stream), duration, [dir], [bbox], [maxRetries])`
Same as `.run` but instead of returning a stream that pipes objects, calls
the callback once per object.
duration is how long between runs: default 1 minute
dir is direction: either `1`, the default, or `-1` for rewind.
maxRetries: How often to retry fetching the current diff before skipping it.
## example
```js
var osmStream = require('osm-stream');
// re-request every 60s
osmStream
.run(function(err, stream) {
stream.on('data', function(d) {
console.log(d);
});
});
// re-request every 60s
// callback-style interface
osmStream
.runFn(function(err, data) {
// ...
});
// one-time request
osmStream
.once(function(err, d) {
console.log(d);
});
```
The stream returned uses [through](https://github.com/dominictarr/through), so
you can end it and that will also stop the run cycle.
### See Also
* [osm-stream-process](https://github.com/iandees/osm-stream-process) in Python
### As Seen
* [Show Me The Way](http://osmlab.github.io/show-me-the-way/) [source](https://github.com/osmlab/show-me-the-way)
* [OSM Live Map](http://osmlab.github.io/osm-live-map/) [source](https://github.com/osmlab/osm-live-map)
* [OSMBuzz](http://spatialbit.com/osmbuzz/)