-
Notifications
You must be signed in to change notification settings - Fork 33
/
region.php
69 lines (53 loc) · 1.61 KB
/
region.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
<?php
use src\Models\ApplicationContainer;
use src\Models\Coordinates\Coordinates;
use src\Models\Coordinates\GeoCode;
use src\Models\Coordinates\NutsLocation;
require_once __DIR__ . '/lib/common.inc.php';
if (! ApplicationContainer::GetAuthorizedUser()) {
echo 'Not authorized!';
exit;
}
$lat_float = 0;
$latOk = false;
$lonOk = false;
$coords = null;
if (isset($_REQUEST['lat'])) {
$lat_float = (float) $_REQUEST['lat'];
$lat = $_REQUEST['lat'];
$latOk = true;
}
$lon_float = 0;
if (isset($_REQUEST['lon'])) {
$lon_float = (float) $_REQUEST['lon'];
$lon = $_REQUEST['lon'];
$lonOk = true;
}
if ($latOk && $lonOk) {
$coords = Coordinates::FromCoordsFactory($lat, $lon);
}
if (! is_null($coords)) {
tpl_set_var('coords_str', $coords->getAsText(Coordinates::COORDINATES_FORMAT_DEG_MIN));
$nutsData = NutsLocation::fromCoordsFactory($coords);
tpl_set_var('nutsDesc', $nutsData->getDescription(' > '));
$googleGeocode = GeoCode::fromGoogleApi($coords);
if ($googleGeocode) {
tpl_set_var('googleDesc', $googleGeocode->getDescription(' > '));
} else {
tpl_set_var('googleDesc', '-');
}
$nominatimGeoCode = GeoCode::fromNominatimApi($coords);
if ($nominatimGeoCode) {
tpl_set_var('nominatimDesc', $nominatimGeoCode->getDescription(' > '));
} else {
tpl_set_var('nominatimDesc', '-');
}
} else {
tpl_set_var('coords_str', '');
tpl_set_var('nutsDesc', '-');
tpl_set_var('googleDesc', '-');
tpl_set_var('mapQuestDesc', '-');
}
//make the template and send it out
tpl_set_tplname('region');
tpl_BuildTemplate();