int main(int argc, char* argv[]) { ui(argc, argv); setup(); if (getenv("RTPRIO") != 0){ printf("running posix RT\n"); goPosixRT(llc); close_llc(); return 0; }else{ printf("running regular\n"); llc(0); printf("finished\n"); close_llc(); } }
void Dimap::createGrid(std::string const &nomGrid, std::string const &nomImage, double stepPixel, double stepCarto, double rowCrop, double sampCrop, std::vector<double> vAltitude, std::string targetSyst, std::string inputSyst, std::vector<double> vRefineCoef)const { double firstSamp = first_col; double firstLine = first_row; double lastSamp = last_col; double lastLine = last_row; //Direct nbr Lignes et colonnes + step last ligne et colonne int nbLine, nbSamp; nbLine=(lastLine-firstLine)/stepPixel +1; nbSamp=(lastSamp-firstSamp)/stepPixel +1 ; std::vector<Pt2dr> vPtCarto; createDirectGrid(firstSamp, firstLine, stepPixel, nbSamp, nbLine, vAltitude, vPtCarto, targetSyst, inputSyst, vRefineCoef, rowCrop, sampCrop); double xmin,xmax,ymin,ymax; // Pour estimer la zone carto on projette le domaine de validite geo // Recherche de la zone la plus etendue Pt2dr Pcarto = ptGeo2Carto(Pt2dr(first_lat, first_lon), targetSyst, inputSyst); xmin = Pcarto.x; ymin = Pcarto.y; xmax = xmin; ymax = ymin; Pcarto = ptGeo2Carto(Pt2dr(first_lat,last_lon), targetSyst, inputSyst); if (xmin>Pcarto.x) xmin = Pcarto.x; else if (xmax<Pcarto.x) xmax = Pcarto.x; if (ymin>Pcarto.y) ymin = Pcarto.y; else if (ymax<Pcarto.y) ymax = Pcarto.y; Pcarto = ptGeo2Carto(Pt2dr(last_lat, last_lon), targetSyst, inputSyst); if (xmin>Pcarto.x) xmin = Pcarto.x; else if (xmax<Pcarto.x) xmax = Pcarto.x; if (ymin>Pcarto.y) ymin = Pcarto.y; else if (ymax<Pcarto.y) ymax = Pcarto.y; Pcarto = ptGeo2Carto(Pt2dr(last_lat, first_lon), targetSyst, inputSyst); if (xmin>Pcarto.x) xmin = Pcarto.x; else if (xmax<Pcarto.x) xmax = Pcarto.x; if (ymin>Pcarto.y) ymin = Pcarto.y; else if (ymax<Pcarto.y) ymax = Pcarto.y; //Coins sup gauche et inf droit du domaine de validite RPC inverse Pt2dr urc(xmax,ymax); Pt2dr llc(xmin,ymin); std::cout << "Emprise carto : "<<llc.x<<" "<<urc.y<<" "<<urc.x<<" "<<llc.y<<std::endl; //Indirect nbr Lignes et colonnes + step last ligne et colonne int nbrLine, nbrSamp; nbrSamp=(urc.x-llc.x)/stepCarto +1; nbrLine=(urc.y-llc.y)/stepCarto +1; std::vector<Pt2dr> vPtImg; //Calcul des coefficients de l'affinite pour la transformation inverse std::vector<double> vRefineCoefInv; { double A0 = vRefineCoef[0]; double A1 = vRefineCoef[1]; double A2 = vRefineCoef[2]; double B0 = vRefineCoef[3]; double B1 = vRefineCoef[4]; double B2 = vRefineCoef[5]; double det = A1*B2 - A2*B1; double IA0 = -A0; double IA1 = B2/det; double IA2 = -A2/det; double IB0 = -B0; double IB1 = -B1/det; double IB2 = A1/det; vRefineCoefInv.push_back(IA0); vRefineCoefInv.push_back(IA1); vRefineCoefInv.push_back(IA2); vRefineCoefInv.push_back(IB0); vRefineCoefInv.push_back(IB1); vRefineCoefInv.push_back(IB2); } createIndirectGrid( xmin, ymax,nbrSamp,nbrLine,stepCarto,vAltitude,vPtImg, targetSyst, inputSyst, vRefineCoefInv, rowCrop, sampCrop); //Writing the grid //Creating grid and writing flux std::ofstream writeGrid(nomGrid.c_str()); writeGrid <<"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"<<std::endl; writeGrid <<"<trans_coord_grid version=\"5\" name=\"\">"<<std::endl; //creation of the date time_t t= time(0); struct tm * timeInfo =localtime(&t); std::string date; std::stringstream ssdate; ssdate<<timeInfo-> tm_year+1900; double adate []= {(double)timeInfo-> tm_mon, (double)timeInfo-> tm_mday, (double)timeInfo-> tm_hour,(double)timeInfo-> tm_min, (double)timeInfo-> tm_sec}; std::vector<double> vdate (adate,adate+5); // Formating the date for (int ida=0; ida<5;ida++) { std::stringstream ssdateTempo; std::string dateTempo; ssdateTempo<<vdate[ida]; dateTempo=ssdateTempo.str(); if (dateTempo.length()==2) ssdate<<dateTempo; else ssdate<<0<<dateTempo; } date=ssdate.str(); writeGrid <<"\t<date>"<<date<<"</date>"<<std::endl; writeGrid <<"\t<trans_coord name=\"\">"<<std::endl; writeGrid <<"\t\t<trans_sys_coord name=\"\">"<<std::endl; writeGrid <<"\t\t\t<sys_coord name=\"sys1\">"<<std::endl; writeGrid <<"\t\t\t\t<sys_coord_plani name=\"sys1\">"<<std::endl; writeGrid <<"\t\t\t\t\t<code>"<<nomImage<<"</code>"<<std::endl; writeGrid <<"\t\t\t\t\t<unit>"<<"p"<<"</unit>"<<std::endl; writeGrid <<"\t\t\t\t\t<direct>"<<"0"<<"</direct>"<<std::endl; writeGrid <<"\t\t\t\t\t<sub_code>"<<"*"<<"</sub_code>"<<std::endl; writeGrid <<"\t\t\t\t\t<vertical>"<<nomImage<<"</vertical>"<<std::endl; writeGrid <<"\t\t\t\t</sys_coord_plani>"<<std::endl; writeGrid <<"\t\t\t\t<sys_coord_alti name=\"sys1\">"<<std::endl; writeGrid <<"\t\t\t\t\t<code>"<<"Unused in MicMac"<<"</code>"<<std::endl; writeGrid <<"\t\t\t\t\t<unit>"<<"m"<<"</unit>"<<std::endl; writeGrid <<"\t\t\t\t</sys_coord_alti>"<<std::endl; writeGrid <<"\t\t\t</sys_coord>"<<std::endl; writeGrid <<"\t\t\t<sys_coord name=\"sys2\">"<<std::endl; writeGrid <<"\t\t\t\t<sys_coord_plani name=\"sys2\">"<<std::endl; writeGrid <<"\t\t\t\t\t<code>"<<"Unused in MicMac"<<"</code>"<<std::endl; writeGrid <<"\t\t\t\t\t<unit>"<<"m"<<"</unit>"<<std::endl; writeGrid <<"\t\t\t\t\t<direct>"<<"1"<<"</direct>"<<std::endl; writeGrid <<"\t\t\t\t\t<sub_code>"<<"*"<<"</sub_code>"<<std::endl; writeGrid <<"\t\t\t\t\t<vertical>"<<"Unused in MicMac"<<"</vertical>"<<std::endl; writeGrid <<"\t\t\t\t</sys_coord_plani>"<<std::endl; writeGrid <<"\t\t\t\t<sys_coord_alti name=\"sys2\">"<<std::endl; writeGrid <<"\t\t\t\t\t<code>"<<"Unused in MicMac"<<"</code>"<<std::endl; writeGrid <<"\t\t\t\t\t<unit>"<<"m"<<"</unit>"<<std::endl; writeGrid <<"\t\t\t\t</sys_coord_alti>"<<std::endl; writeGrid <<"\t\t\t</sys_coord>"<<std::endl; writeGrid <<"\t\t</trans_sys_coord>"<<std::endl; writeGrid <<"\t\t<category>"<<"1"<<"</category>"<<std::endl; writeGrid <<"\t\t<type_modele>"<<"2"<<"</type_modele>"<<std::endl; writeGrid <<"\t\t<direct_available>"<<"1"<<"</direct_available>"<<std::endl; writeGrid <<"\t\t<inverse_available>"<<"1"<<"</inverse_available>"<<std::endl; writeGrid <<"\t</trans_coord>"<<std::endl; // For the direct grid writeGrid <<"\t<multi_grid version=\"1\" name=\"1-2\" >"<<std::endl; std::stringstream ssUL; std::stringstream ssStepPix; std::stringstream ssNumbCol; std::stringstream ssNumbLine; std::string sUpperLeft; std::string sStepPix; std::string sNumbCol; std::string sNumbLine; ssUL<<std::setprecision(15)<<firstSamp-sampCrop<<" "<<std::setprecision(15)<<firstLine-rowCrop; ssStepPix<<stepPixel; ssNumbCol<<nbSamp; ssNumbLine<<nbLine; sUpperLeft=ssUL.str(); sStepPix=ssStepPix.str(); sNumbCol=ssNumbCol.str(); sNumbLine=ssNumbLine.str(); writeGrid <<"\t\t<upper_left>"<<sUpperLeft<<"</upper_left>"<<std::endl; writeGrid <<"\t\t<columns_interval>"<<sStepPix<<"</columns_interval>"<<std::endl; writeGrid <<"\t\t<rows_interval>"<<"-"+sStepPix<<"</rows_interval>"<<std::endl; writeGrid <<"\t\t<columns_number>"<<sNumbCol<<"</columns_number>"<<std::endl; writeGrid <<"\t\t<rows_number>"<<sNumbLine<<"</rows_number>"<<std::endl; writeGrid <<"\t\t<components_number>"<<"2"<<"</components_number>"<<std::endl; std::vector<Pt2dr>::const_iterator it = vPtCarto.begin(); for(size_t i=0;i<vAltitude.size();++i) { std::stringstream ssAlti; std::string sAlti; ssAlti<<std::setprecision(15)<<vAltitude[i]; sAlti=ssAlti.str(); writeGrid <<"\t\t\t<layer value=\""<<sAlti<<"\">"<<std::endl; for(int l=0;l<nbLine;++l) { for(int c = 0;c<nbSamp;++c) { Pt2dr const &PtCarto = (*it); ++it; std::stringstream ssCoord; std::string sCoord; ssCoord<<std::setprecision(15)<<PtCarto.x<<" "<<std::setprecision(15)<<PtCarto.y; sCoord=ssCoord.str(); writeGrid <<"\t\t\t"<<sCoord<<std::endl; } } writeGrid <<"\t\t\t</layer>"<<std::endl; } writeGrid <<"\t</multi_grid>"<<std::endl; // For the inverse grid writeGrid <<"\t<multi_grid version=\"1\" name=\"2-1\" >"<<std::endl; std::stringstream ssULInv; std::stringstream ssStepCarto; std::stringstream ssNumbColInv; std::stringstream ssNumbLineInv; std::string sUpperLeftInv; std::string sStepCarto; std::string sNumbColInv; std::string sNumbLineInv; ssULInv<<std::setprecision(15)<<vPtCarto[0].x<<" "<<std::setprecision(15)<<vPtCarto[0].y; ssStepCarto<<std::setprecision(15)<<stepCarto; ssNumbColInv<<nbrSamp; ssNumbLineInv<<nbrLine; sUpperLeftInv=ssULInv.str(); sStepCarto=ssStepCarto.str(); sNumbColInv=ssNumbColInv.str(); sNumbLineInv=ssNumbLineInv.str(); writeGrid <<"\t\t<upper_left>"<<sUpperLeftInv<<"</upper_left>"<<std::endl; writeGrid <<"\t\t<columns_interval>"<<sStepCarto<<"</columns_interval>"<<std::endl; writeGrid <<"\t\t<rows_interval>"<<sStepCarto<<"</rows_interval>"<<std::endl; writeGrid <<"\t\t<columns_number>"<<sNumbColInv<<"</columns_number>"<<std::endl; writeGrid <<"\t\t<rows_number>"<<sNumbLineInv<<"</rows_number>"<<std::endl; writeGrid <<"\t\t<components_number>"<<"2"<<"</components_number>"<<std::endl; std::vector<Pt2dr>::const_iterator it2 = vPtImg.begin(); for(size_t i=0;i<vAltitude.size();++i) { std::stringstream ssAlti; std::string sAlti; ssAlti<<std::setprecision(15)<<vAltitude[i]; sAlti=ssAlti.str(); writeGrid <<"\t\t\t<layer value=\""<<sAlti<<"\">"<<std::endl; for(int l=0;l<nbrLine;++l) { for(int c = 0;c<nbrSamp;++c) { Pt2dr const &PtImg = (*it2); ++it2; std::stringstream ssCoordInv; std::string sCoordInv; ssCoordInv<<std::setprecision(15)<<PtImg.x - sampCrop<<" " <<std::setprecision(15)<<PtImg.y - rowCrop; sCoordInv=ssCoordInv.str(); writeGrid <<"\t\t\t"<<sCoordInv<<std::endl; } } writeGrid <<"\t\t\t</layer>"<<std::endl; } writeGrid <<"\t</multi_grid>"<<std::endl; writeGrid <<"</trans_coord_grid>"<<std::endl; }