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

Method MakeValid

libs/kml/serdes.cpp:736–793  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

734}
735
736bool KmlParser::MakeValid()
737{
738 if (m_geometry.IsValid())
739 {
740 for (size_t lineIdx = 0; lineIdx < m_geometry.m_lines.size(); ++lineIdx)
741 {
742 auto & timestamps = m_geometry.m_timestamps[lineIdx];
743 if (timestamps.empty())
744 continue;
745
746 std::set<size_t> * skipSet = nullptr;
747 if (auto it = m_skipTimes.find(lineIdx); it != m_skipTimes.end())
748 skipSet = &it->second;
749
750 size_t const pointsSize = m_geometry.m_lines[lineIdx].size();
751 if (pointsSize + (skipSet ? skipSet->size() : 0) != timestamps.size())
752 {
753 MYTHROW(kml::DeserializerKml::DeserializeException,
754 ("Timestamps size", timestamps.size(), "mismatch with the points size:", pointsSize,
755 "for the track:", lineIdx));
756 }
757
758 if (skipSet)
759 {
760 MultiGeometry::TimeT newTimes;
761 newTimes.reserve(timestamps.size() - skipSet->size());
762
763 for (size_t i = 0; i < timestamps.size(); ++i)
764 if (!skipSet->contains(i))
765 newTimes.push_back(timestamps[i]);
766 timestamps.swap(newTimes);
767 }
768 }
769 }
770
771 if (GEOMETRY_TYPE_POINT == m_geometryType)
772 {
773 if (mercator::ValidX(m_org.x) && mercator::ValidY(m_org.y))
774 {
775 // Set default name.
776 if (m_name.empty() && m_featureTypes.empty())
777 m_name[kDefaultLang] = PointToLineString(m_org);
778
779 // Set default pin.
780 if (m_predefinedColor == PredefinedColor::None)
781 m_predefinedColor = PredefinedColor::Red;
782
783 return true;
784 }
785 return false;
786 }
787 else if (GEOMETRY_TYPE_LINE == m_geometryType)
788 {
789 return m_geometry.IsValid();
790 }
791
792 return false;
793}

Callers

nothing calls this directly

Calls 11

ValidXFunction · 0.85
ValidYFunction · 0.85
PointToLineStringFunction · 0.85
IsValidMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45
findMethod · 0.45
endMethod · 0.45
reserveMethod · 0.45
push_backMethod · 0.45
swapMethod · 0.45

Tested by

no test coverage detected