Skip to content

Instantly share code, notes, and snippets.

@wilsaj
Created April 3, 2017 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wilsaj/bc409ea6db702eefabf71b423eab8aff to your computer and use it in GitHub Desktop.
Save wilsaj/bc409ea6db702eefabf71b423eab8aff to your computer and use it in GitHub Desktop.
weather-alerts-geojson with user agent
'use strict';
var es = require('event-stream');
var fs = require('fs');
var parser = require('weather-alerts-parser');
var request = require('request');
var through = require('through');
var geojson = require('../lib/index.js');
function cleanProperties() {
var remove = [
'geocode',
'parameter',
'polygon'
];
return through(function write(featureCollection) {
featureCollection.features.forEach(function(feature) {
remove.forEach(function(remove) {
delete feature.properties[remove];
});
});
this.queue(featureCollection);
});
}
request.get({
url: 'http://alerts.weather.gov/cap/us.php?x=1',
headers: {
'User-Agent': 'lol',
}
})
.pipe(parser.stream())
.pipe(geojson.stream({'stylize': true}))
.pipe(cleanProperties())
.pipe(geojson.collect({'sort': true, 'flatten': true}))
.pipe(es.stringify())
.pipe(process.stdout);
@poblabs
Copy link

poblabs commented Apr 3, 2017

Thanks for the updated gist! Much appreciated. I also thoroughly enjoy the user agent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment