Skip to content

Commit

Permalink
feat(batch): support importing geojson files
Browse files Browse the repository at this point in the history
  • Loading branch information
missinglink committed Jan 10, 2023
1 parent a269b5d commit 0d17db7
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion lib/parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var _ = require('lodash');
var minimist = require( 'minimist' );

var peliasConfig = require( 'pelias-config' ).generate();
const logger = require('pelias-logger').get('openaddresses-import');

/**
* Interprets the command-line arguments passed to the script.
Expand Down Expand Up @@ -99,7 +100,23 @@ function getFullFileList(peliasConfig, args) {
return glob.sync( args.dirPath + '/**/*.{csv,geojson}' );
} else {
// otherwise return the requested files with full path
return files.map(function(file) {
return files.map(file => {

// remove file extension from source
const source = file.replace(/\.[^\/.]+$/, '');

// source definitions previously required a file extension.
// please remove file extensions from your ~/pelias.json file
// to silence these warning messages.
if (source !== file) {
logger.warn(`source definitions no longer require a file extension '${file}'`);
}

// search for files matching this source id, ending in either .geojson or .csv
const found = glob.sync(`${source}.{csv,geojson}`, { cwd: args.dirPath, absolute: true });
if (!_.isEmpty(found)) { return _.last(found); } // results are sorted, prefer .geojson

// no matching files were found, return a non-matching absolute path
return path.join(args.dirPath, file);
});
}
Expand Down

0 comments on commit 0d17db7

Please sign in to comment.