eyes.daylightingsociety.org/rawdata...
';
$chtest = curl_init();
curl_setopt($chtest, CURLOPT_URL, "https://eyes.daylightingsociety.org/rawdata/newest");
curl_setopt($chtest, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($chtest, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($chtest, CURLOPT_HEADER, true);
curl_setopt($chtest, CURLOPT_NOBODY, true);
$curltestoutput = curl_exec($chtest);
curl_close($chtest);
//print getLocation($curltestoutput).'
---
'; $gpxfilename= substr(getLocation($curltestoutput),44,10).'.gpx'; //print 'file: '.$gpxfilename; //determine if file already converted $lastfilename = file_get_contents('lastfilename.txt'); if($gpxfilename==$lastfilename) { print 'Data already in cache.
'; writeDownloadLink($gpxfilename); } else { print 'New data found! You are the first to get it.
';
$myfile = fopen("lastfilename.txt", "w") or die("Unable to open file!");
fwrite($myfile, $gpxfilename);
fclose($myfile);
$beforeGettingData=time();
$curloutput=getNewData();
$afterGettingData=time();
print $afterGettingData-$beforeGettingData.' seconds needed for getting data
';
convert($curloutput,$gpxfilename);
$afterConvertingData=time();
print $afterConvertingData-$afterGettingData.' seconds needed for converting data
';
}
//convert($curloutput,$gpxfilename);
//convert('36.603241, -121.889572, 1 36.602211, -121.891251, 1');
function convert($str, $gpxfilename)
{
$output='<'.'?xml version="1.0" encoding="utf-8"?'.'>'.PHP_EOL;
$output=$output.'
';
$a='';
while($position<$ende)
{
$a='';
while(substr($str,$position,1)!=','&&$position<$ende)//1. Komma
{
$a=$a.substr($str,$position,1);
$position=$position+1;
}
$position=$position+1;
//print 'a'.$a.'
';
$output=$output.'
'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://eyes.daylightingsociety.org/rawdata/newest"); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $curloutput = curl_exec($ch); curl_close($ch); return $curloutput; } function writeDownloadLink($gpxfilename) { print''.$gpxfilename.' ['.round(filesize($gpxfilename)/1024).' KB]
'; print'The data is provided under CC0 1.0 Universal, releasing them to the public domain to the furthest extent permitted by law. The data was submitted by the public to eyes.daylightingsociety.org, so it belongs to the public.
'; } print 'source code can be found here'; ?>