2 require_once('require/class.Connection.php');
3 require_once('require/class.Marine.php');
4 $Marine = new Marine();
5 if (isset($_GET['download']))
7 header('Content-disposition: attachment; filename="races.geojson"');
9 header('Content-Type: text/javascript');
11 $race_id = filter_input(INPUT_GET
,'race_id',FILTER_SANITIZE_NUMBER_INT
);
13 $race_array = $Marine->getRace($race_id);
15 $race_array = array();
18 $output = '{"type": "FeatureCollection","features": [';
19 if (!empty($race_array))
21 $course = json_decode($race_array['race_markers'],true);
24 foreach($course as $marker)
26 date_default_timezone_set('UTC');
27 $output .= '{"type": "Feature",';
28 $output .= '"properties": {';
29 $output .= '"ref": "'.$marker['marine_race_id'].'",';
30 $output .= '"raceid": "'.$race_array['race_id'].'",';
31 $output .= '"race": "'.$race_array['race_name'].'",';
32 $output .= '"name": "'.$marker['name'].'",';
33 $output .= '"type": "'.$marker['type'].'",';
34 if ($i == 0 ||
$i == 1) {
35 $output .= '"icon": "images/tsk/tsk-start.png",';
36 } elseif ($i == $f-1 ||
$i == $f-2) {
37 $output .= '"icon": "images/tsk/tsk-finish.png",';
38 } elseif ($marker['type'] == 4) {
39 $output .= '"icon": "images/kardinalstonne.png",';
41 $output .= '"icon": "images/lateraltonne.png",';
43 $output .= '"stroke": "#f0f0f0",';
44 $output .= '"stroke-width": 2';
46 $output .= '"geometry": {';
47 $output .= '"type": "Point",';
48 $output .= '"coordinates": ';
49 $output .= '['.$marker['lon'].', '.$marker['lat'].']';
55 $output .= '{"type": "Feature",';
56 $output .= '"properties": {';
57 $output .= '"stroke": "#f0f0f0",';
58 $output .= '"stroke-width": 2';
60 $output .= '"geometry": {';
61 $output .= '"type": "LineString",';
62 $output .= '"coordinates": [';
63 foreach($course as $marker)
65 date_default_timezone_set('UTC');
66 $output .= '['.$marker['lon'].', '.$marker['lat'].'],';
68 $output = substr($output, 0, -1);
74 $output = substr($output, 0, -1);