Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return locations.reduce((locMap, loc) => {
const locFields = {};
locFields['x'] = loc.location.x;
locFields['y'] = loc.location.y;
// ref: https://developers.arcgis.com/rest/geocode/api-reference/geocoding-service-output.htm#ESRI_SECTION1_42D7D3D0231241E9B656C01438209440
locFields['geocode_score'] = loc.score;
locFields['match_type'] = loc.attributes.Addr_type;
locMap[loc.attributes.ResultID] = locFields;
return locMap;
}, resMap);
}, {});
// IMPLEMENTATION!
// Instantiate an ApplicationSession to run Geocoding service
const session = new ApplicationSession({
clientId: config.clientId,
clientSecret: config.clientSecret
});
// Parse and geocode
parseCsv(config.csv)
.then(data => {
// Build address requests
const addrs = getAddresses(data, config.fieldmap);
const chunks = chunkGeocode(addrs, 1000);
// Geocode
const promises = chunks.map(chunk =>
bulkGeocode({
addresses: chunk,
authentication: session