-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.php
40 lines (38 loc) · 1.68 KB
/
api.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
<?php
include_once 'util/ArcgisUtil.php';
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Methods: OPTIONS,GET,POST,PUT,DELETE");
header("Access-Control-Max-Age: 3600");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
header('HTTP/1.1 200 OK');
$dest = $_REQUEST['dest'];
switch ($dest) {
case 'coordinate':
if (isset($_REQUEST['distance']) && ! empty($_REQUEST['distance']) && isset($_REQUEST['angle']) && ! empty($_REQUEST['angle'])) {
echo json_encode(ArcgisUtil::destinationPoint($_REQUEST['longitude'], $_REQUEST['latitude'], $_REQUEST['distance'], $_REQUEST['angle']));
} else {
echo json_encode(array(
$_REQUEST['longitude'],
$_REQUEST['latitude']
));
}
break;
case 'json':
$old_json = ArcgisUtil::createPointJsonData(array(
$_REQUEST['longitude'],
$_REQUEST['latitude']
));
$result = array(
$old_json
);
if (isset($_REQUEST['distance']) && ! empty($_REQUEST['distance']) && isset($_REQUEST['angle']) && ! empty($_REQUEST['angle'])) {
$newPoint = ArcgisUtil::destinationPoint($_REQUEST['longitude'], $_REQUEST['latitude'], $_REQUEST['distance'], $_REQUEST['angle']);
$new_json = ArcgisUtil::createPointJsonData($newPoint, ArcgisUtil::hexToRGB("#00ff00"));
array_push($result, $new_json);
}
echo json_encode($result);
break;
default:
header('HTTP/1.1 404 Not Found');
}