Skip to content

Commit

Permalink
Add COM as dept, regions. Flatten key collectiviteOutremer in commune…
Browse files Browse the repository at this point in the history
…. Use zone for filtering by COM
  • Loading branch information
ThomasG77 committed Jun 14, 2022
1 parent 19b9451 commit 0ddc0ec
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 10 deletions.
9 changes: 6 additions & 3 deletions build/cog.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ async function extractDepartements(path) {
region: row.REG,
chefLieu: row.CHEFLIEU,
nom: row.LIBELLE,
typeLiaison: parseTypeLiaison(row.TNCC)
typeLiaison: parseTypeLiaison(row.TNCC),
zone: row.ZONE ? row.ZONE : row.DEP.length > 2 ? 'dom' : 'metro'
}
})
}
Expand All @@ -27,7 +28,8 @@ async function extractRegions(path) {
code: row.REG,
chefLieu: row.CHEFLIEU,
nom: row.LIBELLE,
typeLiaison: parseTypeLiaison(row.TNCC)
typeLiaison: parseTypeLiaison(row.TNCC),
zone: row.ZONE ? row.ZONE : ['01', '02', '03', '04', '06'].includes(row.REG) ? 'dom' : 'metro'
}
})
}
Expand Down Expand Up @@ -119,7 +121,8 @@ async function extractCommunes(communesPath, mouvementsCommunesPath, arrondissem
const commune = {
code: row.COM,
nom: row.LIBELLE,
typeLiaison: parseTypeLiaison(row.TNCC)
typeLiaison: parseTypeLiaison(row.TNCC),
zone: row.zone ? row.zone : row.DEP.length > 2 ? 'dom' : 'metro'
}

if (row.TYPECOM === 'COM') {
Expand Down
7 changes: 3 additions & 4 deletions build/collectivites-outremer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ async function extractCommunesCOM(path) {
const commune = {
code: row.code_commune,
nom: row.nom_commune,
collectiviteOutremer: {
code: row.code_collectivite,
nom: row.nom_collectivite
},
departement: row.code_collectivite,
region: row.code_collectivite,
zone: 'com',
type: 'commune-actuelle'
}

Expand Down
8 changes: 6 additions & 2 deletions build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@ async function main() {
communes: {...populationHorsMayotte.communes, ...populationMayotte.communes}
}
const arrondissements = await extractArrondissements(getSourceFilePath('arrondissements.csv'))
const departements = await extractDepartements(getSourceFilePath('departements.csv'))
const regions = await extractRegions(getSourceFilePath('regions.csv'))
const departements_metro_and_dom = await extractDepartements(getSourceFilePath('departements.csv'))
const departements_com = await extractDepartements(getSourceFilePath('departements-outremer.csv'))
const departements = [...departements_metro_and_dom, ...departements_com]
const regions_metro_and_dom = await extractRegions(getSourceFilePath('regions.csv'))
const regions_com = await extractRegions(getSourceFilePath('regions-outremer.csv'))
const regions = [...regions_metro_and_dom, ...regions_com]

await buildRegions(regions)
await buildDepartements(departements)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@etalab/decoupage-administratif",
"version": "2.0.0",
"version": "2.0.0-5",
"description": "API JavaScript permettant d'interroger le découpage administratif français",
"main": ".",
"repository": "https://github.com/etalab/decoupage-administratif",
Expand Down
9 changes: 9 additions & 0 deletions sources/departements-outremer.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
DEP,REG,CHEFLIEU,TNCC,NCC,NCCENR,LIBELLE,ZONE
975,975,97502,0,SAINT-PIERRE-ET-MIQUELON,Saint-Pierre-et-Miquelon,Saint-Pierre-et-Miquelon,com
977,977,97701,0,SAINT-BARTHELEMY,Saint-Barthélemy,Saint-Barthélemy,com
978,978,97801,0,SAINT-MARTIN,Saint-Martin,Saint-Martin,com
984,984,97502,0,TERRES AUSTRALES ET ANTARCTIQUES FRANCAISES,Terres australes et antarctiques françaises,Terres australes et antarctiques françaises,com
986,986,98613,0,WALLIS ET FUTUNA,Wallis et Futuna,Wallis et Futuna,com
987,987,98735,0,POLYNESIE FRANCAISE,Polynésie française,Polynésie française,com
988,988,98818,0,NOUVELLE-CALEDONIE,Nouvelle-Calédonie,Nouvelle-Calédonie,com
989,989,98901,0,ILE DE CLIPPERTON,Île de Clipperton,Île de Clipperton,com
9 changes: 9 additions & 0 deletions sources/regions-outremer.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
REG,CHEFLIEU,TNCC,NCC,NCCENR,LIBELLE,ZONE
975,97502,0,SAINT-PIERRE-ET-MIQUELON,Saint-Pierre-et-Miquelon,Saint-Pierre-et-Miquelon,com
977,97701,0,SAINT-BARTHELEMY,Saint-Barthélemy,Saint-Barthélemy,com
978,97801,0,SAINT-MARTIN,Saint-Martin,Saint-Martin,com
984,97502,0,TERRES AUSTRALES ET ANTARCTIQUES FRANCAISES,Terres australes et antarctiques françaises,Terres australes et antarctiques françaises,com
986,98613,0,WALLIS ET FUTUNA,Wallis et Futuna,Wallis et Futuna,com
987,98735,0,POLYNESIE FRANCAISE,Polynésie française,Polynésie française,com
988,98818,0,NOUVELLE-CALEDONIE,Nouvelle-Calédonie,Nouvelle-Calédonie,com
989,98901,0,ILE DE CLIPPERTON,Île de Clipperton,Île de Clipperton,com

0 comments on commit 0ddc0ec

Please sign in to comment.