Skip to content

Commit

Permalink
add epsg info metadata to features
Browse files Browse the repository at this point in the history
  • Loading branch information
Contra committed Jun 30, 2016
1 parent f858072 commit 3fe276c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
12 changes: 11 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ function processFilePath(context, file, cb) {
cb = (0, _once2.default)(cb);
var ftp = context.ftp;

var onBoundary = function onBoundary(doc, done) {
// workaround for missing crs info
doc.crs = {
type: 'name',
properties: {
name: 'EPSG:4326'
}
};
context.onBoundary(file.type, doc, done);
};
ftp.get(file.path, function (err, stream) {
if (err) return cb(err);

Expand All @@ -102,7 +112,7 @@ function processFilePath(context, file, cb) {
srcStream.once('end', function () {
var docs = JSON.parse(_buffer.Buffer.concat(chunks)).features;
debug(' -- ' + _chalk2.default.cyan('Parsed ' + file.path + ', inserting ' + docs.length + ' boundaries now...'));
_async2.default.forEach(docs, _async2.default.ensureAsync(context.onBoundary.bind(null, file.type)), cb);
_async2.default.forEach(docs, _async2.default.ensureAsync(onBoundary), cb);
});

stream.resume();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "census-boundaries",
"version": "1.0.4",
"version": "1.0.5",
"description": "Downloads and converts US Census TIGER data representing all boundaries in the United States",
"main": "dist/index.js",
"keywords": [
Expand Down
12 changes: 11 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ function processObject(context, object, cb) {
function processFilePath(context, file, cb) {
cb = once(cb)
const { ftp } = context
const onBoundary = (doc, done) => {
// workaround for missing crs info
doc.crs = {
type: 'name',
properties: {
name: 'EPSG:4326'
}
}
context.onBoundary(file.type, doc, done)
}
ftp.get(file.path, (err, stream) => {
if (err) return cb(err)

Expand All @@ -61,7 +71,7 @@ function processFilePath(context, file, cb) {
srcStream.once('end', () => {
const docs = JSON.parse(Buffer.concat(chunks)).features
debug(` -- ${chalk.cyan(`Parsed ${file.path}, inserting ${docs.length} boundaries now...`)}`)
async.forEach(docs, async.ensureAsync(context.onBoundary.bind(null, file.type)), cb)
async.forEach(docs, async.ensureAsync(onBoundary), cb)
})

stream.resume()
Expand Down

0 comments on commit 3fe276c

Please sign in to comment.