Skip to content

Commit

Permalink
add possibility to retrieve per year
Browse files Browse the repository at this point in the history
  • Loading branch information
aloxe committed Nov 15, 2024
1 parent 71986c2 commit 00ed8b1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion public/datavelo/tracklist.json.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
}
}
closedir($dir);
$trackliste = [];
sort($tracks);
$trackliste = [];
$i = 0;
foreach ($tracks as $key => $val) {
$date = substr($val, 0, 10);
Expand Down
31 changes: 18 additions & 13 deletions public/datavelo/velotraces.json.php
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
<?php
$year = $_REQUEST['y'];
$velotracks = "json";

// An array of the json file names
$tracks = array();

//Open images directory
//Open track directory
$dir = opendir($velotracks);

//List files in tracks directory
while (($file = readdir($dir)) !== false) {
$geojson = json_decode(file_get_contents(__DIR__."/".$velotracks."/".$file));
// correct year or no year
if (substr($file, 0, 4)==$year || !$year) {
$geojson = json_decode(file_get_contents(__DIR__."/".$velotracks."/".$file));

if (isset($geojson->slug)) {
$date = $geojson->date;
$title = $geojson->title;
$slug = $geojson->slug;
$countries = $geojson->countries;
array_push($tracks,[
'date' => $geojson->date,
'title' => $geojson->title,
'slug' => $geojson->slug,
'countries' => $geojson->countries,
]);
if (isset($geojson->slug)) {
$date = $geojson->date;
$title = $geojson->title;
$slug = $geojson->slug;
$countries = $geojson->countries;
array_push($tracks,[
'date' => $geojson->date,
'title' => $geojson->title,
'slug' => $geojson->slug,
'countries' => $geojson->countries,
]);
}
}
}

closedir($dir);
sort($tracks);
echo json_encode($tracks);
Expand Down

0 comments on commit 00ed8b1

Please sign in to comment.