21 : QObject(parent), m_isXmlLoaded(false), m_hasRetrievedLevelCurves(false)
36 if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
38 qDebug() <<
"Failed to open XML file for reading:" << file.errorString();
42 QDomDocument newDocument;
43 if (!newDocument.setContent(&file))
45 qDebug() <<
"Failed to set XML content from file";
64 qDebug() <<
"Level curves have not been retrieved.";
70 qDebug() <<
"XML document is not loaded.";
89 QDomDocument newDocument;
90 if (!newDocument.setContent(text))
92 qDebug() <<
"Failed to set XML content from text";
108 QDomNodeList courbeList = root.elementsByTagName(
"ELEVATION.CONTOUR.LINE:courbe");
112 for (
int i = 0; i < courbeList.size(); ++i)
114 QDomElement courbe = courbeList.at(i).toElement();
123 QString
id = courbe.attribute(
"gml:id");
126 double altitude = courbe.firstChildElement(
"ELEVATION.CONTOUR.LINE:altitude").text().toDouble();
132 courbe.firstChildElement(
"ELEVATION.CONTOUR.LINE:geom").firstChildElement(
"gml:LineString");
133 QString srsName = geom.attribute(
"srsName");
136 QString posList = geom.firstChildElement(
"gml:posList").text();
137 QStringList points = posList.split(
" ");
141 std::vector<Point> CGALpoints;
142 int currentIndex = 0;
144 while (currentIndex < points.size())
146 currentPoint =
getCGALPoint(points, currentIndex, SIGCoords, altitude);
147 CGALpoints.push_back(currentPoint);
151 auto constraint_id =
m_ct.insert_constraint(CGALpoints);
163 size_t nb_removed_vertices = 0;
164 double dStopParam = 0.25;
165 nb_removed_vertices = PS::simplify(
m_ct,
Cost(),
Stop(dStopParam));
166 return nb_removed_vertices;
173 OBox selectedZoneTympanCoords{selectedZone};
177 constraint_it !=
m_ct.constraints_end(); ++constraint_it)
190 QString
id = info.
id;
194 auto vit =
m_ct.points_in_constraint_begin(constraint_id);
196 while (vit !=
m_ct.points_in_constraint_end(constraint_id))
199 bool firstPointFound =
false;
200 while (!firstPointFound && vit !=
m_ct.points_in_constraint_end(constraint_id))
202 currentPoint =
TYPoint{vit->x(), vit->y(), altitude};
204 firstPointFound = selectedZoneTympanCoords.isInside2D(currentPoint);
212 TYPoint fistPointTympanCoords{currentPoint.
_x * scaleFactor, currentPoint.
_y * scaleFactor,
214 listPoints.push_back(fistPointTympanCoords);
216 bool isPointInsideZone =
true;
217 while (isPointInsideZone && vit !=
m_ct.points_in_constraint_end(constraint_id))
219 currentPoint =
TYPoint{vit->x(), vit->y(), altitude};
220 isPointInsideZone = selectedZoneTympanCoords.isInside2D(currentPoint);
221 if (isPointInsideZone)
223 TYPoint newPointTympanCoords{currentPoint.
_x * scaleFactor,
224 currentPoint.
_y * scaleFactor, currentPoint.
_z};
225 listPoints.push_back(newPointTympanCoords);
230 if (listPoints.size() >= 2)
249 const double earthRadius = 6378137.0;
250 const double originShift = 2.0 *
M_PI * earthRadius / 2.0;
252 result.
_x = longitude * originShift / 180.0;
253 result.
_y = log(tan((90.0 + latitude) *
M_PI / 360.0)) / (
M_PI / 180.0);
254 result.
_y = result.
_y * originShift / 180.0;
262 double latitude = points[index].toDouble();
263 double longitude = points[index + 1].toDouble();
267 projectedPoint.
_x -= SIGCoords.
_x;
268 projectedPoint.
_y -= SIGCoords.
_y;
269 projectedPoint.
_z = altitude;
271 return projectedPoint;
std::vector< TYPoint > TYTabPoint
Collection de TYPoint.
PS::Stop_below_count_ratio_threshold Stop
CT::Constraint_iterator Constraint_iterator
PS::Scaled_squared_distance_cost Cost
CT::Constraint_id Constraint_id
virtual void Translate(const OPoint3D &vectorTranslate)
Translate this box.
double _y
y coordinate of OCoord3D
double _z
z coordinate of OCoord3D
double _x
x coordinate of OCoord3D
virtual void debug(const char *message,...)
static OMessageManager * get()
void setListPoints(const TYTabPoint &pts)
void setAltitude(double alt)
void setName(QString name)
QDomDocument m_xmlDocument
std::unordered_map< ConstraintIdWrapper, AltimetryInfo > & getConstraintToAltimetryInfoMap()
Getter for the constraint to AltimetryInfo map.
TYIGNLevelCurvesParser(QObject *parent=nullptr)
std::unordered_map< ConstraintIdWrapper, AltimetryInfo > m_constraintToAltimetryInfoMap
void courbeNiveauCreated(LPTYCourbeNiveau courbeNiveau)
static Point getCGALPoint(const QStringList &points, int index, const OCoord3D &SIGCoords, double altitude)
bool createLevelCurvesFromCT(const OCoord3D &SIGCoords, const OBox &selectedZone, double scaleFactor)
Create level curves from CGAL constrained triangulation.
bool buildXmlDocument(const QString &text)
size_t simplifyPolylines()
bool buildCTFromXMLFile(const OCoord3D &SIGCoords)
Build constrained triangulation from IGN XML file containing level curves.
bool buildPolylineFromCourbe(const QDomElement &courbe, const OCoord3D &SIGCoords)
static TYPoint getPoint(const QStringList &points, int index, const OCoord3D &SIGCoords, double altitude)
void parseXmlData(const OCoord3D &SIGCoords, const OBox &selectedZone, double scaleFactor)
bool loadXmlFile(const QString &filePath)
bool m_hasRetrievedLevelCurves
static TYPoint convertLatLonToWebMercator(double latitude, double longitude)