MCPcopy Create free account
hub / github.com/comaps/comaps / SegmentFromXML

Function SegmentFromXML

tools/openlr/openlr_model_xml.cpp:313–347  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

311}
312
313bool 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

Callers 2

ParseOpenlrFunction · 0.85
TrafficModeMethod · 0.85

Calls 8

IntegerFromXMLFunction · 0.85
IsLocationReferenceTagFunction · 0.85
IsCoordinatesTagFunction · 0.85
GetCoordinatesFunction · 0.85
CoordinatesFromXMLFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected