How to use the @esri/arcgis-rest-auth.ApplicationSession function in @esri/arcgis-rest-auth

To help you get started, we’ve selected a few @esri/arcgis-rest-auth examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Esri / arcgis-rest-js / demos / batch-geocoder-node / batch-geocode.js View on Github external
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