#ifndef SETTINGS_H
#define SETTINGS_H

#include <Indoor/grid/GridPoint.h>
#include <Indoor/data/Timestamp.h>

#include <QFile>

namespace Settings {

	const int numParticles = 5000;

	namespace IMU {
		const float turnSigma = 1.5;		// 3.5
		const float stepLength = 0.80;
		const float stepSigma = 0.20;
	}

	const float smartphoneAboveGround = 1.3;

	const float offlineSensorSpeedup = 2;

	namespace Grid {
		constexpr int gridSize_cm = 20;
	}


	//const GridPoint destination = GridPoint(70*100, 35*100, 0*100);		// use destination
	const GridPoint destination = GridPoint(0,0,0);							// do not use destination

	namespace SensorDebug {
		const Timestamp updateEvery = Timestamp::fromMS(200);
	}

	namespace WiFiModel {
		constexpr float sigma = 13.0;
		/** if the wifi-signal-strengths are stored on the grid-nodes, this needs a grid rebuild! */
		constexpr float TXP = -48;
		constexpr float EXP = 2.5;
		constexpr float WAF = -5.0;
	}



	namespace MapView3D {
		const int maxColorPoints = 10000;
		constexpr int fps = 15;
		const Timestamp msPerFrame = Timestamp::fromMS(1000/fps);
	}

	namespace Filter {
		const Timestamp updateEvery = Timestamp::fromMS(500);
		constexpr bool useMainThread = false;						// perform filtering in the main thread
	}

	namespace Data {

		// notes
		// copy:	scp -P 2222 /tmp/grid.dat kazu@192.168.24.11:/storage/sdcard1/YASMIN/maps/car/
		// all:		scp -P 2222 -r /apps/android/workspace/YASMIN_DATA/* kazu@192.168.24.11:/storage/sdcard1/YASMIN/

		static inline std::string getRoot() {
			#ifdef ANDROID
			//		const std::string folder = getenv("EXTERNAL_STORAGE") + std::string("/YASMIN/maps/");		// this is NOT the sdcard?!
			//		qDebug(folder.c_str());
			//		return folder;
					//return "/storage/sdcard1/YASMIN/";
				std::string f1 = "/storage/sdcard1/YASMIN/";
				std::string f2 = "/sdcard/YASMIN/";
				if (QFile(f1.c_str()).exists()) {return f1;}
				if (QFile(f2.c_str()).exists()) {return f2;}
				throw Exception("data folder missing");
			#else
					return "/apps/android/workspace/YASMIN_DATA/";
			#endif
		}

		/** get the directory where maps are stored */
		static inline std::string getMapDir() {
			return getRoot() + "maps/";
		}

		static inline std::string getOfflineDir() {
			return getRoot() + "offline/";
		}

	}

}

#endif // SETTINGS_H
