本文整理汇总了C++中DateTime::Abs方法的典型用法代码示例。如果您正苦于以下问题:C++ DateTime::Abs方法的具体用法?C++ DateTime::Abs怎么用?C++ DateTime::Abs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DateTime
的用法示例。
在下文中一共展示了DateTime::Abs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessCurve
void MPointCreator::ProcessCurve(const SimpleLine& rCurve,
const Interval<Instant> TimeInterval,
double dCurveLength)
{
double dLength = dCurveLength < 0.0 ?
MMUtil::CalcLengthCurve(&rCurve, m_dNetworkScale) :
dCurveLength;
if (AlmostEqual(dLength, 0.0))
{
AttributePtr<UPoint> pUPoint(new UPoint(TimeInterval,
rCurve.StartPoint(),
rCurve.EndPoint()));
m_pResMPoint->Add(*pUPoint);
return;
}
DateTime Duration = TimeInterval.end - TimeInterval.start;
Duration.Abs();
const bool bStartsSmaller = rCurve.GetStartSmaller();
Instant TimeStart(TimeInterval.start);
const int nHalfSegments = rCurve.Size();
if (nHalfSegments <= 0)
return;
assert(nHalfSegments % 2 == 0);
LRS lrs(bStartsSmaller ? 0.0 : rCurve.Length(), 0);
int lrsPosAkt = 0;
if (!const_cast<SimpleLine&>(rCurve).Get(lrs, lrsPosAkt))
{
assert(false);
return;
}
LRS lrsAkt;
rCurve.Get(lrsPosAkt, lrsAkt);
HalfSegment hs;
rCurve.Get(lrsAkt.hsPos, hs);
double dLengthHS = MMUtil::CalcDistance(hs.GetLeftPoint(),
hs.GetRightPoint(),
m_dNetworkScale);
DateTime TimeEnd = TimeStart +
DateTime(datetime::durationtype,
(uint64_t)(((Duration.millisecondsToNull()
/ dLength) * dLengthHS) + .5));
Interval<Instant> TimeIntervalAkt(TimeStart, TimeEnd,
true, TimeStart == TimeEnd);
Point Pt1(false);
Point Pt2(false);
if (const_cast<SimpleLine&>(rCurve).StartsSmaller())
{
Pt1 = hs.GetDomPoint();
Pt2 = hs.GetSecPoint();
}
else
{
Pt1 = hs.GetSecPoint();
Pt2 = hs.GetDomPoint();
}
AttributePtr<UPoint> pUPoint(new UPoint(TimeIntervalAkt, Pt1, Pt2));
m_pResMPoint->Add(*pUPoint);
TimeStart = TimeEnd;
if (bStartsSmaller)
++lrsPosAkt;
else
--lrsPosAkt;
while (lrsPosAkt >= 0 && lrsPosAkt < nHalfSegments / 2)
{
rCurve.Get(lrsPosAkt, lrsAkt);
rCurve.Get(lrsAkt.hsPos, hs);
double dLengthHS = MMUtil::CalcDistance(hs.GetLeftPoint(),
hs.GetRightPoint(),
m_dNetworkScale);
DateTime TimeEnd = TimeStart +
DateTime(datetime::durationtype,
(uint64_t)(((Duration.millisecondsToNull()
/ dLength) * dLengthHS) + .5));
Interval<Instant> TimeIntervalAkt(TimeStart, TimeEnd,
true, TimeStart == TimeEnd);
if (AlmostEqual(Pt2, hs.GetDomPoint()))
{
Pt1 = hs.GetDomPoint();
Pt2 = hs.GetSecPoint();
}
else
//.........这里部分代码省略.........
示例2: ProcessPoints
//.........这里部分代码省略.........
m_dNetworkScale,
*pSubline1);
double dLenCurve1 = MMUtil::CalcLengthCurve(pSubline1.get(),
m_dNetworkScale);
const SimpleLine* pSection2Curve = pSection2->GetCurve();
AttributePtr<SimpleLine> pSubline2(new SimpleLine(0));
MMUtil::SubLine(pSection2Curve,
pSection2->GetStartPoint(),
Pt2,
pSection2->GetCurveStartsSmaller(),
m_dNetworkScale,
*pSubline2);
double dLenCurve2 = MMUtil::CalcLengthCurve(pSubline2.get(),
m_dNetworkScale);
double dLength = dLenCurve1 + dLenCurve2;
const size_t nCurves = vecCurvesBetweenPoints.size();
for (size_t i = 0; i < nCurves; ++i)
{
dLength += MMUtil::CalcLengthCurve(vecCurvesBetweenPoints[i],
m_dNetworkScale);
}
// Total time
DateTime Duration = rData2.GetTime() - rData1.GetTime();
Duration.Abs();
// Process first curve
DateTime TimeEnd(rData1.GetTime());
if (!pSubline1 ||
AlmostEqual(dLenCurve1, 0.0))
{
Interval<Instant> TimeInterval(rData1.GetTime(),
TimeEnd,
true, true);
AttributePtr<UPoint> pUPoint(new UPoint(TimeInterval,
Pt1, Pt1));
m_pResMPoint->Add(*pUPoint);
}
else
{
TimeEnd = rData1.GetTime() +
DateTime(datetime::durationtype,
(uint64_t)(((Duration.millisecondsToNull()
/ dLength) * dLenCurve1) + .5));
Interval<Instant> TimeInterval(rData1.GetTime(),
TimeEnd,
true,
rData1.GetTime() == TimeEnd);
ProcessCurve(*pSubline1, TimeInterval, dLenCurve1);
}
// Process curves in between
for (size_t i = 0; i < nCurves; ++i)
{