-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostprocess.ts
More file actions
23 lines (19 loc) · 657 Bytes
/
postprocess.ts
File metadata and controls
23 lines (19 loc) · 657 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { readJSON, writeJSON } from 'https://deno.land/x/flat/mod.ts';
const filename = Deno.args[0];
const data = await readJSON(filename);
const jsonFilename = filename.replace(/\.txt$/, '.json');
const jsonData = JSON.parse(data).SrchResults.slice(1);
const geojsonFilename = filename.replace(/\.txt$/, '.geojson');
const geoJSONData = {
type: 'FeatureCollection',
features: jsonData.map((d: any) => ({
type: 'Feature',
properties: d,
geometry: {
type: 'Point',
coordinates: d.LatLng.split(',').reverse().map(Number),
},
})),
};
await writeJSON(jsonFilename, jsonData);
await writeJSON(geojsonFilename, geoJSONData);