#pragma once
#include <math.h>
#include"glm/glm.hpp"
#include"map"
#include"string"
using namespace std;
class NavinfoGISCoord
{
public:
	static NavinfoGISCoord* GetInstance();
	glm::dvec2 LatLonToTM(const double &lon, const double &lat, const char* name);
	glm::dvec2 XYToLatLonTM(double x, double y, bool southhemi, const char* name);
	//glm::dvec2 XYToLatLonTM(double x, double y, bool southhemi);
	double TMCentralMeridian(const double &zone);


	glm::dvec2 LatLonToUTM(const double &lon, const double &lat, const char* name);
	glm::dvec2 XYToLatLonUTM(double x, double y, bool southhemi, const char* name);
	//glm::dvec2 XYToLatLonUTM(double x, double y, bool southhemi);
		
	double UTMCentralMeridian(const double &zone);
	glm::dvec2 MapLatLonToXY(const double &phi, const double &lambda, const double &lambda0);
	glm::dvec2 MapXYToLatLon(double x, double y, double lambda0);
	double ArcLengthOfMeridian(const double &phi);
	double FootpointLatitude(double y);

private:
	NavinfoGISCoord();
	~NavinfoGISCoord();
private:
	const double pi = M_PI;

	const double sm_a = 6378137.0;
	const double sm_b = 6356752.3142;
	const double TMScaleFactor = 1.0;
	const double UTMScaleFactor = 0.99960000000000000;

	map<string, double> *_mapUTMZone;
	map<string, double> *_mapTMZone;
	map<string, glm::dvec2> *_mapUTMDiff;
	map<string, glm::dvec2> *_mapTMDiff;
private:
	static NavinfoGISCoord *_instance;
};



