Skip to content

Commit

Permalink
Changement base appelations FranceAgrimer
Browse files Browse the repository at this point in the history
  • Loading branch information
vinsag committed Dec 11, 2019
1 parent a3bd9e9 commit a336676
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
28 changes: 12 additions & 16 deletions controllers/aoc/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,31 @@ var _ = require('lodash');
/**
* Récupération des AOC viticoles par géométrie
*/
router.get('/appellation-viticole', [
router.post('/appellation-viticole', [
check('geom').exists().withMessage('Le paramètre geom est obligatoire'),
check('geom').custom(isGeometry)
], validateParams, pgClient, function(req, res, next) {
var params = matchedData(req);

var sql = format(`
SELECT
id,
new_insee,
new_nomcom,
old_insee,
old_nomcom,
type_ig,
id_app,
appellation,
id_denom,
denomination,
crinao,
ST_AsGeoJSON(geom) as geom
appellation,
idapp,
id_uni,
insee,
segment,
instruction_obligatoire,
granularite,
ST_AsGeoJSON(geom) as geom
FROM
inao.appellation
appellations
WHERE ST_Intersects(
geom,
ST_SetSRID(ST_GeomFromGeoJSON('%s'), 4326)
)
)
LIMIT 1000
`, params.geom );

req.pgClient.query(sql,function(err,result){
if (err)
return next(err);
Expand Down
7 changes: 4 additions & 3 deletions doc/aoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ basePath: /api

paths:
/aoc/appellation-viticole:
get:
post:
description: |
Prend une geometrie de type GeoJSON en paramètre d'entrée et renvoie les appellations viticoles intersectantes
Paramètres de sorties : Retourne un résultat de Type "FeatureCollection"
consumes:
- application/x-www-form-urlencoded
Paramètres de sorties : Retourne un résultat de Type "FeatureCollection"
parameters:

- name: geom
Expand Down

0 comments on commit a336676

Please sign in to comment.