Code_TYMPAN  4.4.0
Industrial site acoustic simulation
TYIGNGeoPfMocker.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) <2012-2024> <EDF-DTG> <FRANCE>
3  * This file is part of Code_TYMPAN (R).
4  * Code_TYMPAN (R) is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  * Code_TYMPAN (R) is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  * You should have received a copy of the GNU General Public License along
13  * with Code_TYMPAN (R). If not, see <https://www.gnu.org/licenses/>.
14  */
15 
16 #include <iostream>
17 #include <fstream>
18 #include <string>
19 #include <sstream>
20 
21 #include "TYIGNGeoPfMocker.h"
22 #include "TYIGNGeoProvider.h"
23 
25 {
26  bool ret = true;
27  ret &= setLandtakeCoordinates();
28  ret &= setImageProperties();
29  ret &= loadLevelCurves();
30  return ret;
31 }
33 {
34  std::ifstream coordinatesFile("C:/projects/tympan/issues/530 - Mock IGN/landtake_coordinates.txt");
35  if (!coordinatesFile.is_open())
36  {
37  std::cerr << "Failed to open the file landtake_coordinates.txt. Put it in "
38  "C:/projects/tympan/issues/530 - Mock IGN/"
39  << std::endl;
40  return false;
41  }
42 
43  std::string line;
44  if (std::getline(coordinatesFile, line))
45  {
46  TYIGNGeoProvider::getInstance()->setLandtakeCoord(QString::fromStdString(line));
47  }
48  else
49  {
50  std::cerr << "Failed to read from the file." << std::endl;
51  return false;
52  }
53 
54  return true;
55 }
57 {
58  std::ifstream imgPropsFile("C:/projects/tympan/issues/530 - Mock IGN/img_props.txt");
59  if (!imgPropsFile.is_open())
60  {
61  std::cerr
62  << "Failed to open the file img_props.txt. Put it in C:/projects/tympan/issues/530 - Mock IGN/"
63  << std::endl;
64  return false;
65  }
66 
67  int lineNumber = 0;
68  std::string line;
69  while (std::getline(imgPropsFile, line) && lineNumber < 2)
70  {
71  if (lineNumber == 0)
72  {
73  TYIGNGeoProvider::getInstance()->setImageWidth(QString::fromStdString(line));
74  }
75  else if (lineNumber == 1)
76  {
77  TYIGNGeoProvider::getInstance()->setScaleFactor(QString::fromStdString(line));
78  }
79  ++lineNumber;
80  }
81 
82  imgPropsFile.close();
83  return true;
84 }
86 {
87  TYIGNGeoProvider::getInstance()->_parser->loadXmlFile(
88  "C:/projects/tympan/issues/530 - Mock IGN/level_curves.xml");
89  return true;
90 }
std::shared_ptr< TYIGNLevelCurvesParser > _parser
void setImageWidth(const QString &text)
static TYIGNGeoProvider * getInstance()
void setLandtakeCoord(const QString &text)
void setScaleFactor(const QString &text)