Ejemplo n.º 1
0
Pt2dr Dimap::ptGeo2Carto(Pt2dr Pgeo, std::string targetSyst, std::string inputSyst)const
{
    std::ofstream fic("processing/conv_ptGeo.txt");
    fic << std::setprecision(15);
    fic << Pgeo.y <<" "<<Pgeo.x<<";"<<std::endl;
    // transformation in the ground coordinate system
    std::string command;
	command = g_externalToolHandler.get("cs2cs").callName() + " " + inputSyst + " +to " + targetSyst + " processing/conv_ptGeo.txt > processing/conv_ptCarto.txt";
    int res = system(command.c_str());
    if (res != 0) std::cout<<"error calling cs2cs in ptGeo2Carto"<<std::endl;
    // loading the coordinate of the converted point
    Pt2dr PointCarto;
    std::ifstream fic2("processing/conv_ptCarto.txt");
    while(!fic2.eof()&&fic2.good())
    {
        double X,Y,Z;
        fic2 >> Y >> X >> Z;
        if (fic2.good())
        {
            PointCarto.x=X;
            PointCarto.y=Y;
        }
    }
	cout << PointCarto << endl;
    return PointCarto;
}
Ejemplo n.º 2
0
//reads the txt file with the satellite positions in ECEF coordinates
vector<vector<Pt3dr> > ReadSatPos(string aTxtSatPos)
{
	//Reading the file
	vector<vector<Pt3dr> > aSatPos;
	std::ifstream fic2(aTxtSatPos.c_str());
	u_int i = 0;
	while (!fic2.eof() && fic2.good())
	{
		double X, Y, Z;
		fic2 >> X >> Y >> Z;

		Pt3dr aPt(X, Y, Z);
		//std::cout << i << " " << aPt << endl;
		vector<Pt3dr> aVectPts;

		for (u_int j = 0; j < 11; j++)
			aVectPts.push_back(aPt);

		aSatPos.push_back(aVectPts);
		//std::cout << i << " " << aSatPos[i] << endl;
		i++;
	}
	cout << "Loaded " << aSatPos.size() << " satellite position points in ECEF coordinates" << endl;

	return aSatPos;
}
Ejemplo n.º 3
0
//OLD reads the txt file with lattice point in geocentric coordinates and transforms them into geodetic (unit : degrees)
vector<vector<Pt3dr> > ReadLatticeGeo_OLD(string aTxtLong, string aTxtLat)
{
	//Reading the file
	vector<vector<Pt3dr> > aMatGeo;
	//Reading longitudes of lattice pts
	std::ifstream fic1(aTxtLong.c_str());
	while (!fic1.eof() && fic1.good())
	{
		double L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11;
		fic1 >> L1 >> L2 >> L3 >> L4 >> L5 >> L6 >> L7 >> L8 >> L9 >> L10 >> L11;
		vector<Pt3dr> aVectPts;
		//for (u_int i = 0; i < 11; i++)
		//{
		//		
		//}
		Pt3dr aPt1(L1, 0.0, 0.0); aVectPts.push_back(aPt1);
		Pt3dr aPt2(L2, 0.0, 0.0); aVectPts.push_back(aPt2);
		Pt3dr aPt3(L3, 0.0, 0.0); aVectPts.push_back(aPt3);
		Pt3dr aPt4(L4, 0.0, 0.0); aVectPts.push_back(aPt4);
		Pt3dr aPt5(L5, 0.0, 0.0); aVectPts.push_back(aPt5);
		Pt3dr aPt6(L6, 0.0, 0.0); aVectPts.push_back(aPt6);
		Pt3dr aPt7(L7, 0.0, 0.0); aVectPts.push_back(aPt7);
		Pt3dr aPt8(L8, 0.0, 0.0); aVectPts.push_back(aPt8);
		Pt3dr aPt9(L9, 0.0, 0.0); aVectPts.push_back(aPt9);
		Pt3dr aPt10(L10, 0.0, 0.0); aVectPts.push_back(aPt10);
		Pt3dr aPt11(L11, 0.0, 0.0); aVectPts.push_back(aPt11);

		aMatGeo.push_back(aVectPts);
	}
	//Reading latitudes of lattice pts
	std::ifstream fic2(aTxtLat.c_str());
	u_int i = 0;
	while (!fic2.eof() && fic2.good())
	{
		double L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11;
		fic2 >> L1 >> L2 >> L3 >> L4 >> L5 >> L6 >> L7 >> L8 >> L9 >> L10 >> L11;
		double WGSCorFact = 0.99330562;
		//cout << setprecision(15) << "pi = " << M_PI << endl;
		//geocentric->geodetic
		aMatGeo[i][0].y = atan(tan(L1 *M_PI / 180) / WGSCorFact) * 180 / M_PI;
		aMatGeo[i][1].y = atan(tan(L2 *M_PI / 180) / WGSCorFact) * 180 / M_PI;
		aMatGeo[i][2].y = atan(tan(L3 *M_PI / 180) / WGSCorFact) * 180 / M_PI;
		aMatGeo[i][3].y = atan(tan(L4 *M_PI / 180) / WGSCorFact) * 180 / M_PI;
		aMatGeo[i][4].y = atan(tan(L5 *M_PI / 180) / WGSCorFact) * 180 / M_PI;
		aMatGeo[i][5].y = atan(tan(L6 *M_PI / 180) / WGSCorFact) * 180 / M_PI;
		aMatGeo[i][6].y = atan(tan(L7 *M_PI / 180) / WGSCorFact) * 180 / M_PI;
		aMatGeo[i][7].y = atan(tan(L8 *M_PI / 180) / WGSCorFact) * 180 / M_PI;
		aMatGeo[i][8].y = atan(tan(L9 *M_PI / 180) / WGSCorFact) * 180 / M_PI;
		aMatGeo[i][9].y = atan(tan(L10 *M_PI / 180) / WGSCorFact) * 180 / M_PI;
		aMatGeo[i][10].y = atan(tan(L11 *M_PI / 180) / WGSCorFact) * 180 / M_PI;
		//std::cout << "Ligne " << i << " : " << aMatGeo[i] << endl;
		i++;
	}

	std::cout << "Loaded " << aMatGeo.size()*aMatGeo[0].size() << " lattice points in geodetic coordinates" << endl;

	return aMatGeo;
}
Ejemplo n.º 4
0
void StarMgr::init()
{
	QSettings* conf = StelApp::getInstance().getSettings();
	Q_ASSERT(conf);

	starConfigFileFullPath = StelFileMgr::findFile("stars/default/starsConfig.json", StelFileMgr::Flags(StelFileMgr::Writable|StelFileMgr::File));
	if (starConfigFileFullPath.isEmpty())
	{
		qWarning() << "Could not find the starsConfig.json file: will copy the default one.";
		copyDefaultConfigFile();
	}

	QFile fic(starConfigFileFullPath);
	if(fic.open(QIODevice::ReadOnly))
	{
		starSettings = StelJsonParser::parse(&fic).toMap();
		fic.close();
	}

	// Increment the 1 each time any star catalog file change
	if (starSettings.value("version").toInt()!=StarCatalogFormatVersion)
	{
		qWarning() << "Found an old starsConfig.json file, upgrade..";
		fic.remove();
		copyDefaultConfigFile();
		QFile fic2(starConfigFileFullPath);
		if(fic2.open(QIODevice::ReadOnly))
		{
			starSettings = StelJsonParser::parse(&fic2).toMap();
			fic2.close();
		}
	}

	loadData(starSettings);
	starFont.setPixelSize(StelApp::getInstance().getBaseFontSize());

	setFlagStars(conf->value("astro/flag_stars", true).toBool());
	setFlagLabels(conf->value("astro/flag_star_name",true).toBool());
	setLabelsAmount(conf->value("stars/labels_amount",3.f).toFloat());

	objectMgr->registerStelObjectMgr(this);
	texPointer = StelApp::getInstance().getTextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures/pointeur2.png");   // Load pointer texture

	StelApp::getInstance().getCore()->getGeodesicGrid(maxGeodesicGridLevel)->visitTriangles(maxGeodesicGridLevel,initTriangleFunc,this);
	foreach(ZoneArray* z, gridLevels)
		z->scaleAxis();
	StelApp *app = &StelApp::getInstance();
	connect(app, SIGNAL(languageChanged()), this, SLOT(updateI18n()));
	connect(app, SIGNAL(skyCultureChanged(const QString&)), this, SLOT(updateSkyCulture(const QString&)));
	connect(app, SIGNAL(colorSchemeChanged(const QString&)), this, SLOT(setStelStyle(const QString&)));

	QString displayGroup = N_("Display Options");
	addAction("actionShow_Stars", displayGroup, N_("Stars"), "flagStarsDisplayed", "S");
	addAction("actionShow_Stars_Labels", displayGroup, N_("Stars labels"), "flagLabelsDisplayed", "Alt+S");
}
Ejemplo n.º 5
0
//reads the txt file with lattice point in geocentric coordinates and transforms them into ECEF coordinates
vector<vector<Pt3dr> > ReadLatticeGeo(string aTxtLong, string aTxtLat)
{
	//Reading the file
	vector<vector<Pt3dr> > aMatGeoGeocentric;
	vector<vector<Pt3dr> > aMatGeo;
	//Reading longitudes of lattice pts
	std::ifstream fic1(aTxtLong.c_str());
	while (!fic1.eof() && fic1.good())
	{
		double L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11;
		fic1 >> L1 >> L2 >> L3 >> L4 >> L5 >> L6 >> L7 >> L8 >> L9 >> L10 >> L11;
		vector<Pt3dr> aVectPts;
		//for (u_int i = 0; i < 11; i++)
		//{
		//		
		//}
		Pt3dr aPt1(L1, 0.0, 0.0); aVectPts.push_back(aPt1);
		Pt3dr aPt2(L2, 0.0, 0.0); aVectPts.push_back(aPt2);
		Pt3dr aPt3(L3, 0.0, 0.0); aVectPts.push_back(aPt3);
		Pt3dr aPt4(L4, 0.0, 0.0); aVectPts.push_back(aPt4);
		Pt3dr aPt5(L5, 0.0, 0.0); aVectPts.push_back(aPt5);
		Pt3dr aPt6(L6, 0.0, 0.0); aVectPts.push_back(aPt6);
		Pt3dr aPt7(L7, 0.0, 0.0); aVectPts.push_back(aPt7);
		Pt3dr aPt8(L8, 0.0, 0.0); aVectPts.push_back(aPt8);
		Pt3dr aPt9(L9, 0.0, 0.0); aVectPts.push_back(aPt9);
		Pt3dr aPt10(L10, 0.0, 0.0); aVectPts.push_back(aPt10);
		Pt3dr aPt11(L11, 0.0, 0.0); aVectPts.push_back(aPt11);

		aMatGeoGeocentric.push_back(aVectPts);
	}
	//Reading latitudes of lattice pts
	std::ifstream fic2(aTxtLat.c_str());
	u_int k = 0;
	while (!fic2.eof() && fic2.good())
	{
		double L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11;
		fic2 >> L1 >> L2 >> L3 >> L4 >> L5 >> L6 >> L7 >> L8 >> L9 >> L10 >> L11;
		aMatGeoGeocentric[k][0].y = L1 ;
		aMatGeoGeocentric[k][1].y = L2 ;
		aMatGeoGeocentric[k][2].y = L3 ;
		aMatGeoGeocentric[k][3].y = L4 ;
		aMatGeoGeocentric[k][4].y = L5 ;
		aMatGeoGeocentric[k][5].y = L6 ;
		aMatGeoGeocentric[k][6].y = L7 ;
		aMatGeoGeocentric[k][7].y = L8 ;
		aMatGeoGeocentric[k][8].y = L9 ;
		aMatGeoGeocentric[k][9].y = L10;
		aMatGeoGeocentric[k][10].y = L11;
		k++;
	}

	//Convert to ECEF
	double a = 6378137;
	double b = (1 - 1 / 298.257223563)*a;
	for (u_int i = 0; i < aMatGeoGeocentric.size(); i++){
		vector<Pt3dr> aVectPt;
		for (u_int j = 0; j < aMatGeoGeocentric[0].size(); j++){
			Pt3dr aPt;
			double aSinLat = sin(aMatGeoGeocentric[i][j].y*M_PI / 180);
			double aCosLat = cos(aMatGeoGeocentric[i][j].y*M_PI / 180);
			double aSinLon = sin(aMatGeoGeocentric[i][j].x*M_PI / 180);
			double aCosLon = cos(aMatGeoGeocentric[i][j].x*M_PI / 180);
			double r = sqrt(a*a*b*b / (a*a*aSinLat*aSinLat + b*b*aCosLat*aCosLat));
			aPt.x = r*aCosLat*aCosLon;
			aPt.y = r*aCosLat*aSinLon;
			aPt.z = r*aSinLat;
			aVectPt.push_back(aPt);
		}
		aMatGeo.push_back(aVectPt);
	}

	std::cout << "Loaded " << aMatGeo.size()*aMatGeo[0].size() << " lattice points in geodetic coordinates" << endl;

	return aMatGeo;
}
int Luc_main(int argc, char ** argv)
{
    //GET PSEUDO-RPC2D FOR ASTER FROM LATTICE POINTS
    std::string aTxtImage, aTxtCarto;
    std::string aFileOut = "RPC2D-params.xml";
    //Reading the arguments
    ElInitArgMain
        (
        argc, argv,
        LArgMain()
        << EAMC(aTxtImage, "txt file contaning the lattice point in the image coordinates", eSAM_IsPatFile)
        << EAMC(aTxtCarto, "txt file contaning the lattice point in the carto coordinates", eSAM_IsPatFile),
        LArgMain()
        << EAM(aFileOut, "Out", true, "Output xml file with RPC2D coordinates")
        );

    //Reading the files
    vector<Pt2dr> aPtsIm, aPtsCarto;
    {
        std::ifstream fic(aTxtImage.c_str());
        while (!fic.eof() && fic.good())
        {
            double X, Y;
            fic >> X >> Y;
            Pt2dr aPt(X, Y);
            if (fic.good())
            {
                aPtsIm.push_back(aPt);
            }
        }
        cout << "Read " << aPtsIm.size() << " points in image coordinates" << endl;
        //cout << aPtsIm << endl;
        std::ifstream fic2(aTxtCarto.c_str());
        while (!fic2.eof() && fic2.good())
        {
            double X, Y, Z;
            fic2 >> X >> Y >> Z;
            Pt2dr aPt(X, Y);
            if (fic2.good())
            {
                aPtsCarto.push_back(aPt);
            }
        }
        cout << "Read " << aPtsCarto.size() << " points in cartographic coordinates" << endl;
        //cout << aPtsCarto << endl;
    }

    //Finding normalization parameters
    //divide Pts into X and Y
    vector<double> aPtsCartoX, aPtsCartoY, aPtsImX, aPtsImY;
    for (u_int i = 0; i < aPtsCarto.size(); i++)
    {
        aPtsCartoX.push_back(aPtsCarto[i].x);
        aPtsCartoY.push_back(aPtsCarto[i].y);
        aPtsImX.push_back(aPtsIm[i].x);
        aPtsImY.push_back(aPtsIm[i].y);
    }

    Pt2dr aPtCartoMin(*std::min_element(aPtsCartoX.begin(), aPtsCartoX.end()), *std::min_element(aPtsCartoY.begin(), aPtsCartoY.end()));
    Pt2dr aPtCartoMax(*std::max_element(aPtsCartoX.begin(), aPtsCartoX.end()), *std::max_element(aPtsCartoY.begin(), aPtsCartoY.end()));
    Pt2dr aPtImMin(*std::min_element(aPtsImX.begin(), aPtsImX.end()), *std::min_element(aPtsImY.begin(), aPtsImY.end()));
    Pt2dr aPtImMax(*std::max_element(aPtsImX.begin(), aPtsImX.end()), *std::max_element(aPtsImY.begin(), aPtsImY.end()));
    Pt2dr aCartoScale((aPtCartoMax.x - aPtCartoMin.x) / 2, (aPtCartoMax.y - aPtCartoMin.y) / 2);
    Pt2dr aImScale((aPtImMax.x - aPtImMin.x) / 2, (aPtImMax.y - aPtImMin.y) / 2);
    Pt2dr aCartoOffset(aPtCartoMin.x + (aPtCartoMax.x - aPtCartoMin.x) / 2, aPtCartoMin.y + (aPtCartoMax.y - aPtCartoMin.y) / 2);
    Pt2dr aImOffset(aPtImMin.x + (aPtImMax.x - aPtImMin.x) / 2, aPtImMin.y + (aPtImMax.y - aPtImMin.y) / 2);

    //Parameters too get parameters of P1 and P2 in ---  Column=P1(X,Y)/P2(X,Y)  --- where (X,Y) are Carto coordinates (idem for Row)
    //Function is 0=Poly1(X,Y)-Column*Poly2(X,Y) ==> Column*k=a+bX+cY+dXY+eX^2+fY^2+gX^2Y+hXY^2+iX^3+jY^3-Column(lX+mY+nXY+oX^2+pY^2+qX^2Y+rXY^2+sX^3+tY^3)
    //k=1 to avoid sol=0
    L2SysSurResol aSysCol(19), aSysRow(19);

    //For all lattice points
    for (u_int i = 0; i<aPtsCarto.size(); i++){

        //NORMALIZATION
        double X = (aPtsCarto[i].x - aCartoOffset.x) / aCartoScale.x;
        double Y = (aPtsCarto[i].y - aCartoOffset.y) / aCartoScale.y;
        double COL = (aPtsIm[i].x - aImOffset.x) / aImScale.x;
        double ROW = (aPtsIm[i].y - aImOffset.y) / aImScale.y;

        double aEqCol[19] = {
            (1),
            (X),
            (Y),
            (X*Y),
            (pow(X, 2)),
            (pow(Y, 2)),
            (pow(X, 2)*Y),
            (X*pow(Y, 2)),
            (pow(X, 3)),
            (pow(Y, 3)),
            //(COL),
            (-COL*X),
            (-COL*Y),
            (-COL*X*Y),
            (-COL*pow(X, 2)),
            (-COL*pow(Y, 2)),
            (-COL*pow(X, 2)*Y),
            (-COL*X*pow(Y, 2)),
            (-COL*pow(X, 3)),
            (-COL*pow(Y, 3)),
        };
		aSysCol.AddEquation(1, aEqCol, COL);


        double aEqRow[19] = {
            (1),
            (X),
            (Y),
            (X*Y),
            (pow(X, 2)),
            (pow(Y, 2)),
            (pow(X, 2)*Y),
            (X*pow(Y, 2)),
            (pow(X, 3)),
            (pow(Y, 3)),
            //(ROW),
            (-ROW*X),
            (-ROW*Y),
            (-ROW*X*Y),
            (-ROW*pow(X, 2)),
            (-ROW*pow(Y, 2)),
            (-ROW*pow(X, 2)*Y),
            (-ROW*X*pow(Y, 2)),
            (-ROW*pow(X, 3)),
            (-ROW*pow(Y, 3)),
        };
		aSysRow.AddEquation(1, aEqRow, ROW);
    }

    //Computing the result
    bool Ok;
    Im1D_REAL8 aSolCol = aSysCol.GSSR_Solve(&Ok);
    Im1D_REAL8 aSolRow = aSysRow.GSSR_Solve(&Ok);
    double* aDataCol = aSolCol.data();
    double* aDataRow = aSolRow.data();

    //Outputting results
    {
        std::ofstream fic(aFileOut.c_str());
        fic << std::setprecision(15);
		fic << "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" << endl;
		fic << "<RPC2D>" << endl;
        fic << "\t<RFM_Validity>" << endl;
        fic << "\t\t<Direct_Model_Validity_Domain>" << endl;
        fic << "\t\t\t<FIRST_ROW>" << aPtImMin.x << "</FIRST_ROW>" << endl;
        fic << "\t\t\t<FIRST_COL>" << aPtImMin.y << "</FIRST_COL>" << endl;
        fic << "\t\t\t<LAST_ROW>" << aPtImMax.x << "</LAST_ROW>" << endl;
        fic << "\t\t\t<LAST_COL>" << aPtImMax.y << "</LAST_COL>" << endl;
        fic << "\t\t</Direct_Model_Validity_Domain>" << endl;
        fic << "\t\t<Inverse_Model_Validity_Domain>" << endl;
        fic << "\t\t\t<FIRST_X>" << aPtCartoMin.x << "</FIRST_X>" << endl;
        fic << "\t\t\t<FIRST_Y>" << aPtCartoMin.y << "</FIRST_Y>" << endl;
        fic << "\t\t\t<LAST_X>" << aPtCartoMax.x << "</LAST_X>" << endl;
        fic << "\t\t\t<LAST_Y>" << aPtCartoMax.y << "</LAST_Y>" << endl;
        fic << "\t\t</Inverse_Model_Validity_Domain>" << endl;

        fic << "\t\t<X_SCALE>" << aCartoScale.x << "</X_SCALE>" << endl;
        fic << "\t\t<X_OFF>" << aCartoOffset.x << "</X_OFF>" << endl;
        fic << "\t\t<Y_SCALE>" << aCartoScale.y << "</Y_SCALE>" << endl;
        fic << "\t\t<Y_OFF>" << aCartoOffset.y << "</Y_OFF>" << endl;

        fic << "\t\t<SAMP_SCALE>" << aImScale.x << "</SAMP_SCALE>" << endl;
        fic << "\t\t<SAMP_OFF>" << aImOffset.x << "</SAMP_OFF>" << endl;
        fic << "\t\t<LINE_SCALE>" << aImScale.y << "</LINE_SCALE>" << endl;
        fic << "\t\t<LINE_OFF>" << aImOffset.y << "</LINE_OFF>" << endl;

        fic << "\t</RFM_Validity>" << endl;

        for (int i = 0; i<10; i++)
        {
			fic << "<COL_NUMERATOR_" << i + 1 << ">" << aDataCol[i] << "</COL_NUMERATOR_" << i + 1 << ">" << endl;
        }
		fic << "<COL_DENUMERATOR_1>1</COL_DENUMERATOR_1>" << endl;
        for (int i = 10; i<19; i++)
        {
			fic << "<COL_DENUMERATOR_" << i - 8 << ">" << aDataCol[i] << "</COL_DENUMERATOR_" << i -8 << ">" << endl;
        }
		for (int i = 0; i<10; i++)
		{
			fic << "<ROW_NUMERATOR_" << i + 1 << ">" << aDataRow[i] << "</ROW_NUMERATOR_" << i + 1 << ">" << endl;
		}
		fic << "<ROW_DENUMERATOR_1>1</ROW_DENUMERATOR_1>" << endl;
		for (int i = 10; i<19; i++)
		{
			fic << "<ROW_DENUMERATOR_" << i - 8 << ">" << aDataRow[i] << "</ROW_DENUMERATOR_" << i - 8 << ">" << endl;
		}
		fic << "</RPC2D>" << endl;
    }
    cout << "Written functions in file " << aFileOut << endl;

    return 0;
}