| 311 | } |
| 312 | |
| 313 | bool SegmentFromXML(pugi::xml_node const & segmentNode, LinearSegment & segment) |
| 314 | { |
| 315 | CHECK(segmentNode, ()); |
| 316 | if (!IntegerFromXML(segmentNode.child("ReportSegmentID"), segment.m_segmentId)) |
| 317 | { |
| 318 | LOG(LERROR, ("Can't parse segment id")); |
| 319 | return false; |
| 320 | } |
| 321 | |
| 322 | if (!IntegerFromXML(segmentNode.child("segmentLength"), segment.m_segmentLengthMeters)) |
| 323 | { |
| 324 | LOG(LERROR, ("Can't parse segment length")); |
| 325 | return false; |
| 326 | } |
| 327 | |
| 328 | if (IsLocationReferenceTag(segmentNode)) |
| 329 | { |
| 330 | auto const locRefNode = GetLinearLocationReference(segmentNode); |
| 331 | auto const result = LinearLocationReferenceFromXML(locRefNode, segment.m_locationReference); |
| 332 | if (result) |
| 333 | segment.m_source = LinearSegmentSource::FromLocationReferenceTag; |
| 334 | |
| 335 | return result; |
| 336 | } |
| 337 | |
| 338 | CHECK(IsCoordinatesTag(segmentNode), ()); |
| 339 | auto const coordsNode = GetCoordinates(segmentNode); |
| 340 | if (!CoordinatesFromXML(coordsNode, segment.m_locationReference)) |
| 341 | return false; |
| 342 | |
| 343 | CHECK_EQUAL(segment.m_locationReference.m_points.size(), 2, ()); |
| 344 | segment.m_locationReference.m_points[0].m_distanceToNextPoint = segment.m_segmentLengthMeters; |
| 345 | segment.m_source = LinearSegmentSource::FromCoordinatesTag; |
| 346 | return true; |
| 347 | } |
| 348 | } // namespace openlr |
no test coverage detected