-
Notifications
You must be signed in to change notification settings - Fork 161
/
Copy pathlocation-geojson.php
94 lines (91 loc) · 4.59 KB
/
location-geojson.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
require_once('require/class.Connection.php');
require_once('require/class.Source.php');
$Source = new Source();
if (isset($_GET['download']))
{
header('Content-disposition: attachment; filename="locations.geojson"');
}
header('Content-Type: text/javascript');
$spotter_array = array();
if (!isset($globalDemo)) {
if (isset($_GET['coord']))
{
$coords = explode(',',$_GET['coord']);
if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true')
|| (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) {
//$spotter_array = $Source->getAllLocationInfo();
$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('gs',$coords));
}
if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true')
|| (!isset($_COOKIE['show_WeatherStation']) && (isset($globalMapWeatherStation) && $globalMapWeatherStation === TRUE))) {
$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('wx',$coords));
}
if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true')
|| (!isset($_COOKIE['show_Lightning']) && (isset($globalMapLightning) && $globalMapLightning === TRUE))) {
$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('lightning',$coords));
}
if ((isset($_COOKIE['show_Fire']) && $_COOKIE['show_Fire'] == 'true')
|| (!isset($_COOKIE['show_Fire']) && (isset($globalMapFires) && $globalMapFires === TRUE))) {
$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('fires',$coords,true));
}
$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType(''));
} else {
if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true')
|| (!isset($_COOKIE['show_GroundStation']) && (isset($globalMapGroundStation) && $globalMapGroundStation === TRUE))) {
//$spotter_array = $Source->getAllLocationInfo();
$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('gs'));
}
if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true')
|| (!isset($_COOKIE['show_WeatherStation']) && (isset($globalMapWeatherStation) && $globalMapWeatherStation === TRUE))) {
$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('wx'));
}
if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true')
|| (!isset($_COOKIE['show_Lightning']) && (isset($globalMapLightning) && $globalMapLightning === TRUE))) {
$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('lightning'));
}
if ((isset($_COOKIE['show_Fire']) && $_COOKIE['show_Fire'] == 'true')
|| (!isset($_COOKIE['show_Fire']) && (isset($globalMapFires) && $globalMapFires === TRUE))) {
$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('fires',array(),true));
}
$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType(''));
}
}
$output = '{"type": "FeatureCollection","features": [';
if (!empty($spotter_array) && count($spotter_array) > 0)
{
foreach($spotter_array as $spotter_item)
{
date_default_timezone_set('UTC');
$output .= '{"type": "Feature",';
$output .= '"properties": {';
$output .= '"id": "'.$spotter_item['id'].'",';
$output .= '"location_id": "'.$spotter_item['location_id'].'",';
$output .= '"name": "'.$spotter_item['name'].'",';
$output .= '"city": "'.$spotter_item['city'].'",';
$output .= '"country": "'.$spotter_item['country'].'",';
$output .= '"altitude": "'.$spotter_item['altitude'].'",';
if ($spotter_item['name'] != '' && $spotter_item['city'] != '' && $spotter_item['country'] != '') {
$output .= '"popupContent": "'.$spotter_item['name'].' : '.$spotter_item['city'].', '.$spotter_item['country'].'",';
} elseif ($spotter_item['location_id'] != '') {
$output .= '"popupContent": "'.$spotter_item['location_id'].'",';
}
$output .= '"icon": "'.$globalURL.'/images/'.$spotter_item['logo'].'",';
$output .= '"type": "'.$spotter_item['type'].'",';
if ($spotter_item['type'] == 'wx') {
$weather = json_decode($spotter_item['description'],true);
if (isset($weather['temp'])) $output.= '"temp": "'.$weather['temp'].'",';
}
$output .= '"image_thumb": "'.$spotter_item['image_thumb'].'"';
$output .= '},';
$output .= '"geometry": {';
$output .= '"type": "Point",';
$output .= '"coordinates": ['.$spotter_item['longitude'].', '.$spotter_item['latitude'].']';
$output .= '}';
$output .= '},';
}
$output = substr($output, 0, -1);
}
$output .= ']}';
print $output;
?>