server/index.js
// Parse the parameter and call isodist
Parse the parameter and call isodist
Parse the parameter and call isodist
function run(options) {
options.data = _.keyBy(options.steps, 'distance');
	options.steps = _.map(options.steps, 'distance');
	let endpoint = '';
	if (options.provider === 'osrm') {
		endpoint = argv['osrm-endpoint'];
	} else if (options.provider === 'valhalla') {
		endpoint = argv['valhalla-endpoint'];
	}
	options = _.defaults(options, {
		deintersect: false,
		endpoint: endpoint,
		hexSize: 0.5,
		profile: 'car',
		provider: 'osrm',
		resolution: 0.2
	});
	if (VALID_PROVIDERS.indexOf(options.provider) === -1) {
		throw new Error(`Invalid provider (${options.provider})`);
	}
	switch(options.provider) {
		case 'osrm':
			if (argv['osrm-use-node-binding']) {
				if (!options.map) {
					log.fail('Missing OSRM map name, if no endpoint is given');
				}
				const mapName = Path.resolve(__dirname, `../data/osrm/${options.map}.osrm`);
				options.osrm = new OSRM(mapName);
			}
			break;
		case 'valhalla':
			if (!options.endpoint) {
				log.fail('Missing endpoint for provider: valhalla');
			}
			break;
	}
	return IsoDist(options.origin, options.steps, options);
}
function run ( options ) { options . data = _ . keyBy ( options . steps , 'distance' ) ; options . steps = _ . map ( options . steps , 'distance' ) ; let endpoint = '' ; if ( options . provider === 'osrm' ) { endpoint = argv [ 'osrm-endpoint' ] ; } else if ( options . provider === 'valhalla' ) { endpoint = argv [ 'valhalla-endpoint' ] ; } options = _ . defaults ( options , { deintersect : false , endpoint : endpoint , hexSize : 0.5 , profile : 'car' , provider : 'osrm' , resolution : 0.2 } ) ; if ( VALID_PROVIDERS . indexOf ( options . provider ) === - 1 ) { throw new Error ( ` ${ options . provider } ` ) ; } switch ( options . provider ) { case 'osrm' : if ( argv [ 'osrm-use-node-binding' ] ) { if ( ! options . map ) { log . fail ( 'Missing OSRM map name, if no endpoint is given' ) ; } const mapName = Path . resolve ( __dirname , ` ${ options . map } ` ) ; options . osrm = new OSRM ( mapName ) ; } break ; case 'valhalla' : if ( ! options . endpoint ) { log . fail ( 'Missing endpoint for provider: valhalla' ) ; } break ; } return IsoDist ( options . origin , options . steps , options ) ; }
Parse the parameter and call isodist
Parse the parameter and call isodist
/**
				 * Resolve the options path
				 */