-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAvoidanceZones.cpp
65 lines (55 loc) · 2.01 KB
/
AvoidanceZones.cpp
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
#include <iostream>
#include <fstream>
#include "../include/route4me.h"
#define KEY "11111111111111111111111111111111"
using namespace std;
int main()
{
// global init
CRoute4Me::init();
CRoute4Me route(KEY);
ifstream inf("poly.json");
if(!inf.is_open()) {
cout << "Cannot find a file with avoidance zone" << endl;
return -1;
}
Json::Value poly_data;
inf >> poly_data;
if (route.add_avoidance_zone("ABC", poly_data) == 0) {
cout << "Added poly:" << endl << Json::FastWriter().write(route.get_json_resp()) << endl;
}
else {
cout << "Failed adding poly: " << Json::FastWriter().write(route.get_json_resp()) << endl;
}
if (route.get_avoidance_zones() == 0) {
cout << "All zones:" << endl << Json::FastWriter().write(route.get_json_resp()) << endl;
}
else {
cout << "No zones found: " << Json::FastWriter().write(route.get_json_resp()) << endl;
}
if (route.get_avoidance_zone("") == 0) {
cout << "Zone:" << endl << Json::FastWriter().write(route.get_json_resp()) << endl;
}
else {
cout << "No zone: " << Json::FastWriter().write(route.get_json_resp()) << endl;
}
if (route.update_avoidance_zone("ABC", poly_data) == 0) {
cout << "Zone updated:" << endl << Json::FastWriter().write(route.get_json_resp()) << endl;
}
else {
cout << "Zone update failed: " << Json::FastWriter().write(route.get_json_resp()) << endl;
}
if (route.remove_avoidance_zone("ABC") == 0) {
cout << "Zone removed:" << endl << Json::FastWriter().write(route.get_json_resp()) << endl;
}
else {
cout << "Zone removal failed: " << Json::FastWriter().write(route.get_json_resp()) << endl;
}
if (route.get_avoidance_zone("ABC") == 0) {
cout << "Zone:" << endl << Json::FastWriter().write(route.get_json_resp()) << endl;
}
else {
cout << "No zone found: " << Json::FastWriter().write(route.get_json_resp()) << endl;
}
CRoute4Me::cleanup();
}