Skip to content

Commit

Permalink
prepare functions to load directly json
Browse files Browse the repository at this point in the history
typofix
  • Loading branch information
aloxe committed Jul 14, 2024
1 parent 9f1b85d commit cb2047b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion public/datavelo/velotraces.json.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@
}
closedir($dir);
// asort($tracks);
echo json_encode($tracks);
echo json_encode($tracks); //, JSON_PRETTY_PRINT);
?>
21 changes: 21 additions & 0 deletions src/helpers/gpxUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ export const getGpxList = async () => {
}
}

export const getGeoJsonList = async () => {
try {
const response = await axios.get('https://alix.guillard.fr/data/velo/velotraces.json.php');
return response.data
} catch (error) {
console.error('oups Error fetching data:', error.message);
return([])
}
}

export const filterGpxList = (currentYear, currentCountry, allGpxList) => {
const loadCountry = currentCountry === 'xx' ? '' : currentCountry;
const loadYear = currentYear === 'all' ? '' : currentYear;
Expand Down Expand Up @@ -54,6 +64,17 @@ export const loadGeoJsonFromGpx = async (url) => {
}
}

export const loadGeoJsonFromSlug = async (slug) => {
try {
const response = await axios.get(`https://alix.guillard.fr/data/velo/json/${slug}`);
const geojson = response.data
return geojson;
} catch (error) {
console.error('Error fetching geojson data:', error.message);
return
}
}

export const uploadJson = async (geodata) => {
console.log("upload", geodata);
const body = JSON.stringify(geodata)
Expand Down

0 comments on commit cb2047b

Please sign in to comment.