Skip to content

Commit

Permalink
Correction bug module nature + modif menu
Browse files Browse the repository at this point in the history
  • Loading branch information
vinsag committed Jun 25, 2021
1 parent a1fdf8a commit 80c1b27
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 14 deletions.
32 changes: 20 additions & 12 deletions controllers/nature/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var Router = require('express').Router;
var router = new Router();
var cors = require('cors');
const { check } = require('express-validator/check');
const { check, param } = require('express-validator/check');
const { matchedData } = require('express-validator/filter');

const validateParams = require('../../middlewares/validateParams');
Expand All @@ -26,18 +26,26 @@ function createNaturaProxy(featureTypeName){
function(req,res){
var params = matchedData(req);

const input = JSON.parse(params.geom);
proj4.defs("EPSG:4326","+proj=longlat +datum=WGS84 +no_defs");
// http://epsg.io/3857.js
proj4.defs("EPSG:3857","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs");
const transform = proj4("EPSG:4326","EPSG:3857");
meta.coordEach(input,function(c){
let newC = transform.forward(c);
c[0] = newC[0];
c[1] = newC[1];
});
params.geom=input;
// Tranformation de la géométrie dans le réferentiel 3857
if(params.geom) {
const input = JSON.parse(params.geom);

proj4.defs("EPSG:4326","+proj=longlat +datum=WGS84 +no_defs");

// http://epsg.io/3857.js
proj4.defs("EPSG:3857","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs");

const transform = proj4("EPSG:4326","EPSG:3857");

meta.coordEach(input,function(c){
let newC = transform.forward(c);
c[0] = newC[0];
c[1] = newC[1];
});
params.geom=input;

}

/* Value default pour _limit an _start */
if ( typeof params._start == 'undefined' ) { params._start = 0;}
if( typeof params._limit == 'undefined') {params._limit = 1000;}
Expand Down
14 changes: 13 additions & 1 deletion doc/views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
</td>
</tr>
<tr>
<td>Nature (Version bêta)</td>
<td>Nature</td>
<td>
API d'accès aux flux WFS Géoportail s'appuyant sur des données du MNHN
</td>
Expand Down Expand Up @@ -267,6 +267,18 @@
Implémentation des Promise JavaScript avec un support pour les différents navigateurs (simplifie les chaînages de requête et la gestion des exécutions en parallèle)
</td>
</tr>
<tr>
<td>
<a target="_blank" href="https://github.com/proj4js/proj4js">
proj4
</a>
</td>
<td class="text-center">Tranformation géométrique</td>
<td>
Bibliothèque JavaScript permettant de transformer des coordonnées géomtriques dans un autre référentiel
</td>
</tr>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion doc/views/partial/menu.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<a href="/api/doc/wfs-geoportail">WFS-Geoportail (Version Bêta)</a>
</li>
<li>
<a href="/api/doc/nature">Nature (Version Bêta)</a>
<a href="/api/doc/nature">Nature</a>
</li>
</ul>
</li>
Expand Down

0 comments on commit 80c1b27

Please sign in to comment.