#pragma once

#include "BaseConstVariable.h"

#include "BaseTool.h"
#include "ImageOperatorBase.h"
#include "GeoOperator.h"
#include "FileOperator.h"
#include "LogInfoCls.h"

enum RasterLevel {
	RasterSLC,
	RasterL1B,
	RasterL2
};

class   BASECONSTVARIABLEAPI	SARSimulationImageL1Dataset
{
public:
	SARSimulationImageL1Dataset(RasterLevel Rasterlevel= RasterLevel::RasterSLC);
	~SARSimulationImageL1Dataset();

private:
	RasterLevel Rasterlevel;
public:
	RasterLevel getRasterLevel();


private :
	QString outFolderPath;
	QString L1DatasetName;
	QString xmlfileName;
	QString xmlFilePath;
	QString ImageRasterName;
	QString ImageRasterPath;
	QString GPSPointFilename;
	QString GPSPointFilePath;

public:
	QString getoutFolderPath(); 
	QString getDatesetName();
	QString getxmlfileName();
	QString getxmlFilePath();
	QString getImageRasterName();
	QString getImageRasterPath();
	QString getGPSPointFilename(); // GPS点
	QString getGPSPointFilePath();


public:
	ErrorCode OpenOrNew(QString folder, QString filename, long rowCount, long colCount);
	ErrorCode Open(QString folderPath, QString Name);
	ErrorCode Open(QString xmlPath);
public:
	void saveToXml();
	ErrorCode loadFromXml();
	std::shared_ptr<double> getAntPos();
	ErrorCode saveAntPos(std::shared_ptr<double> ptr); // 注意这个方法很危险，请写入前检查数据是否正确
	
	std::shared_ptr<std::complex<double>> getImageRaster();
	ErrorCode saveImageRaster(std::shared_ptr<std::complex<double>> echoPtr, long startPRF, long PRFLen);
	std::shared_ptr<std::complex<double>> getImageRaster(long startPRF, long PRFLen);
	
	Eigen::MatrixXcd getImageRasterMatrix();
	ErrorCode saveImageRaster(Eigen::MatrixXcd& data, long startPRF);

	gdalImage getImageRasterGdalImage();

private: // xml中参数
	  
	long rowCount;
	long colCount;

	double Rnear;  
	double Rfar;  
	double Rref;  

	double centerFreq;  
	double Fs;  
	double prf;

	double CenterAngle; 
	QString LookSide;
	QVector<SatelliteAntPos> sateposes;

	double startImageTime;
	double EndImageTime;

public:

	 void	setStartImageTime(double imageTime);
	 double getStartImageTime();

	 void	setEndImageTime(double imageTime);
	 double getEndImageTime();


	QVector<SatelliteAntPos> getXmlSateAntPos();
	void setSateAntPos(QVector<SatelliteAntPos> pos);

	long getrowCount();
	void setrowCount(long rowCount);

	long getcolCount();
	void setcolCount(long pulsePoints);

	double getNearRange();
	void setNearRange(double nearRange);

	double getFarRange();
	void setFarRange(double farRange);

	double getRefRange();
	void setRefRange(double refRange);

	double getCenterFreq();
	void setCenterFreq(double freq);

	double getFs();
	void setFs(double samplingFreq);

	double getPRF();
	void setPRF(double PRF);

	double getCenterAngle();
	void setCenterAngle(double angle);

	QString getLookSide();
	void setLookSide(QString lookside);

public:// 多普勒参数
	double TotalProcessedAzimuthBandWidth, DopplerParametersReferenceTime;
	double d0, d1, d2, d3, d4;
	double r0, r1, r2, r3, r4;
	double DEM;
	double  incidenceAngleNearRange, incidenceAngleFarRange;

public:

	double getTotalProcessedAzimuthBandWidth();
	void setTotalProcessedAzimuthBandWidth(double v);

	double getDopplerParametersReferenceTime();
	void setDopplerParametersReferenceTime(double v);

	QVector<double> getDopplerParams();
	void setDopplerParams(double d0, double d1, double d2, double d3, double d4);

	QVector<double> getDopplerCenterCoff();
	void setDopplerCenterCoff(double r0, double r1, double r2, double r3, double r4);


	double getIncidenceAngleNearRange();
	void setIncidenceAngleNearRangeet(double angle);

	double getIncidenceAngleFarRange();
	void setIncidenceAngleFarRange(double angle);

private:
	double  latitude_center, longitude_center, 
		latitude_topLeft, longitude_topLeft,
		latitude_topRight, longitude_topRight,
		latitude_bottomLeft, longitude_bottomLeft, 
		latitude_bottomRight, longitude_bottomRight;
public:
	// Getter and Setter functions
	double getLatitudeCenter();
	void setLatitudeCenter(double value);

	double getLongitudeCenter();
	void setLongitudeCenter(double value);

	double getLatitudeTopLeft();
	void setLatitudeTopLeft(double value);

	double getLongitudeTopLeft();
	void setLongitudeTopLeft(double value);

	double getLatitudeTopRight();
	void setLatitudeTopRight(double value);

	double getLongitudeTopRight();
	void setLongitudeTopRight(double value);

	double getLatitudeBottomLeft();
	void setLatitudeBottomLeft(double value);

	double getLongitudeBottomLeft();
	void setLongitudeBottomLeft(double value);

	double getLatitudeBottomRight();
	void setLatitudeBottomRight(double value);

	double getLongitudeBottomRight();
	void setLongitudeBottomRight(double value);
public:
	DemBox getExtend();


public:
	double getdrange();
	void setdrange(double dr);

	double getdAz();
	void setdAz(double dAz);
private:
	double dr, dAz;

};

