Files
MapLibreParticleLab/platform/glfw/settings_json.cpp
Bart Louwers 2a8ebc4906 core: rename mbgl directories to mln (#4511)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-08-22 20:50:14 +02:00

61 lines
1.3 KiB
C++

#include "settings_json.hpp"
#include <fstream>
#include <mln/util/constants.hpp>
#include <mln/math/angles.hpp>
namespace mln {
Settings_JSON::Settings_JSON() {
load();
}
void Settings_JSON::load() {
std::ifstream file("/tmp/mbgl-native.cfg");
if (file) {
file >> longitude;
file >> latitude;
file >> altitude;
file >> zoom;
file >> bearing;
file >> pitch;
file >> roll;
file >> fov;
file >> maxPitch;
file >> debug;
file >> online;
}
}
void Settings_JSON::save() {
std::ofstream file("/tmp/mbgl-native.cfg");
if (file) {
file << longitude << std::endl;
file << latitude << std::endl;
file << altitude << std::endl;
file << zoom << std::endl;
file << bearing << std::endl;
file << pitch << std::endl;
file << roll << std::endl;
file << fov << std::endl;
file << maxPitch << std::endl;
file << debug << std::endl;
file << online << std::endl;
}
}
void Settings_JSON::clear() {
longitude = 0;
latitude = 0;
altitude = 0;
zoom = 0;
bearing = 0;
pitch = 0;
roll = 0;
fov = util::rad2deg(util::DEFAULT_FOV);
maxPitch = util::rad2deg(util::DEFAULT_PITCH_MAX);
debug = 0;
online = true;
}
} // namespace mln