Skip to content

Conversation

@ingalls
Copy link
Member

@ingalls ingalls commented Sep 19, 2023

Context

Update ESRI Dump to use GeoJSON internally

  • First step in fixing issues like: Update city_of_kingston.json openaddresses#6943
  • Output GeoJSON from ESRI Dump
  • Convert existing ESRI Dump fixtures to GeoJSON
  • Update GeoJSON parsing (geojson.py) to support FeatureCollection or Geojson+LD
  • Probably fix a lot of tests.

import fs from 'node:fs';

let file = String(fs.readFileSync('/home/null/Development/openaddresses/batch-machine/openaddr/tests/conforms/lake-man-split2.csv'))
    .split('\n')
    .map((line) => {
        return line.split(',');
    });

const headers = file.splice(0, 1)[0];
file.pop();

file = file.map((line) => {
    const res = {}
    for (let i = 0; i < headers.length; i++) {
        res[headers[i]] = line[i];
    }

    res['OA:x'] = Number(res['OA:x'])
    res['OA:y'] = Number(res['OA:y'])

    return {
        type: 'Feature',
        properties: res,
        geometry: {
            type: 'Point',
            coordinates: [ res['OA:x'], res['OA:y'] ]
        }
    };
});

console.log(file.map((line) => JSON.stringify(line)).join('\n'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants