Skip to content

Commit

Permalink
Merge pull request #165 from etalab/feature/siren-communes
Browse files Browse the repository at this point in the history
Update code to support SIREN for communes
  • Loading branch information
ThomasG77 authored Aug 31, 2022
2 parents edfd593 + af8fb0a commit 48a2f3a
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 10 deletions.
1 change: 1 addition & 0 deletions build/communes.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ async function buildCommunes() {
code: commune.code,
type: commune.type,
nom: commune.nom,
siren: commune.siren,
codeDepartement: commune.departement,
codeRegion: commune.region,
codesPostaux: commune.codesPostaux || [],
Expand Down
9 changes: 9 additions & 0 deletions definition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ parameters:
- nom
- code
- codesPostaux
- siren
- centre
- surface
- contour
Expand All @@ -37,6 +38,7 @@ parameters:
- nom
- code
- codesPostaux
- siren
- codeEpci
- codeDepartement
- codeRegion
Expand Down Expand Up @@ -171,6 +173,10 @@ paths:
in: query
description: Code de la commune
type: string
- name: siren
in: query
description: Code SIREN de la commune
type: string
- name: codeEpci
in: query
description: Code de l'EPCI associé
Expand Down Expand Up @@ -525,6 +531,9 @@ definitions:
description: Liste des codes postaux associés à la commune
items:
type: string
siren:
type: string
description: Code SIREN de la commune
codeEpci:
type: string
description: Code de l'EPCI associé à la commune
Expand Down
2 changes: 1 addition & 1 deletion lib/communeHelpers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const {initFields, initFormat} = require('./helpers')

const initCommuneFields = initFields({
default: ['nom', 'code', 'codeDepartement', 'codeEpci', 'codeRegion', 'codesPostaux', 'population'],
default: ['nom', 'code', 'codeDepartement', 'siren', 'codeEpci', 'codeRegion', 'codesPostaux', 'population'],
base: ['nom', 'code']
})

Expand Down
1 change: 1 addition & 0 deletions lib/communes.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const schema = {
type: {type: 'token', queryWith: 'type', multiple: 'OR'},
code: {type: 'token', queryWith: 'code'},
codesPostaux: {type: 'tokenList', queryWith: 'codePostal'},
siren: {type: 'token', queryWith: 'siren'},
codeEpci: {type: 'token', queryWith: 'codeEpci'},
codeDepartement: {type: 'token', queryWith: 'codeDepartement'},
codeRegion: {type: 'token', queryWith: 'codeRegion'},
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@etalab/api-geo",
"version": "2.1.0",
"version": "2.2.0",
"description": "Interroger les référentiels géographiques plus facilement",
"repository": {
"type": "git",
Expand All @@ -20,7 +20,7 @@
"rbush": "^2.0.1"
},
"devDependencies": {
"@etalab/decoupage-administratif": "^2.1.0",
"@etalab/decoupage-administratif": "^2.2.1",
"@turf/area": "^6.0.1",
"@turf/bbox": "^6.5.0",
"@turf/bbox-polygon": "^6.5.0",
Expand Down Expand Up @@ -61,7 +61,8 @@
},
"contributors": [
"Jérôme Desboeufs <[email protected]>",
"Théophile Merlière <[email protected]>"
"Théophile Merlière <[email protected]>",
"Thomas Gratier <[email protected]>"
],
"license": "MIT"
}
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ app.use((req, res, next) => {

/* Communes */
app.get('/communes', initLimit(), initCommuneFields, initCommuneFormat, (req, res) => {
const query = pick(req.query, 'type', 'code', 'codePostal', 'nom', 'codeEpci', 'codeDepartement', 'codeRegion', 'boost', 'zone')
const query = pick(req.query, 'type', 'code', 'codePostal', 'nom', 'siren', 'codeEpci', 'codeDepartement', 'codeRegion', 'boost', 'zone')
if (req.query.lat && req.query.lon) {
const lat = parseFloat(req.query.lat)
const lon = parseFloat(req.query.lon)
Expand Down
2 changes: 1 addition & 1 deletion test/communeHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('communeHelpers', () => {
it('empty request should return default fields', done => {
runTestCase(
{},
['nom', 'code', 'codesPostaux', 'codeEpci', 'codeDepartement', 'codeRegion', 'population'],
['nom', 'code', 'codesPostaux', 'codeEpci', 'codeDepartement', 'codeRegion', 'population', 'siren'],
done
)
})
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@
lodash "^4.17.11"
to-fast-properties "^2.0.0"

"@etalab/decoupage-administratif@^2.1.0":
version "2.1.0"
resolved "https://registry.npmjs.org/@etalab/decoupage-administratif/-/decoupage-administratif-2.1.0.tgz"
integrity sha512-ICOWiysBRNMd6HNY5yGFeia+AHqHLiXMrXDm4YPeEMPQP2i/vs38soCCFu8C789UT3o0efu79UK2hNTcHWBoXg==
"@etalab/decoupage-administratif@^2.2.1":
version "2.2.1"
resolved "https://registry.yarnpkg.com/@etalab/decoupage-administratif/-/decoupage-administratif-2.2.1.tgz#a33bb862b1ce28463a87b9ca235a44e5cfd2ca4d"
integrity sha512-W+m9W4GuIyi6nudnx2BNrLfkBv7DLNYq6KSTjnk49yPXMNLBRfvp8bLQuNDk6/jqvrPhMOOc0uRQhDu18UXQ8w==

"@mrmlnc/readdir-enhanced@^2.2.1":
version "2.2.1"
Expand Down

0 comments on commit 48a2f3a

Please sign in to comment.