Commit 00184939 authored by Adrien Pavie's avatar Adrien Pavie
Browse files

Add license file in datasets exports (fixes #14)

parent 1d1feab6
......@@ -7,8 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## Next version (to be released)
## 0.2.5 - 2021-02-18
### Added
- Command for themes dump (`npm run dump`) can take an argument to only dump a specific theme (example `npm run dump fuel`)
- Exported datasets contain a `license.txt` file with OSM license details
### Changed
- Updated theme for shop/craft/office (add various kind of shop-like amenities, restrict offices list)
......
......@@ -107,6 +107,7 @@ Les paramètres généraux de configuration du service sont à renseigner dans l
* `FLAT_NODES` : activer l'option `--flat-nodes` de l'outil osm2pgsql, utile pour les imports de grosses régions ou de pays (`true` pour activer, `false` pour désactiver)
* `API_BASE_URL` : URL à utiliser dans les fichiers de métadonnées pour accéder à l'API (utile si API derrière un proxy), si absent l'adresse directe de l'API est utilisée (exemple: `https://geodatamine.fr`)
* `BOUNDARY` : métadonnées de la zone chargée en base (exemple: `{ "name": "Ille-et-Vilaine", "ref": "35", "id": "35"}`)
* `LICENSE` : texte de la licence, qui apparaît dans les fichiers exportés (exemple `Données © les contributeurs d’OpenStreetMap`)
### Thèmes
......
......@@ -253,11 +253,14 @@ function createDataFile(theme, boundary, request, options) {
const filename = `${theme.id}${boundary ? boundary.id.toString() : "dump"}${Date.now()}_${options.format}`;
const baseFilePath = `${CONFIG.WORK_DIR}/${filename}`;
// Generate metadata file content
// Generate metadata + license file content
const metadataFile = baseFilePath + "_metadata.csv";
const licenseFile = baseFilePath + "_license.txt";
if(options.metadata) {
const metadataTxt = getMetadataText(theme, boundary, options.format, options.url);
fs.writeFileSync(metadataFile, metadataTxt);
fs.writeFileSync(licenseFile, CONFIG.LICENSE);
}
/*
......@@ -305,10 +308,11 @@ function createDataFile(theme, boundary, request, options) {
// Add metadata along dataset
if(options.metadata) {
const zipFile = baseFilePath + ".zip";
bashCommands.push(`zip -j ${zipFile} ${outFile} ${metadataFile}`);
bashCommands.push(`zip -j ${zipFile} ${outFile} ${metadataFile} ${licenseFile}`);
bashCommands.push(`printf "@ ${outFile.replace(CONFIG.WORK_DIR + "/", "")}\n@=data.${FORMAT_TO_EXT[options.format]}\n" | zipnote -w ${zipFile}`);
bashCommands.push(`printf "@ ${metadataFile.replace(CONFIG.WORK_DIR + "/", "")}\n@=metadata.csv\n" | zipnote -w ${zipFile}`);
bashCommands.push(`rm ${outFile} ${metadataFile}`);
bashCommands.push(`printf "@ ${licenseFile.replace(CONFIG.WORK_DIR + "/", "")}\n@=license.txt\n" | zipnote -w ${zipFile}`);
bashCommands.push(`rm ${outFile} ${metadataFile} ${licenseFile}`);
outFile = zipFile;
}
......
......@@ -12,5 +12,7 @@
"PG_DB_OLD": "geodatamine_prev",
"CACHE_MEM": 10000,
"FLAT_NODES": false
"FLAT_NODES": false,
"LICENSE": "Données © les contributeurs d’OpenStreetMap, sous licence Open Database License\nLa licence complète est disponible à cette adresse : https://www.openstreetmap.org/copyright"
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment