Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions bin/failed-sources.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import fs from "fs";
import { all } from "../src/core/sources.js";
import fs from 'fs';
import { all } from '../src/core/sources.js';

const main = () => {
all.forEach((source) => {
if (!fs.existsSync(source.destinations.raw.path)) {
console.log(
source.country,
source.idName,
"is broken?",
!!source.broken
source.idSourceName,
'is broken?',
!!source.broken,
);
}
});
Expand Down
32 changes: 16 additions & 16 deletions bin/write-sources.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import fs from "fs";
import path from "path";
import * as utils from "../src/core/utils.js";
import logger from "../logger.js";
import identitySource from "../identity-source.js";
import makeDir from "make-dir";
import fs from 'fs';
import path from 'path';
import * as utils from '../src/core/utils.js';
import logger from '../logger.js';
import identitySource from '../identity-source.js';
import makeDir from 'make-dir';

const __dirname = path.dirname(import.meta.url.split(":")[1]);
const __root = path.join(__dirname, "..");
const __dirname = path.dirname(import.meta.url.split(':')[1]);
const __root = path.join(__dirname, '..');

const exportPath = path.join(__root, "tmp");
const exportPath = path.join(__root, 'tmp');

function dealWithCrossWalk(crosswalk) {
let tmpCrosswalk = crosswalk;
if (!crosswalk) return crosswalk;
Object.entries(crosswalk).forEach(
([key, val]) => (tmpCrosswalk = { ...tmpCrosswalk, [key]: val.toString() })
([key, val]) => (tmpCrosswalk = { ...tmpCrosswalk, [key]: val.toString() }),
);
return tmpCrosswalk;
}
Expand All @@ -30,7 +30,7 @@ const handleSource = async (sourceName) => {

const resultPath = path.join(exportPath, sourceName);

await utils.asyncWriteFile(resultPath, "export default [\n");
await utils.asyncWriteFile(resultPath, 'export default [\n');

country.forEach((source) => {
const obj = {
Expand All @@ -42,8 +42,8 @@ const handleSource = async (sourceName) => {
city: source.short || null,
long: source.long || source.short || null,
short: source.short || null,
main: source.main || source.idName || null,
idName: idName,
main: source.main || source.idSourceName || null,
idSourceName: idSourceName,
info: source.info || null,
brokenDownload: source.brokenDownload || false,
download: source.download || null,
Expand All @@ -56,15 +56,15 @@ const handleSource = async (sourceName) => {
obj.crosswalk = dealWithCrossWalk(source.crosswalk);

fs.appendFileSync(resultPath, ` ${JSON.stringify(obj)},\n`, (err) =>
logger.error(err)
logger.error(err),
);
});

fs.appendFileSync(resultPath, `];`, (err) => logger.error(err));
};

const handleSources = async () => {
const sources = await utils.asyncReadDir(path.join(__root, "sources"));
const sources = await utils.asyncReadDir(path.join(__root, 'sources'));
await Promise.all(sources.map(handleSource));
};

Expand All @@ -76,5 +76,5 @@ async function start() {
}
}

process.on("exit", (code) => logger.info(`Exiting with code ${code}\n`));
process.on('exit', (code) => logger.info(`Exiting with code ${code}\n`));
start();
2 changes: 1 addition & 1 deletion identity-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
city: null,
short: null,
long: null,
idName: null,
idSourceName: null,
main: null,
center: null,
latitude: null,
Expand Down
62 changes: 31 additions & 31 deletions sources/argentina.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,70 +4,70 @@ const country = [
isoAlpha3: 'ARG',
numericCountryCode: '032',
country: 'Argentina',
}
]
},
];

export default [
{
isoAlpha2: 'AR',
isoAlpha3: 'ARG',
numericCountryCode: '032',
country: "Argentina",
city: "Buenos Aires",
short: "Buenos Aires",
long: "Buenos Aires",
idName: "buenos_aires",
main: "buenos_aires",
country: 'Argentina',
city: 'Buenos Aires',
short: 'Buenos Aires',
long: 'Buenos Aires',
idSourceName: 'buenos_aires',
main: 'buenos_aires',
center: null,
latitude: null,
longitude: null,
info: "https://data.buenosaires.gob.ar/dataset/arbolado-espacios-verdes",
info: 'https://data.buenosaires.gob.ar/dataset/arbolado-espacios-verdes',
broken: false,
download:
"http://cdn.buenosaires.gob.ar/datosabiertos/datasets/arbolado-en-espacios-verdes/arbolado-en-espacios-verdes.csv",
format: "csv",
'http://cdn.buenosaires.gob.ar/datosabiertos/datasets/arbolado-en-espacios-verdes/arbolado-en-espacios-verdes.csv',
format: 'csv',
filename: null,
gdalOptions: null,
license: null,
email: null,
contact: null,
crosswalk: {
idReference: "id_arbol",
height: "altura_tot",
dbh: "diametre",
common: "nombre_com",
scientific: "nombre_cie",
family: "nombre_fam",
idReference: 'id_arbol',
height: 'altura_tot',
dbh: 'diametre',
common: 'nombre_com',
scientific: 'nombre_cie',
family: 'nombre_fam',
},
},
{
isoAlpha2: 'AR',
isoAlpha3: 'ARG',
numericCountryCode: '032',
country: "Argentina",
city: "Buenos Aires2",
short: "Buenos Aires2",
long: "Buenos Aires2",
idName: "buenos_aires2",
main: "buenos_aires",
country: 'Argentina',
city: 'Buenos Aires2',
short: 'Buenos Aires2',
long: 'Buenos Aires2',
idSourceName: 'buenos_aires2',
main: 'buenos_aires',
center: null,
latitude: null,
longitude: null,
info: "https://data.buenosaires.gob.ar/dataset/arbolado-publico-lineal",
info: 'https://data.buenosaires.gob.ar/dataset/arbolado-publico-lineal',
broken: false,
download:
"http://cdn.buenosaires.gob.ar/datosabiertos/datasets/arbolado-publico-lineal/arbolado-publico-lineal-2017-2018.geojson",
format: "geojson",
filename: "buenos_aires2.geojson",
'http://cdn.buenosaires.gob.ar/datosabiertos/datasets/arbolado-publico-lineal/arbolado-publico-lineal-2017-2018.geojson',
format: 'geojson',
filename: 'buenos_aires2.geojson',
gdalOptions: null,
license: null,
email: null,
contact: null,
crosswalk: {
idReference: "nro_registro",
scientific: "nombre_cientifico",
dbh: "diametro_altura_pecho",
height: "altura_arbol",
idReference: 'nro_registro',
scientific: 'nombre_cientifico',
dbh: 'diametro_altura_pecho',
height: 'altura_arbol',
},
},
];
Loading