diff --git a/altiProfil/controllers/ajax.classic.php b/altiProfil/controllers/ajax.classic.php index 85f9e73..a3f624f 100755 --- a/altiProfil/controllers/ajax.classic.php +++ b/altiProfil/controllers/ajax.classic.php @@ -69,11 +69,12 @@ public function getProfil(){ $p2Lon = $this->param('p2Lon'); $p2Lat = $this->param('p2Lat'); $sampling = $this->param('sampling'); + $distance = $this->param('distance'); if ( ($this->checkParams($p1Lon, $p1Lat)) and ($this->checkParams($p2Lon, $p2Lat)) ){ if($altiProvider == 'ign' ){ $altiProviderInstance = new \AltiProfil\AltiServicesFromIGN($altiConfig); - $rep->data = $altiProviderInstance->getProfil($p1Lon, $p1Lat, $p2Lon, $p2Lat, $sampling); + $rep->data = $altiProviderInstance->getProfil($p1Lon, $p1Lat, $p2Lon, $p2Lat, $sampling, $distance); return $rep; }elseif ( $altiProvider == 'database' ) { $repository = $this->param('repository'); diff --git a/altiProfil/install/www/altiprofil/js/altiProfil.js b/altiProfil/install/www/altiprofil/js/altiProfil.js index 6447fe3..92f8eaa 100755 --- a/altiProfil/install/www/altiprofil/js/altiProfil.js +++ b/altiProfil/install/www/altiprofil/js/altiProfil.js @@ -86,7 +86,8 @@ function getProfil(p1,p2){ 'srs': lizMap.map.projection.projCode, 'repository': lizUrls.params.repository, 'project': lizUrls.params.project, - 'sampling' : Math.round(p1.distanceTo(p2))/2 /* Only use with french mapping Agency (IGN) web service */ + 'sampling' : Math.round(p1.distanceTo(p2)/25) /* Only use with french mapping Agency (IGN) web service */, + 'distance' : Math.round(p1.distanceTo(p2)) } getProfilJsonResponse(qParams, function(data){ diff --git a/altiProfil/lib/AltiServicesFromIGN.php b/altiProfil/lib/AltiServicesFromIGN.php index 5288a52..0c97441 100755 --- a/altiProfil/lib/AltiServicesFromIGN.php +++ b/altiProfil/lib/AltiServicesFromIGN.php @@ -58,13 +58,15 @@ public function getAlti($lon, $lat) /** * Get profil from IGN API **/ - public function getProfil($p1Lon, $p1Lat, $p2Lon, $p2Lat, $sampling) + public function getProfil($p1Lon, $p1Lat, $p2Lon, $p2Lat, $sampling, $distance) { + // 150 is the max allowed for a fast response by IGN + $sampling = min(150, $sampling); $APIRestProfil = "/alti/rest/elevationLine.json"; $data = array( 'lon' => $p1Lon."|".$p2Lon, 'lat' => $p1Lat."|".$p2Lat, - 'sampling' => 10, + 'sampling' => $sampling, 'resource' => $this->resource_id ); @@ -146,10 +148,11 @@ public function getProfil($p1Lon, $p1Lat, $p2Lon, $p2Lat, $sampling) $customdata = array(); $resolution = ""; $i=0; + $distanceStep = ($distance/$sampling); foreach($ignProfilResponse->elevations as $key => $value) { - $x[] = $i; + $x[] = $i*$distanceStep; $y[] = $value->z; - $customdata[] = [$value->lon, $value->lat]; + $customdata[] = [["lon" => $value->lon, "lat" => $value->lat]]; $i = $i+1; } $data = [ [