<?php
$points = Array ( Array ( 45.29077, 5.63361 ), Array ( 45.29083, 5.63384 ) );
echo 'points = ';
print_r($points);
$json_parcours = array("type"=>"FeatureCollection", "features"=>array());
$coord_bdd = array();
foreach($points as $value){
//echo gettype($value[1]).' : ';
$round1 = substr($value[1],0,7);
$round2 = sprintf('%f.5', $value[0]);
$round1 = floatval($round1);
$round2 = floatval($round2);
array_push($coord_bdd,array($round1,$round2));
//echo $round1.', '.$round2.'<br />';
echo '<br/><br/>coord_bdd = ';
print_r($coord_bdd);
}
array_push($json_parcours["features"],array("type"=>"Feature","geometry"=>array("type"=>"LineString","coordinates"=>$coord_bdd),"properties"=>array()));
$jsonData = json_encode($json_parcours,JSON_UNESCAPED_UNICODE); // Convertir le tableau en JSON
echo '<br/><br/>jsonData = ';
print_r($jsonData);
- Output for 5.4.0, 8.1.30 - 8.1.33, 8.2.24 - 8.2.29, 8.3.5 - 8.3.26, 8.4.1 - 8.4.13
- points = Array
(
[0] => Array
(
[0] => 45.29077
[1] => 5.63361
)
[1] => Array
(
[0] => 45.29083
[1] => 5.63384
)
)
<br/><br/>coord_bdd = Array
(
[0] => Array
(
[0] => 5.63361
[1] => 45.29077
)
)
<br/><br/>coord_bdd = Array
(
[0] => Array
(
[0] => 5.63361
[1] => 45.29077
)
[1] => Array
(
[0] => 5.63384
[1] => 45.29083
)
)
<br/><br/>jsonData = {"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"LineString","coordinates":[[5.63361,45.29077],[5.63384,45.29083]]},"properties":[]}]}
preferences:
47.94 ms | 408 KiB | 5 Q