Skip to content

Commit

Permalink
Merge pull request #25 from IGNF/v2.1.5
Browse files Browse the repository at this point in the history
V2.1.5
  • Loading branch information
vinsag authored Feb 6, 2020
2 parents da28216 + 94ea459 commit 8b29cfc
Show file tree
Hide file tree
Showing 7 changed files with 396 additions and 223 deletions.
124 changes: 49 additions & 75 deletions controllers/gpu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var router = new Router();

const { check } = require('express-validator/check');
const { matchedData } = require('express-validator/filter');
const isGeometry = require('../../checker/isGeometry');
const {isGeometry,isCodeInsee} = require('../../checker');
const validateParams = require('../../middlewares/validateParams');

var gpuWfsClient = require('../../middlewares/gpuWfsClient');
Expand Down Expand Up @@ -87,108 +87,82 @@ var corsOptionsGlobal = function(origin,callback) {
}
callback(null, corsOptions);
}
/* Définition des tests paramètres */
var legacyValidators = [
check('geom').optional().custom(isGeometry)
];

router.get('/municipality',cors(corsOptionsGlobal), [
check('geom').optional().custom(isGeometry),
check('insee').optional().isAlphanumeric()
], createGpuProxy(mapping['municipality']));

var communeValidators = legacyValidators.concat([
check('insee').optional().custom(isCodeInsee)
]);

router.get('/document',cors(corsOptionsGlobal), [
check('geom').optional().custom(isGeometry),
var partitionValidators = legacyValidators.concat([
check('partition').optional().isString()
], createGpuProxy(mapping['document']));
]);

var categoriesValidators = partitionValidators.concat([
check('categorie').optional().isString()
])

router.get('/zone-urba', cors(corsOptionsGlobal),[
check('geom').optional().custom(isGeometry),
check('partition').optional().isString()
], createGpuProxy(mapping['zone-urba']));
router.get('/municipality', cors(corsOptionsGlobal),communeValidators, createGpuProxy(mapping['municipality']));
router.post('/municipality',cors(corsOptionsGlobal), communeValidators, createGpuProxy(mapping['municipality']));

router.get('/secteur-cc', cors(corsOptionsGlobal),[
check('geom').optional().custom(isGeometry),
check('partition').optional().isString()
], createGpuProxy(mapping['secteur-cc']));

router.get('/document',cors(corsOptionsGlobal),partitionValidators,createGpuProxy(mapping['document']));
router.post('/document',cors(corsOptionsGlobal),partitionValidators,createGpuProxy(mapping['document']));

router.get('/prescription-pct', cors(corsOptionsGlobal),[
check('geom').optional().custom(isGeometry),
check('partition').optional().isString()
], createGpuProxy(mapping['prescription-pct']));
router.get('/zone-urba', cors(corsOptionsGlobal),partitionValidators, createGpuProxy(mapping['zone-urba']));
router.post('/zone-urba', cors(corsOptionsGlobal),partitionValidators, createGpuProxy(mapping['zone-urba']));

router.get('/prescription-lin', cors(corsOptionsGlobal),[
check('geom').optional().custom(isGeometry),
check('partition').optional().isString()
], createGpuProxy(mapping['prescription-lin']));
router.get('/secteur-cc', cors(corsOptionsGlobal),partitionValidators, createGpuProxy(mapping['secteur-cc']));
router.post('/secteur-cc', cors(corsOptionsGlobal),partitionValidators, createGpuProxy(mapping['secteur-cc']));

router.get('/prescription-surf', cors(corsOptionsGlobal), [
check('geom').optional().custom(isGeometry),
check('partition').optional().isString()
], createGpuProxy(mapping['prescription-surf']));
router.get('/prescription-pct', cors(corsOptionsGlobal),partitionValidators, createGpuProxy(mapping['prescription-pct']));
router.post('/prescription-pct', cors(corsOptionsGlobal),partitionValidators, createGpuProxy(mapping['prescription-pct']));

router.get('/info-pct', cors(corsOptionsGlobal),[
check('geom').optional().custom(isGeometry),
check('partition').optional().isString()
], createGpuProxy(mapping['info-pct']));
router.get('/prescription-lin', cors(corsOptionsGlobal),partitionValidators,createGpuProxy(mapping['prescription-lin']));
router.post('/prescription-lin', cors(corsOptionsGlobal),partitionValidators,createGpuProxy(mapping['prescription-lin']));

router.get('/info-lin', cors(corsOptionsGlobal),[
check('geom').optional().custom(isGeometry),
check('partition').optional().isString()
], createGpuProxy(mapping['info-lin']));
router.get('/prescription-surf', cors(corsOptionsGlobal),partitionValidators ,createGpuProxy(mapping['prescription-surf']));
router.post('/prescription-surf', cors(corsOptionsGlobal),partitionValidators ,createGpuProxy(mapping['prescription-surf']));

router.get('/info-surf', cors(corsOptionsGlobal),[
check('geom').optional().custom(isGeometry),
check('partition').optional().isString()
], createGpuProxy(mapping['info-surf']));
router.get('/info-pct', cors(corsOptionsGlobal), partitionValidators,createGpuProxy(mapping['info-pct']));
router.post('/info-pct', cors(corsOptionsGlobal), partitionValidators,createGpuProxy(mapping['info-pct']));

router.get('/info-lin', cors(corsOptionsGlobal),partitionValidators, createGpuProxy(mapping['info-lin']));
router.post('/info-lin', cors(corsOptionsGlobal),partitionValidators, createGpuProxy(mapping['info-lin']));

router.get('/info-surf', cors(corsOptionsGlobal), partitionValidators, createGpuProxy(mapping['info-surf']));
router.post('/info-surf', cors(corsOptionsGlobal), partitionValidators, createGpuProxy(mapping['info-surf']));

/*--------------------------------------------------------------------------------------------
* SUP
-------------------------------------------------------------------------------------------*/

router.get('/acte-sup', cors(corsOptionsGlobal), [
check('geom').optional().custom(isGeometry),
check('partition').optional().isString(),
], createGpuProxy(mapping['acte-sup']));
router.get('/acte-sup', cors(corsOptionsGlobal),partitionValidators,createGpuProxy(mapping['acte-sup']));
router.post('/acte-sup', cors(corsOptionsGlobal),partitionValidators,createGpuProxy(mapping['acte-sup']));

router.get('/assiette-sup-p', cors(corsOptionsGlobal),[
check('geom').optional().custom(isGeometry),
check('partition').optional().isString(),
check('categorie').optional().isString()
], createGpuProxy(mapping['assiette-sup-p']));
router.get('/assiette-sup-p', cors(corsOptionsGlobal),categoriesValidators , createGpuProxy(mapping['assiette-sup-p']));
router.post('/assiette-sup-p', cors(corsOptionsGlobal),categoriesValidators , createGpuProxy(mapping['assiette-sup-p']));

router.get('/assiette-sup-l', cors(corsOptionsGlobal),[
check('geom').optional().custom(isGeometry),
check('partition').optional().isString(),
check('categorie').optional().isString()
], createGpuProxy(mapping['assiette-sup-l']));
router.get('/assiette-sup-l', cors(corsOptionsGlobal),categoriesValidators , createGpuProxy(mapping['assiette-sup-l']));
router.post('/assiette-sup-l', cors(corsOptionsGlobal),categoriesValidators , createGpuProxy(mapping['assiette-sup-l']));

router.get('/assiette-sup-s', cors(corsOptionsGlobal),[
check('geom').optional().custom(isGeometry),
check('partition').optional().isString(),
check('categorie').optional().isString()
], createGpuProxy(mapping['assiette-sup-s']));
router.get('/assiette-sup-s', cors(corsOptionsGlobal),categoriesValidators, createGpuProxy(mapping['assiette-sup-s']));
router.post('/assiette-sup-s', cors(corsOptionsGlobal),categoriesValidators, createGpuProxy(mapping['assiette-sup-s']));

/*--------------------------------------------------------------------------------------------
* Generateur sup
-------------------------------------------------------------------------------------------*/

router.get('/generateur-sup-p', cors(corsOptionsGlobal),[
check('geom').optional().custom(isGeometry),
check('partition').optional().isString(),
check('categorie').optional().isString()
], createGpuProxy(mapping['generateur-sup-p']));
router.get('/generateur-sup-p', cors(corsOptionsGlobal),categoriesValidators,createGpuProxy(mapping['generateur-sup-p']));
router.post('/generateur-sup-p', cors(corsOptionsGlobal),categoriesValidators,createGpuProxy(mapping['generateur-sup-p']));

router.get('/generateur-sup-l', cors(corsOptionsGlobal),[
check('geom').optional().custom(isGeometry),
check('partition').optional().isString(),
check('categorie').optional().isString()
], createGpuProxy(mapping['generateur-sup-l']));
router.get('/generateur-sup-l', cors(corsOptionsGlobal),categoriesValidators, createGpuProxy(mapping['generateur-sup-l']));
router.post('/generateur-sup-l', cors(corsOptionsGlobal),categoriesValidators, createGpuProxy(mapping['generateur-sup-l']));

router.get('/generateur-sup-s', cors(corsOptionsGlobal),[
check('geom').optional().custom(isGeometry),
check('partition').optional().isString(),
check('categorie').optional().isString()
], createGpuProxy(mapping['generateur-sup-s']));
router.get('/generateur-sup-s', cors(corsOptionsGlobal),categoriesValidators, createGpuProxy(mapping['generateur-sup-s']));
router.post('/generateur-sup-s', cors(corsOptionsGlobal),categoriesValidators, createGpuProxy(mapping['generateur-sup-s']));

/*--------------------------------------------------------------------------------------------
* Recherche dans toutes les tables par geom...
Expand Down
2 changes: 1 addition & 1 deletion doc/cadastre.yml
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ paths:
description: Code insee de la commune sur 5 caractères
type: string
pattern: '\d{5}'
required: true
required: false

- name: section
in: query
Expand Down
9 changes: 8 additions & 1 deletion doc/gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@ info:
title: Module urbanisme (GpU)
description: >
Le service d’interrogation du GPU permet d’obtenir des informations d’urbanisme intersectant une géométrie (ponctuelle ou surfacique).
Attention : les géométries passées en paramètre doivent comporter un nombre de points raisonnable.
Toutes les réponses sont au format GeoJSON et de type FeatureCollection.
Toutes les requêtes(sauf /all) du module GPU peuvent se faire en POST ou en GET.
Exemple de géométrie :
* Centre de Rennes : `{"type": "Point","coordinates":[-1.691634,48.104237]}`
* Parcelle : `{"type":"MultiPolygon","coordinates":[[[[-1.6993786,48.1113366],[-1.6994647,48.1113416],[-1.6994613,48.1113573],[-1.6993639,48.111803],[-1.6992707,48.112222],[-1.6990176,48.1120599],[-1.6989945,48.1120573],[-1.6991084,48.111617],[-1.6991262,48.1115482],[-1.6993407,48.1115608],[-1.6993494,48.1115158],[-1.699361,48.111431],[-1.6993786,48.1113366]]]]}`
* Parcelle : `{"type":"MultiPolygon","coordinates":[[[[-0.4781433,44.745308],[-0.4782708,44.74523],[-0.4783436,44.7451852],[-0.4783998,44.7451462],[-0.4784414,44.7451099],[-0.4784924,44.7450598],[-0.4785333,44.7450223],[-0.4785783,44.7449774],[-0.4786326,44.7449217],[-0.4786341,44.7449202],[-0.4795499,44.7457302],[-0.4789179,44.7461035],[-0.4781433,44.745308]]]]}`
version: 1.0.0

Expand Down
2 changes: 1 addition & 1 deletion middlewares/gppWfsClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = function(req, res, next) {
/* gestion des variables d'environnement et valeur par défaut */
var options = {
apiKey: process.env.GEOPORTAL_API_KEY,
url: 'http://wxs.ign.fr/{apiKey}/geoportail/wfs',
url: 'https://wxs.ign.fr/{apiKey}/geoportail/wfs',
headers:{
'User-Agent': 'apicarto',
'Referer': 'http://localhost'
Expand Down
2 changes: 1 addition & 1 deletion middlewares/gpuWfsClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = function(req, res, next) {

req.gpuWfsClient = new GeoportalWfsClient({
'apiKey': '39wtxmgtn23okfbbs1al2lz3',
'url' : 'http://wxs-gpu.mongeoportail.ign.fr/externe/39wtxmgtn23okfbbs1al2lz3/wfs/v',
'url' : 'https://wxs-gpu.mongeoportail.ign.fr/externe/{apiKey}/wfs/v',
'headers':{
Referer: referer,
'User-Agent': 'apicarto'
Expand Down
Loading

0 comments on commit 8b29cfc

Please sign in to comment.