-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathimport.js
52 lines (39 loc) · 1.77 KB
/
import.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* @file Entry-point script for the OpenAddresses import pipeline.
*/
var peliasConfig = require( 'pelias-config' ).generate(require('./schema'));
var logger = require( 'pelias-logger' ).get( 'openaddresses' );
var parameters = require( './lib/parameters' );
var importPipeline = require( './lib/importPipeline' );
const adminLookupStream = require('pelias-wof-admin-lookup');
// Pretty-print the total time the import took.
function startTiming() {
var startTime = new Date().getTime();
process.on( 'exit', function (){
var totalTimeTaken = (new Date().getTime() - startTime).toString();
var seconds = totalTimeTaken.slice(0, totalTimeTaken.length - 3);
var milliseconds = totalTimeTaken.slice(totalTimeTaken.length - 3);
logger.info( 'Total time taken: %s.%ss', seconds, milliseconds );
});
}
var args = parameters.interpretUserArgs( process.argv.slice( 2 ) );
const adminLayers = ['neighbourhood', 'borough', 'locality', 'localadmin',
'county', 'macrocounty', 'region', 'macroregion', 'dependency', 'country',
'empire', 'continent'];
if( 'exitCode' in args ){
((args.exitCode > 0) ? console.error : console.info)( args.errMessage );
process.exit( args.exitCode );
} else {
startTiming();
if (peliasConfig.imports.openaddresses.hasOwnProperty('adminLookup')) {
logger.info('imports.openaddresses.adminLookup has been deprecated, ' +
'enable adminLookup using imports.adminLookup.enabled = true');
}
var files = parameters.getFileList(peliasConfig, args);
const importer_id = args['parallel-id'];
let importer_name = 'openaddresses';
if (importer_id !== undefined) {
importer_name = `openaddresses-${importer_id}`;
}
importPipeline.create( files, args.dirPath, adminLookupStream.create(adminLayers), importer_name);
}