function getIdsFromFile()

in scripts/generate-manifest.js [201:219]


function getIdsFromFile(dataDir, file, fields) {
  const fieldMap = {};
  const fieldsWithIds = fields.filter(field => !field.skipCopy);

  if (fieldsWithIds.length == 0) return fieldMap;

  // Only read the dataset if there are identfiers to return
  const json = JSON.parse(readFileSync(`${dataDir}/${file}`, 'utf8'));
  const features = json.features || json.objects.data.geometries;
  for (const { name } of fieldsWithIds) {
    fieldMap[name] = new Set(); // Probably unnecessary but ensures unique ids
  }
  for (const feature of features) {
    for (const { name } of fieldsWithIds) {
      fieldMap[name].add(feature.properties[name]);
    }
  }
  return fieldMap;
}