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

Update to support anciens INSEE codes #181

Merged
merged 1 commit into from
Nov 21, 2023
Merged
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
1 change: 1 addition & 0 deletions build/communes.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ async function buildCommunes() {
codeRegion: commune.region,
codesPostaux: [...(commune.codesPostaux || [])].sort(),
population: commune.population,
anciensCodes: commune.anciensCodes || [],
zone: commune.zone
}

Expand Down
10 changes: 10 additions & 0 deletions definition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ parameters:
- codeRegion
- region
- population
- anciensCodes
- deleguees
- associees
- zone
Expand Down Expand Up @@ -254,6 +255,10 @@ paths:
in: query
description: Code de la commune si on a un arrondissement
type: string
- name: ancienCode
in: query
description: Code INSEE ancien de la commune
type: string
- $ref: '#/parameters/zoneParam'
- $ref: '#/parameters/typeCommune'
- $ref: '#/parameters/communeFieldsParam'
Expand Down Expand Up @@ -719,6 +724,11 @@ definitions:
population:
type: integer
description: Population municipale
anciensCodes:
type: array
description: Liste des anciens codes INSEE associés à la commune
items:
type: string
surface:
type: number
format: float
Expand Down
3 changes: 2 additions & 1 deletion lib/communes.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ const schema = {
codeDepartement: {type: 'token', queryWith: 'codeDepartement'},
codeRegion: {type: 'token', queryWith: 'codeRegion'},
zone: {type: 'token', queryWith: 'zone', multiple: 'OR'},
contour: {type: 'geo', queryWith: 'pointInContour'}
contour: {type: 'geo', queryWith: 'pointInContour'},
anciensCodes: {type: 'tokenList', queryWith: 'ancienCode'}
}

function getIndexedDb(options = {}) {
Expand Down
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ if (process.env.COMMUNES_ASSOCIEES_DELEGUEES) {

/* Communes */
app.get('/communes', initLimit(), initCommuneFields, initCommuneFormat, (req, res) => {
const query = pick(req.query, 'type', 'code', 'codePostal', 'nom', 'siren', 'deleguees', 'associees', 'codeEpci', 'codeDepartement', 'codeRegion', 'boost', 'zone', 'codeParent')
const query = pick(req.query, 'type', 'code', 'codePostal', 'nom', 'siren', 'deleguees', 'associees', 'codeEpci', 'codeDepartement', 'codeRegion', 'boost', 'zone', 'codeParent', 'ancienCode')
if (req.query.lat && req.query.lon) {
const lat = parseFloat(req.query.lat)
const lon = parseFloat(req.query.lon)
Expand Down