blob: f2f1248aa6a21da33c2871a7bb1d81f5620e0974 (
plain)
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
|
#include "settings_json.hpp"
#include <rapidjson/prettywriter.h>
#include <rapidjson/filestream.h>
#include <rapidjson/document.h>
#include <stdio.h>
using namespace mbgl;
Settings_JSON::Settings_JSON() { load(); }
void Settings_JSON::load() {
FILE *settingsFile = fopen("/tmp/mbgl-native.json", "r");
if (settingsFile != NULL) {
rapidjson::FileStream is(settingsFile);
rapidjson::Document document;
document.ParseStream<0>(is);
if (document.IsArray()) {
longitude = document[rapidjson::SizeType(0)].GetDouble();
latitude = document[1].GetDouble();
zoom = document[2].GetDouble();
bearing = document[3].GetDouble();
debug = document[4].GetBool();
}
}
}
void Settings_JSON::save() {
rapidjson::FileStream s(fopen("/tmp/mbgl-native.json", "w"));
rapidjson::PrettyWriter<rapidjson::FileStream> writer(s);
writer.StartArray();
writer.Double(longitude);
writer.Double(latitude);
writer.Double(zoom);
writer.Double(bearing);
writer.Bool(debug);
writer.EndArray();
}
void Settings_JSON::clear() {
longitude = 0;
latitude = 0;
zoom = 0;
bearing = 0;
debug = false;
}
|