forked from xtiko14/dvf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e3ed000
commit ee4455d
Showing
7 changed files
with
103 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CADASTRE_COMMUNES_PATH= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,3 +119,4 @@ typings/ | |
# End of https://www.gitignore.io/api/node,macos | ||
|
||
/data | ||
/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const {promisify} = require('util') | ||
const {join} = require('path') | ||
const gunzip = promisify(require('zlib').gunzip) | ||
const {readFile, pathExists} = require('fs-extra') | ||
const {keyBy} = require('lodash') | ||
const {getCodeDepartement} = require('./util') | ||
|
||
const communesPath = process.env.CADASTRE_COMMUNES_PATH | ||
|
||
async function getParcellesCommune(codeCommune) { | ||
const filePath = join(communesPath, getCodeDepartement(codeCommune), codeCommune, `cadastre-${codeCommune}-parcelles.json.gz`) | ||
|
||
if (!(await pathExists(filePath))) { | ||
return | ||
} | ||
|
||
const gzippedFileContent = await readFile(filePath) | ||
const fileContent = await gunzip(gzippedFileContent) | ||
const featureCollection = JSON.parse(fileContent) | ||
|
||
return keyBy(featureCollection.features, 'properties.id') | ||
} | ||
|
||
module.exports = {getParcellesCommune} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters