Skip to content

Commit

Permalink
Fix ign sampling and data for ploty template (#37)
Browse files Browse the repository at this point in the history
* use 25 m sampling or max 150

* fix hovertemplate, use distance to calculate x axis step
  • Loading branch information
nworr authored Apr 29, 2024
1 parent f1e3247 commit 9855be9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion altiProfil/controllers/ajax.classic.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
3 changes: 2 additions & 1 deletion altiProfil/install/www/altiprofil/js/altiProfil.js
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
11 changes: 7 additions & 4 deletions altiProfil/lib/AltiServicesFromIGN.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);

Expand Down Expand Up @@ -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 = [ [
Expand Down

0 comments on commit 9855be9

Please sign in to comment.