Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manage COM as dept and region, flatten key collectiviteOutremer #35

Merged
merged 5 commits into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
36 changes: 33 additions & 3 deletions build/cog.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,22 @@ async function extractDepartements(path) {
const rows = await readCsvFile(path)

return rows.map(row => {
let zone
if (row.ZONE) {
ThomasG77 marked this conversation as resolved.
Show resolved Hide resolved
zone = row.ZONE
} else if (row.DEP.length > 2) {
zone = 'dom'
ThomasG77 marked this conversation as resolved.
Show resolved Hide resolved
} else {
zone = 'metro'
}

return {
code: row.DEP,
region: row.REG,
chefLieu: row.CHEFLIEU,
nom: row.LIBELLE,
typeLiaison: parseTypeLiaison(row.TNCC)
typeLiaison: parseTypeLiaison(row.TNCC),
zone
}
})
}
Expand All @@ -23,11 +33,21 @@ async function extractRegions(path) {
const rows = await readCsvFile(path)

return rows.map(row => {
let zone
if (row.ZONE) {
zone = row.ZONE
} else if (['01', '02', '03', '04', '06'].includes(row.REG)) {
zone = 'dom'
} else {
zone = 'metro'
}

return {
code: row.REG,
chefLieu: row.CHEFLIEU,
nom: row.LIBELLE,
typeLiaison: parseTypeLiaison(row.TNCC)
typeLiaison: parseTypeLiaison(row.TNCC),
zone
}
})
}
Expand Down Expand Up @@ -116,10 +136,20 @@ async function extractCommunes(communesPath, mouvementsCommunesPath, arrondissem
const anciensCodesIndex = computeAnciensCodesCommunes(communesRows, mouvementsRows)

const communes = communesRows.map(row => {
let zone
if (row.zone) {
zone = row.zone
} else if (row.DEP.length > 2) {
zone = 'dom'
} else {
zone = 'metro'
}

const commune = {
code: row.COM,
nom: row.LIBELLE,
typeLiaison: parseTypeLiaison(row.TNCC)
typeLiaison: parseTypeLiaison(row.TNCC),
zone
}

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 departementsMetroAndDom = await extractDepartements(getSourceFilePath('departements.csv'))
const departementsCom = await extractDepartements(getSourceFilePath('departements-outremer.csv'))
const departements = [...departementsMetroAndDom, ...departementsCom]
const regionsMetroAndDom = await extractRegions(getSourceFilePath('regions.csv'))
const regionsCom = await extractRegions(getSourceFilePath('regions-outremer.csv'))
const regions = [...regionsMetroAndDom, ...regionsCom]

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",
ThomasG77 marked this conversation as resolved.
Show resolved Hide resolved
"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