mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-06 04:24:29 +00:00
Format all C++ and Java code via clang-format
Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
@@ -26,11 +26,10 @@ namespace track_analyzing
|
||||
{
|
||||
using namespace std;
|
||||
|
||||
void FillTable(basic_istream<char> & tableCsvStream, MwmToDataPoints & matchedDataPoints,
|
||||
vector<TableRow> & table)
|
||||
void FillTable(basic_istream<char> & tableCsvStream, MwmToDataPoints & matchedDataPoints, vector<TableRow> & table)
|
||||
{
|
||||
for (auto const & row : coding::CSVRunner(
|
||||
coding::CSVReader(tableCsvStream, true /* hasHeader */, ',' /* delimiter */)))
|
||||
for (auto const & row :
|
||||
coding::CSVRunner(coding::CSVReader(tableCsvStream, true /* hasHeader */, ',' /* delimiter */)))
|
||||
{
|
||||
CHECK_EQUAL(row.size(), kTableColumns, (row));
|
||||
auto const & mwmName = row[kMwmNameCsvColumn];
|
||||
@@ -39,13 +38,12 @@ void FillTable(basic_istream<char> & tableCsvStream, MwmToDataPoints & matchedDa
|
||||
}
|
||||
}
|
||||
|
||||
void RemoveKeysSmallValue(MwmToDataPoints & checkedMap, MwmToDataPoints & additionalMap,
|
||||
uint64_t ignoreDataPointNumber)
|
||||
void RemoveKeysSmallValue(MwmToDataPoints & checkedMap, MwmToDataPoints & additionalMap, uint64_t ignoreDataPointNumber)
|
||||
{
|
||||
CHECK(AreKeysEqual(additionalMap, checkedMap),
|
||||
("Mwms in |checkedMap| and in |additionalMap| should have the same set of keys."));
|
||||
|
||||
for (auto it = checkedMap.begin() ; it != checkedMap.end();)
|
||||
for (auto it = checkedMap.begin(); it != checkedMap.end();)
|
||||
{
|
||||
auto const dataPointNumberAfterMatching = it->second;
|
||||
if (dataPointNumberAfterMatching > ignoreDataPointNumber)
|
||||
@@ -72,14 +70,13 @@ MwmToDataPointFraction GetMwmToDataPointFraction(MwmToDataPoints const & numberM
|
||||
return fractionMapping;
|
||||
}
|
||||
|
||||
MwmToDataPoints CalcsMatchedDataPointsToKeepDistribution(
|
||||
MwmToDataPoints const & matchedDataPoints, MwmToDataPointFraction const & distributionFractions)
|
||||
MwmToDataPoints CalcsMatchedDataPointsToKeepDistribution(MwmToDataPoints const & matchedDataPoints,
|
||||
MwmToDataPointFraction const & distributionFractions)
|
||||
{
|
||||
CHECK(!matchedDataPoints.empty(), ());
|
||||
CHECK(AreKeysEqual(matchedDataPoints, distributionFractions),
|
||||
("Mwms in |matchedDataPoints| and in |distributionFractions| should have the same set of keys."));
|
||||
CHECK(AlmostEqualAbs(ValueSum(distributionFractions), 1.0, kSumFractionEps),
|
||||
(ValueSum(distributionFractions)));
|
||||
CHECK(AlmostEqualAbs(ValueSum(distributionFractions), 1.0, kSumFractionEps), (ValueSum(distributionFractions)));
|
||||
|
||||
auto const matchedFractions = GetMwmToDataPointFraction(matchedDataPoints);
|
||||
|
||||
@@ -137,17 +134,14 @@ MwmToDataPoints CalcsMatchedDataPointsToKeepDistribution(
|
||||
|
||||
if (matchedDataPointsToKeepDistributionForMwm == 0)
|
||||
{
|
||||
LOG(LWARNING, ("Zero points should be put to", mwm,
|
||||
"to keep the distribution. Distribution fraction:", fraction,
|
||||
"totalMatchedPointNumberToKeepDistribution:",
|
||||
totalMatchedPointNumberToKeepDistribution));
|
||||
LOG(LWARNING, ("Zero points should be put to", mwm, "to keep the distribution. Distribution fraction:", fraction,
|
||||
"totalMatchedPointNumberToKeepDistribution:", totalMatchedPointNumberToKeepDistribution));
|
||||
}
|
||||
}
|
||||
return matchedDataPointsToKeepDistribution;
|
||||
}
|
||||
|
||||
MwmToDataPoints BalancedDataPointNumber(MwmToDataPoints && matchedDataPoints,
|
||||
MwmToDataPoints && distribution,
|
||||
MwmToDataPoints BalancedDataPointNumber(MwmToDataPoints && matchedDataPoints, MwmToDataPoints && distribution,
|
||||
uint64_t ignoreDataPointsNumber)
|
||||
{
|
||||
// Removing every mwm from |distribution| and |matchedDataPoints| if it has
|
||||
@@ -188,7 +182,7 @@ void FilterTable(MwmToDataPoints const & balancedDataPointNumbers, vector<TableR
|
||||
auto it = balancedDataPointNumbers.find(mwmName);
|
||||
if (it == balancedDataPointNumbers.end())
|
||||
{
|
||||
mwmRecordsIndices.resize(0); // No indices.
|
||||
mwmRecordsIndices.resize(0); // No indices.
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -201,16 +195,13 @@ void FilterTable(MwmToDataPoints const & balancedDataPointNumbers, vector<TableR
|
||||
// Refilling |table| with part of its items to corresponds |balancedDataPointNumbers| distribution.
|
||||
vector<TableRow> balancedTable;
|
||||
for (auto const & kv : tableIdx)
|
||||
{
|
||||
for (auto const idx : kv.second)
|
||||
balancedTable.emplace_back(std::move(table[idx]));
|
||||
}
|
||||
table = std::move(balancedTable);
|
||||
}
|
||||
|
||||
void BalanceDataPoints(basic_istream<char> & tableCsvStream,
|
||||
basic_istream<char> & distributionCsvStream, uint64_t ignoreDataPointsNumber,
|
||||
vector<TableRow> & balancedTable)
|
||||
void BalanceDataPoints(basic_istream<char> & tableCsvStream, basic_istream<char> & distributionCsvStream,
|
||||
uint64_t ignoreDataPointsNumber, vector<TableRow> & balancedTable)
|
||||
{
|
||||
LOG(LINFO, ("Balancing data points..."));
|
||||
// Filling a map mwm to DataPoints number according to distribution csv file.
|
||||
@@ -232,15 +223,14 @@ void BalanceDataPoints(basic_istream<char> & tableCsvStream,
|
||||
|
||||
// Removing every mwm from |distribution| if there is no such mwm in |matchedDataPoints|.
|
||||
for (auto it = distribution.begin(); it != distribution.end();)
|
||||
{
|
||||
if (matchedDataPoints.count(it->first) == 0)
|
||||
it = distribution.erase(it);
|
||||
else
|
||||
++it;
|
||||
}
|
||||
|
||||
CHECK(AreKeysEqual(distribution, matchedDataPoints),
|
||||
("Mwms in |distribution| and in |matchedDataPoints| should have the same set of keys.", distribution, matchedDataPoints));
|
||||
("Mwms in |distribution| and in |matchedDataPoints| should have the same set of keys.", distribution,
|
||||
matchedDataPoints));
|
||||
|
||||
// Calculating how many points should have every mwm to keep the |distribution|.
|
||||
MwmToDataPoints const balancedDataPointNumber =
|
||||
@@ -252,18 +242,15 @@ void BalanceDataPoints(basic_istream<char> & tableCsvStream,
|
||||
// Removing some items form |tableCsvStream| (if it's necessary) to correspond to
|
||||
// the distribution.
|
||||
FilterTable(balancedDataPointNumber, balancedTable);
|
||||
LOG(LINFO, ("Data points have balanced. Total distribution data points number:",
|
||||
totalDistributionDataPointsNumber,
|
||||
LOG(LINFO, ("Data points have balanced. Total distribution data points number:", totalDistributionDataPointsNumber,
|
||||
"Total matched data points number:", totalMatchedDataPointsNumber,
|
||||
"Total balanced data points number:", totalBalancedDataPointsNumber));
|
||||
}
|
||||
|
||||
void CmdBalanceCsv(string const & csvPath, string const & distributionPath,
|
||||
uint64_t ignoreDataPointsNumber)
|
||||
void CmdBalanceCsv(string const & csvPath, string const & distributionPath, uint64_t ignoreDataPointsNumber)
|
||||
{
|
||||
LOG(LINFO, ("Balancing csv file", csvPath, "with distribution set in", distributionPath,
|
||||
". If an mwm has", ignoreDataPointsNumber,
|
||||
"data points or less it will not be considered."));
|
||||
LOG(LINFO, ("Balancing csv file", csvPath, "with distribution set in", distributionPath, ". If an mwm has",
|
||||
ignoreDataPointsNumber, "data points or less it will not be considered."));
|
||||
ifstream table(csvPath);
|
||||
CHECK(table.is_open(), ("Cannot open", csvPath));
|
||||
ifstream distribution(distributionPath);
|
||||
|
||||
@@ -32,17 +32,17 @@ typename MapCont::mapped_type ValueSum(MapCont const & mapCont)
|
||||
}
|
||||
|
||||
/// \returns true if |map1| and |map2| have the same key and false otherwise.
|
||||
template<typename Map1, typename Map2>
|
||||
template <typename Map1, typename Map2>
|
||||
bool AreKeysEqual(Map1 const & map1, Map2 const & map2)
|
||||
{
|
||||
if (map1.size() != map2.size())
|
||||
{
|
||||
LOG(LINFO,
|
||||
("AreKeysEqual() returns false. map1.size():", map1.size(), "map2.size()", map2.size()));
|
||||
LOG(LINFO, ("AreKeysEqual() returns false. map1.size():", map1.size(), "map2.size()", map2.size()));
|
||||
return false;
|
||||
}
|
||||
|
||||
return std::equal(map1.begin(), map1.end(), map2.begin(), [](auto const & kv1, auto const & kv2) {
|
||||
return std::equal(map1.begin(), map1.end(), map2.begin(), [](auto const & kv1, auto const & kv2)
|
||||
{
|
||||
if (kv1.first == kv2.first)
|
||||
return true;
|
||||
|
||||
@@ -68,13 +68,11 @@ MwmToDataPointFraction GetMwmToDataPointFraction(MwmToDataPoints const & numberM
|
||||
/// * number of data points in the returned mapping is less than or equal to
|
||||
/// number of data points in |matchedDataPoints| for every mwm
|
||||
/// * distribution defined by |distributionFraction| is kept
|
||||
MwmToDataPoints CalcsMatchedDataPointsToKeepDistribution(
|
||||
MwmToDataPoints const & matchedDataPoints,
|
||||
MwmToDataPointFraction const & distributionFractions);
|
||||
MwmToDataPoints CalcsMatchedDataPointsToKeepDistribution(MwmToDataPoints const & matchedDataPoints,
|
||||
MwmToDataPointFraction const & distributionFractions);
|
||||
|
||||
/// \returns mapping with number of matched data points for every mwm to correspond to |distribution|.
|
||||
MwmToDataPoints BalancedDataPointNumber(MwmToDataPoints && matchedDataPoints,
|
||||
MwmToDataPoints && distribution,
|
||||
MwmToDataPoints BalancedDataPointNumber(MwmToDataPoints && matchedDataPoints, MwmToDataPoints && distribution,
|
||||
uint64_t ignoreDataPointsNumber);
|
||||
|
||||
/// \breif Leaves in |table| only number of items according to |balancedDataPointNumbers|.
|
||||
@@ -83,13 +81,11 @@ void FilterTable(MwmToDataPoints const & balancedDataPointNumbers, std::vector<T
|
||||
|
||||
/// \brief Fills |balancedTable| with TableRow(s) according to the distribution set in
|
||||
/// |distributionCsvStream|.
|
||||
void BalanceDataPoints(std::basic_istream<char> & tableCsvStream,
|
||||
std::basic_istream<char> & distributionCsvStream,
|
||||
void BalanceDataPoints(std::basic_istream<char> & tableCsvStream, std::basic_istream<char> & distributionCsvStream,
|
||||
uint64_t ignoreDataPointsNumber, std::vector<TableRow> & balancedTable);
|
||||
|
||||
/// \brief Removes some data point for every mwm from |csvPath| to correspond distribution
|
||||
/// set in |distributionPath|. If an mwm in |csvPath| contains data points less of equal to
|
||||
/// |ignoreDataPointsNumber| than the mwm will not be taken into acount while balancing.
|
||||
void CmdBalanceCsv(std::string const & csvPath, std::string const & distributionPath,
|
||||
uint64_t ignoreDataPointsNumber);
|
||||
void CmdBalanceCsv(std::string const & csvPath, std::string const & distributionPath, uint64_t ignoreDataPointsNumber);
|
||||
} // namespace track_analyzing
|
||||
|
||||
@@ -9,24 +9,19 @@ using namespace std;
|
||||
|
||||
namespace track_analyzing
|
||||
{
|
||||
void CmdCppTrack(string const & trackFile, string const & mwmName, string const & user,
|
||||
size_t trackIdx)
|
||||
void CmdCppTrack(string const & trackFile, string const & mwmName, string const & user, size_t trackIdx)
|
||||
{
|
||||
storage::Storage storage;
|
||||
auto const numMwmIds = CreateNumMwmIds(storage);
|
||||
MwmToMatchedTracks mwmToMatchedTracks;
|
||||
ReadTracks(numMwmIds, trackFile, mwmToMatchedTracks);
|
||||
|
||||
MatchedTrack const & track =
|
||||
GetMatchedTrack(mwmToMatchedTracks, *numMwmIds, mwmName, user, trackIdx);
|
||||
MatchedTrack const & track = GetMatchedTrack(mwmToMatchedTracks, *numMwmIds, mwmName, user, trackIdx);
|
||||
|
||||
auto const backupPrecision = cout.precision();
|
||||
cout.precision(8);
|
||||
for (MatchedTrackPoint const & point : track)
|
||||
{
|
||||
cout << " {" << point.GetDataPoint().m_latLon.m_lat << ", " << point.GetDataPoint().m_latLon.m_lon
|
||||
<< "}," << endl;
|
||||
}
|
||||
cout << " {" << point.GetDataPoint().m_latLon.m_lat << ", " << point.GetDataPoint().m_latLon.m_lon << "}," << endl;
|
||||
cout.precision(backupPrecision);
|
||||
}
|
||||
} // namespace track_analyzing
|
||||
|
||||
@@ -48,10 +48,7 @@ void CmdGPX(string const & logFile, string const & outputDirName, string const &
|
||||
ofs << "</metadata>\n";
|
||||
for (auto const & point : track.second)
|
||||
{
|
||||
ofs << "<wpt lat=\""
|
||||
<< point.m_latLon.m_lat
|
||||
<< "\" lon=\""
|
||||
<< point.m_latLon.m_lon << "\">"
|
||||
ofs << "<wpt lat=\"" << point.m_latLon.m_lat << "\" lon=\"" << point.m_latLon.m_lon << "\">"
|
||||
<< "</wpt>\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -37,8 +37,8 @@ namespace
|
||||
{
|
||||
using Iter = typename vector<string>::iterator;
|
||||
|
||||
void MatchTracks(MwmToTracks const & mwmToTracks, storage::Storage const & storage,
|
||||
NumMwmIds const & numMwmIds, MwmToMatchedTracks & mwmToMatchedTracks)
|
||||
void MatchTracks(MwmToTracks const & mwmToTracks, storage::Storage const & storage, NumMwmIds const & numMwmIds,
|
||||
MwmToMatchedTracks & mwmToMatchedTracks)
|
||||
{
|
||||
base::Timer timer;
|
||||
|
||||
@@ -46,7 +46,8 @@ void MatchTracks(MwmToTracks const & mwmToTracks, storage::Storage const & stora
|
||||
uint64_t pointsCount = 0;
|
||||
uint64_t nonMatchedPointsCount = 0;
|
||||
|
||||
auto processMwm = [&](string const & mwmName, UserToTrack const & userToTrack) {
|
||||
auto processMwm = [&](string const & mwmName, UserToTrack const & userToTrack)
|
||||
{
|
||||
auto const countryFile = platform::CountryFile(mwmName);
|
||||
auto const mwmId = numMwmIds.GetId(countryFile);
|
||||
TrackMatcher matcher(storage, mwmId, countryFile);
|
||||
@@ -78,23 +79,22 @@ void MatchTracks(MwmToTracks const & mwmToTracks, storage::Storage const & stora
|
||||
pointsCount += matcher.GetPointsCount();
|
||||
nonMatchedPointsCount += matcher.GetNonMatchedPointsCount();
|
||||
|
||||
LOG(LINFO, (numMwmIds.GetFile(mwmId).GetName(), ", users:", userToTrack.size(), ", tracks:",
|
||||
matcher.GetTracksCount(), ", points:", matcher.GetPointsCount(),
|
||||
", non matched points:", matcher.GetNonMatchedPointsCount()));
|
||||
LOG(LINFO,
|
||||
(numMwmIds.GetFile(mwmId).GetName(), ", users:", userToTrack.size(), ", tracks:", matcher.GetTracksCount(),
|
||||
", points:", matcher.GetPointsCount(), ", non matched points:", matcher.GetNonMatchedPointsCount()));
|
||||
};
|
||||
|
||||
ForTracksSortedByMwmName(mwmToTracks, numMwmIds, processMwm);
|
||||
|
||||
LOG(LINFO,
|
||||
("Matching finished, elapsed:", timer.ElapsedSeconds(), "seconds, tracks:", tracksCount,
|
||||
", points:", pointsCount, ", non matched points:", nonMatchedPointsCount));
|
||||
LOG(LINFO, ("Matching finished, elapsed:", timer.ElapsedSeconds(), "seconds, tracks:", tracksCount,
|
||||
", points:", pointsCount, ", non matched points:", nonMatchedPointsCount));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace track_analyzing
|
||||
{
|
||||
void CmdMatch(string const & logFile, string const & trackFile,
|
||||
shared_ptr<NumMwmIds> const & numMwmIds, Storage const & storage, Stats & stats)
|
||||
void CmdMatch(string const & logFile, string const & trackFile, shared_ptr<NumMwmIds> const & numMwmIds,
|
||||
Storage const & storage, Stats & stats)
|
||||
{
|
||||
MwmToTracks mwmToTracks;
|
||||
ParseTracks(logFile, numMwmIds, mwmToTracks);
|
||||
@@ -165,8 +165,7 @@ void UnzipAndMatch(Iter begin, Iter end, string const & trackExt, Stats & stats)
|
||||
|
||||
void CmdMatchDir(string const & logDir, string const & trackExt, string const & inputDistribution)
|
||||
{
|
||||
LOG(LINFO,
|
||||
("Matching dir:", logDir, ". Input distribution will be saved to:", inputDistribution));
|
||||
LOG(LINFO, ("Matching dir:", logDir, ". Input distribution will be saved to:", inputDistribution));
|
||||
Platform::EFileType fileType = Platform::EFileType::Unknown;
|
||||
Platform::EError const result = Platform::GetFileType(logDir, fileType);
|
||||
|
||||
|
||||
@@ -69,11 +69,9 @@ bool DayTimeToBool(DayTimeType type)
|
||||
switch (type)
|
||||
{
|
||||
case DayTimeType::Day:
|
||||
case DayTimeType::PolarDay:
|
||||
return true;
|
||||
case DayTimeType::PolarDay: return true;
|
||||
case DayTimeType::Night:
|
||||
case DayTimeType::PolarNight:
|
||||
return false;
|
||||
case DayTimeType::PolarNight: return false;
|
||||
}
|
||||
|
||||
UNREACHABLE();
|
||||
@@ -100,15 +98,9 @@ public:
|
||||
return tie(m_hwType, m_surfaceType) < tie(rhs.m_hwType, rhs.m_surfaceType);
|
||||
}
|
||||
|
||||
bool operator==(Type const & rhs) const
|
||||
{
|
||||
return tie(m_hwType, m_surfaceType) == tie(rhs.m_hwType, m_surfaceType);
|
||||
}
|
||||
bool operator==(Type const & rhs) const { return tie(m_hwType, m_surfaceType) == tie(rhs.m_hwType, m_surfaceType); }
|
||||
|
||||
bool operator!=(Type const & rhs) const
|
||||
{
|
||||
return !(*this == rhs);
|
||||
}
|
||||
bool operator!=(Type const & rhs) const { return !(*this == rhs); }
|
||||
|
||||
string GetSummary() const
|
||||
{
|
||||
@@ -158,10 +150,7 @@ struct RoadInfo
|
||||
tie(rhs.m_type, rhs.m_maxspeedKMpH, rhs.m_isCityRoad, rhs.m_isOneWay);
|
||||
}
|
||||
|
||||
bool operator!=(RoadInfo const & rhs) const
|
||||
{
|
||||
return !(*this == rhs);
|
||||
}
|
||||
bool operator!=(RoadInfo const & rhs) const { return !(*this == rhs); }
|
||||
|
||||
bool operator<(RoadInfo const & rhs) const
|
||||
{
|
||||
@@ -172,11 +161,8 @@ struct RoadInfo
|
||||
string GetSummary() const
|
||||
{
|
||||
ostringstream out;
|
||||
out << TypeToString(m_type.m_hwType) << ","
|
||||
<< TypeToString(m_type.m_surfaceType) << ","
|
||||
<< m_maxspeedKMpH << ","
|
||||
<< m_isCityRoad << ","
|
||||
<< m_isOneWay;
|
||||
out << TypeToString(m_type.m_hwType) << "," << TypeToString(m_type.m_surfaceType) << "," << m_maxspeedKMpH << ","
|
||||
<< m_isCityRoad << "," << m_isOneWay;
|
||||
|
||||
return out.str();
|
||||
}
|
||||
@@ -193,7 +179,9 @@ public:
|
||||
MoveType() = default;
|
||||
|
||||
MoveType(RoadInfo const & roadType, traffic::SpeedGroup speedGroup, DataPoint const & dataPoint)
|
||||
: m_roadInfo(roadType), m_speedGroup(speedGroup), m_latLon(dataPoint.m_latLon)
|
||||
: m_roadInfo(roadType)
|
||||
, m_speedGroup(speedGroup)
|
||||
, m_latLon(dataPoint.m_latLon)
|
||||
{
|
||||
m_isDayTime = DayTimeToBool(GetDayTime(dataPoint.m_timestamp, m_latLon.m_lat, m_latLon.m_lon));
|
||||
}
|
||||
@@ -213,17 +201,14 @@ public:
|
||||
bool IsValid() const
|
||||
{
|
||||
// In order to collect cleaner data we don't use speed group lower than G5.
|
||||
return m_roadInfo.m_type.m_hwType != 0 &&
|
||||
m_roadInfo.m_type.m_surfaceType != 0 &&
|
||||
return m_roadInfo.m_type.m_hwType != 0 && m_roadInfo.m_type.m_surfaceType != 0 &&
|
||||
m_speedGroup == kValidTrafficValue;
|
||||
}
|
||||
|
||||
string GetSummary() const
|
||||
{
|
||||
ostringstream out;
|
||||
out << m_roadInfo.GetSummary() << ","
|
||||
<< m_isDayTime << ","
|
||||
<< m_latLon.m_lat << " " << m_latLon.m_lon;
|
||||
out << m_roadInfo.GetSummary() << "," << m_isDayTime << "," << m_latLon.m_lat << " " << m_latLon.m_lon;
|
||||
|
||||
return out.str();
|
||||
}
|
||||
@@ -250,9 +235,7 @@ public:
|
||||
string GetSummary() const
|
||||
{
|
||||
ostringstream out;
|
||||
out << m_totalDistance << ","
|
||||
<< m_totalTime << ","
|
||||
<< CalcSpeedKMpH(m_totalDistance, m_totalTime) << ",";
|
||||
out << m_totalDistance << "," << m_totalTime << "," << CalcSpeedKMpH(m_totalDistance, m_totalTime) << ",";
|
||||
|
||||
for (size_t i = 0; i < m_crossroads.size(); ++i)
|
||||
{
|
||||
@@ -276,8 +259,8 @@ private:
|
||||
class MoveTypeAggregator final
|
||||
{
|
||||
public:
|
||||
void Add(MoveType && moveType, IsCrossroadChecker::CrossroadInfo const & crossroads, MatchedTrack::const_iterator begin,
|
||||
MatchedTrack::const_iterator end, Geometry & geometry)
|
||||
void Add(MoveType && moveType, IsCrossroadChecker::CrossroadInfo const & crossroads,
|
||||
MatchedTrack::const_iterator begin, MatchedTrack::const_iterator end, Geometry & geometry)
|
||||
{
|
||||
if (begin + 1 >= end)
|
||||
return;
|
||||
@@ -288,9 +271,9 @@ public:
|
||||
|
||||
if (time == 0)
|
||||
{
|
||||
LOG(LWARNING, ("Track with the same time at the beginning and at the end. Beginning:",
|
||||
beginDataPoint.m_latLon, " End:", endDataPoint.m_latLon,
|
||||
" Timestamp:", beginDataPoint.m_timestamp, " Segment:", begin->GetSegment()));
|
||||
LOG(LWARNING, ("Track with the same time at the beginning and at the end. Beginning:", beginDataPoint.m_latLon,
|
||||
" End:", endDataPoint.m_latLon, " Timestamp:", beginDataPoint.m_timestamp,
|
||||
" Segment:", begin->GetSegment()));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -298,8 +281,7 @@ public:
|
||||
m_moveInfos[moveType].Add(length, time, crossroads, static_cast<uint32_t>(distance(begin, end)));
|
||||
}
|
||||
|
||||
string GetSummary(string const & user, string const & mwmName, string const & countryName,
|
||||
Stats & stats) const
|
||||
string GetSummary(string const & user, string const & mwmName, string const & countryName, Stats & stats) const
|
||||
{
|
||||
ostringstream out;
|
||||
for (auto const & it : m_moveInfos)
|
||||
@@ -307,8 +289,7 @@ public:
|
||||
if (!it.first.IsValid())
|
||||
continue;
|
||||
|
||||
out << user << "," << mwmName << "," << it.first.GetSummary() << ","
|
||||
<< it.second.GetSummary() << '\n';
|
||||
out << user << "," << mwmName << "," << it.first.GetSummary() << "," << it.second.GetSummary() << '\n';
|
||||
|
||||
stats.AddDataPoints(mwmName, countryName, it.second.GetDataPointsNumber());
|
||||
}
|
||||
@@ -324,7 +305,8 @@ class MatchedTrackPointToMoveType final
|
||||
{
|
||||
public:
|
||||
MatchedTrackPointToMoveType(FilesContainerR const & container, VehicleModelInterface & vehicleModel)
|
||||
: m_featuresVector(container), m_vehicleModel(vehicleModel)
|
||||
: m_featuresVector(container)
|
||||
, m_vehicleModel(vehicleModel)
|
||||
{
|
||||
if (container.IsExist(CITY_ROADS_FILE_TAG))
|
||||
m_cityRoads.Load(container.GetReader(CITY_ROADS_FILE_TAG));
|
||||
@@ -336,9 +318,7 @@ public:
|
||||
MoveType GetMoveType(MatchedTrackPoint const & point)
|
||||
{
|
||||
auto const & dataPoint = point.GetDataPoint();
|
||||
return MoveType(GetRoadInfo(point.GetSegment()),
|
||||
static_cast<traffic::SpeedGroup>(dataPoint.m_traffic),
|
||||
dataPoint);
|
||||
return MoveType(GetRoadInfo(point.GetSegment()), static_cast<traffic::SpeedGroup>(dataPoint.m_traffic), dataPoint);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -352,15 +332,14 @@ private:
|
||||
CHECK(feature, ());
|
||||
|
||||
auto const maxspeed = m_maxspeeds.GetMaxspeed(featureId);
|
||||
auto const maxspeedValueKMpH = maxspeed.IsValid() ?
|
||||
min(maxspeed.GetSpeedKmPH(segment.IsForward()), kMaxspeedTopBound) :
|
||||
kInvalidSpeed;
|
||||
auto const maxspeedValueKMpH =
|
||||
maxspeed.IsValid() ? min(maxspeed.GetSpeedKmPH(segment.IsForward()), kMaxspeedTopBound) : kInvalidSpeed;
|
||||
|
||||
m_prevFeatureId = featureId;
|
||||
|
||||
feature::TypesHolder const types(*feature);
|
||||
m_prevRoadInfo = {m_carModelTypes.GetType(types), maxspeedValueKMpH,
|
||||
m_cityRoads.IsCityRoad(featureId), m_vehicleModel.IsOneWay(types)};
|
||||
m_prevRoadInfo = {m_carModelTypes.GetType(types), maxspeedValueKMpH, m_cityRoads.IsCityRoad(featureId),
|
||||
m_vehicleModel.IsOneWay(types)};
|
||||
return m_prevRoadInfo;
|
||||
}
|
||||
|
||||
@@ -374,7 +353,6 @@ private:
|
||||
};
|
||||
} // namespace
|
||||
|
||||
|
||||
void CmdTagsTable(string const & filepath, string const & trackExtension, StringFilter mwmFilter,
|
||||
StringFilter userFilter)
|
||||
{
|
||||
@@ -393,18 +371,17 @@ void CmdTagsTable(string const & filepath, string const & trackExtension, String
|
||||
|
||||
auto const countryName = storage.GetTopmostParentFor(mwmName);
|
||||
auto const carModelFactory = make_shared<CarModelFactory>(VehicleModelFactory::CountryParentNameGetterFn{});
|
||||
shared_ptr<VehicleModelInterface> vehicleModel =
|
||||
carModelFactory->GetVehicleModelForCountry(mwmName);
|
||||
shared_ptr<VehicleModelInterface> vehicleModel = carModelFactory->GetVehicleModelForCountry(mwmName);
|
||||
string const mwmFile = GetCurrentVersionMwmFile(storage, mwmName);
|
||||
MatchedTrackPointToMoveType pointToMoveType(FilesContainerR(make_unique<FileReader>(mwmFile)), *vehicleModel);
|
||||
Geometry geometry(GeometryLoader::CreateFromFile(mwmFile, vehicleModel));
|
||||
auto const vehicleType = VehicleType::Car;
|
||||
auto const edgeEstimator = EdgeEstimator::Create(vehicleType, *vehicleModel,
|
||||
nullptr /* trafficStash */, &dataSource, numMwmIds);
|
||||
auto const edgeEstimator =
|
||||
EdgeEstimator::Create(vehicleType, *vehicleModel, nullptr /* trafficStash */, &dataSource, numMwmIds);
|
||||
|
||||
MwmDataSource routingSource(dataSource, numMwmIds);
|
||||
auto indexGraphLoader = IndexGraphLoader::Create(vehicleType, false /* loadAltitudes */,
|
||||
carModelFactory, edgeEstimator, routingSource);
|
||||
auto indexGraphLoader =
|
||||
IndexGraphLoader::Create(vehicleType, false /* loadAltitudes */, carModelFactory, edgeEstimator, routingSource);
|
||||
|
||||
platform::CountryFile const countryFile(mwmName);
|
||||
auto localCountryFile = storage.GetLatestLocalFile(countryFile);
|
||||
@@ -412,8 +389,7 @@ void CmdTagsTable(string const & filepath, string const & trackExtension, String
|
||||
if (!dataSource.IsLoaded(countryFile))
|
||||
{
|
||||
auto registerResult = dataSource.Register(*localCountryFile);
|
||||
CHECK_EQUAL(registerResult.second, MwmSet::RegResult::Success,
|
||||
("Can't register mwm", countryFile.GetName()));
|
||||
CHECK_EQUAL(registerResult.second, MwmSet::RegResult::Success, ("Can't register mwm", countryFile.GetName()));
|
||||
}
|
||||
|
||||
auto const mwmId = numMwmIds->GetId(countryFile);
|
||||
@@ -440,18 +416,14 @@ void CmdTagsTable(string const & filepath, string const & trackExtension, String
|
||||
// Splitting track with points where MoveType is changed.
|
||||
while (end != track.end() && pointToMoveType.GetMoveType(*end) == moveType)
|
||||
{
|
||||
IsCrossroadChecker::MergeCrossroads(checker(prev->GetSegment(), end->GetSegment()),
|
||||
info);
|
||||
IsCrossroadChecker::MergeCrossroads(checker(prev->GetSegment(), end->GetSegment()), info);
|
||||
prev = end;
|
||||
++end;
|
||||
}
|
||||
|
||||
// If it's not the end of the track than it could be a crossroad.
|
||||
if (end != track.end())
|
||||
{
|
||||
IsCrossroadChecker::MergeCrossroads(checker(prev->GetSegment(), end->GetSegment()),
|
||||
info);
|
||||
}
|
||||
IsCrossroadChecker::MergeCrossroads(checker(prev->GetSegment(), end->GetSegment()), info);
|
||||
|
||||
aggregator.Add(std::move(moveType), info, subtrackBegin, end, geometry);
|
||||
subtrackBegin = end;
|
||||
|
||||
@@ -23,28 +23,24 @@ using namespace std;
|
||||
|
||||
namespace track_analyzing
|
||||
{
|
||||
void CmdTrack(string const & trackFile, string const & mwmName, string const & user,
|
||||
size_t trackIdx)
|
||||
void CmdTrack(string const & trackFile, string const & mwmName, string const & user, size_t trackIdx)
|
||||
{
|
||||
storage::Storage storage;
|
||||
auto const numMwmIds = CreateNumMwmIds(storage);
|
||||
MwmToMatchedTracks mwmToMatchedTracks;
|
||||
ReadTracks(numMwmIds, trackFile, mwmToMatchedTracks);
|
||||
|
||||
MatchedTrack const & track =
|
||||
GetMatchedTrack(mwmToMatchedTracks, *numMwmIds, mwmName, user, trackIdx);
|
||||
MatchedTrack const & track = GetMatchedTrack(mwmToMatchedTracks, *numMwmIds, mwmName, user, trackIdx);
|
||||
|
||||
string const mwmFile = GetCurrentVersionMwmFile(storage, mwmName);
|
||||
shared_ptr<VehicleModelInterface> vehicleModel =
|
||||
CarModelFactory({}).GetVehicleModelForCountry(mwmName);
|
||||
shared_ptr<VehicleModelInterface> vehicleModel = CarModelFactory({}).GetVehicleModelForCountry(mwmName);
|
||||
Geometry geometry(GeometryLoader::CreateFromFile(mwmFile, vehicleModel));
|
||||
|
||||
uint64_t const duration =
|
||||
track.back().GetDataPoint().m_timestamp - track.front().GetDataPoint().m_timestamp;
|
||||
uint64_t const duration = track.back().GetDataPoint().m_timestamp - track.front().GetDataPoint().m_timestamp;
|
||||
double const length = CalcTrackLength(track, geometry);
|
||||
double const averageSpeed = CalcSpeedKMpH(length, duration);
|
||||
LOG(LINFO, ("Mwm:", mwmName, ", user:", user, ", points:", track.size(), "duration:", duration,
|
||||
"length:", length, ", speed:", averageSpeed, "km/h"));
|
||||
LOG(LINFO, ("Mwm:", mwmName, ", user:", user, ", points:", track.size(), "duration:", duration, "length:", length,
|
||||
", speed:", averageSpeed, "km/h"));
|
||||
|
||||
for (size_t i = 0; i < track.size(); ++i)
|
||||
{
|
||||
@@ -64,10 +60,9 @@ void CmdTrack(string const & trackFile, string const & mwmName, string const & u
|
||||
if (elapsed != 0)
|
||||
speed = CalcSpeedKMpH(distance, elapsed);
|
||||
|
||||
LOG(LINFO, (base::SecondsSinceEpochToString(point.GetDataPoint().m_timestamp),
|
||||
point.GetDataPoint().m_latLon, point.GetSegment(), ", traffic:",
|
||||
point.GetDataPoint().m_traffic, ", distance:", distance, ", elapsed:", elapsed,
|
||||
", speed:", speed));
|
||||
LOG(LINFO, (base::SecondsSinceEpochToString(point.GetDataPoint().m_timestamp), point.GetDataPoint().m_latLon,
|
||||
point.GetSegment(), ", traffic:", point.GetDataPoint().m_traffic, ", distance:", distance,
|
||||
", elapsed:", elapsed, ", speed:", speed));
|
||||
}
|
||||
}
|
||||
} // namespace track_analyzing
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
|
||||
namespace track_analyzing
|
||||
{
|
||||
using namespace routing;
|
||||
@@ -105,8 +104,7 @@ bool TrackHasTrafficPoints(MatchedTrack const & track)
|
||||
return false;
|
||||
}
|
||||
|
||||
double EstimateDuration(MatchedTrack const & track, shared_ptr<EdgeEstimator> estimator,
|
||||
Geometry & geometry)
|
||||
double EstimateDuration(MatchedTrack const & track, shared_ptr<EdgeEstimator> estimator, Geometry & geometry)
|
||||
{
|
||||
double result = 0.0;
|
||||
Segment segment;
|
||||
@@ -117,16 +115,15 @@ double EstimateDuration(MatchedTrack const & track, shared_ptr<EdgeEstimator> es
|
||||
continue;
|
||||
|
||||
segment = point.GetSegment();
|
||||
result += estimator->CalcSegmentWeight(segment, geometry.GetRoad(segment.GetFeatureId()),
|
||||
EdgeEstimator::Purpose::ETA);
|
||||
result +=
|
||||
estimator->CalcSegmentWeight(segment, geometry.GetRoad(segment.GetFeatureId()), EdgeEstimator::Purpose::ETA);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void CmdTracks(string const & filepath, string const & trackExtension, StringFilter mwmFilter,
|
||||
StringFilter userFilter, TrackFilter const & filter, bool noTrackLogs,
|
||||
bool noMwmLogs, bool noWorldLogs)
|
||||
void CmdTracks(string const & filepath, string const & trackExtension, StringFilter mwmFilter, StringFilter userFilter,
|
||||
TrackFilter const & filter, bool noTrackLogs, bool noMwmLogs, bool noWorldLogs)
|
||||
{
|
||||
storage::Storage storage;
|
||||
auto numMwmIds = CreateNumMwmIds(storage);
|
||||
@@ -135,21 +132,19 @@ void CmdTracks(string const & filepath, string const & trackExtension, StringFil
|
||||
ErrorStat absoluteError;
|
||||
ErrorStat relativeError;
|
||||
|
||||
auto processMwm = [&](string const & mwmName, UserToMatchedTracks const & userToMatchedTracks) {
|
||||
auto processMwm = [&](string const & mwmName, UserToMatchedTracks const & userToMatchedTracks)
|
||||
{
|
||||
if (mwmFilter(mwmName))
|
||||
return;
|
||||
|
||||
TrackStats & mwmStats = mwmToStats[mwmName];
|
||||
|
||||
shared_ptr<VehicleModelInterface> vehicleModel =
|
||||
CarModelFactory({}).GetVehicleModelForCountry(mwmName);
|
||||
shared_ptr<VehicleModelInterface> vehicleModel = CarModelFactory({}).GetVehicleModelForCountry(mwmName);
|
||||
|
||||
Geometry geometry(
|
||||
GeometryLoader::CreateFromFile(GetCurrentVersionMwmFile(storage, mwmName), vehicleModel));
|
||||
Geometry geometry(GeometryLoader::CreateFromFile(GetCurrentVersionMwmFile(storage, mwmName), vehicleModel));
|
||||
|
||||
shared_ptr<EdgeEstimator> estimator =
|
||||
EdgeEstimator::Create(VehicleType::Car, *vehicleModel,
|
||||
nullptr /* trafficStash */, nullptr /* dataSource */, nullptr /* numMwmIds */);
|
||||
shared_ptr<EdgeEstimator> estimator = EdgeEstimator::Create(
|
||||
VehicleType::Car, *vehicleModel, nullptr /* trafficStash */, nullptr /* dataSource */, nullptr /* numMwmIds */);
|
||||
|
||||
for (auto const & it : userToMatchedTracks)
|
||||
{
|
||||
@@ -181,13 +176,13 @@ void CmdTracks(string const & filepath, string const & trackExtension, StringFil
|
||||
if (!noTrackLogs)
|
||||
{
|
||||
cout << fixed << setprecision(1) << " points: " << track.size() << ", length: " << length
|
||||
<< ", duration: " << duration << ", estimated duration: " << estimatedDuration
|
||||
<< ", speed: " << speed << ", traffic: " << hasTrafficPoints
|
||||
<< ", duration: " << duration << ", estimated duration: " << estimatedDuration << ", speed: " << speed
|
||||
<< ", traffic: " << hasTrafficPoints
|
||||
<< ", departure: " << base::SecondsSinceEpochToString(start.m_timestamp)
|
||||
<< ", arrival: " << base::SecondsSinceEpochToString(finish.m_timestamp)
|
||||
<< setprecision(numeric_limits<double>::max_digits10)
|
||||
<< ", start: " << start.m_latLon.m_lat << ", " << start.m_latLon.m_lon
|
||||
<< ", finish: " << finish.m_latLon.m_lat << ", " << finish.m_latLon.m_lon << endl;
|
||||
<< setprecision(numeric_limits<double>::max_digits10) << ", start: " << start.m_latLon.m_lat << ", "
|
||||
<< start.m_latLon.m_lon << ", finish: " << finish.m_latLon.m_lat << ", " << finish.m_latLon.m_lon
|
||||
<< endl;
|
||||
}
|
||||
|
||||
mwmStats.AddTracks(1);
|
||||
@@ -202,7 +197,8 @@ void CmdTracks(string const & filepath, string const & trackExtension, StringFil
|
||||
}
|
||||
};
|
||||
|
||||
auto processFile = [&](string const & filename, MwmToMatchedTracks const & mwmToMatchedTracks) {
|
||||
auto processFile = [&](string const & filename, MwmToMatchedTracks const & mwmToMatchedTracks)
|
||||
{
|
||||
LOG(LINFO, ("Processing", filename));
|
||||
ForTracksSortedByMwmName(mwmToMatchedTracks, *numMwmIds, processMwm);
|
||||
};
|
||||
@@ -213,10 +209,8 @@ void CmdTracks(string const & filepath, string const & trackExtension, StringFil
|
||||
{
|
||||
cout << endl;
|
||||
for (auto const & it : mwmToStats)
|
||||
{
|
||||
if (!it.second.IsEmpty())
|
||||
cout << it.first << ": " << it.second.GetSummary() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (!noWorldLogs)
|
||||
@@ -226,11 +220,9 @@ void CmdTracks(string const & filepath, string const & trackExtension, StringFil
|
||||
worldStats.Add(it.second);
|
||||
|
||||
cout << endl << "World: " << worldStats.GetSummary() << endl;
|
||||
cout << fixed << setprecision(1)
|
||||
<< "Absolute error: deviation: " << absoluteError.GetStdDevString()
|
||||
cout << fixed << setprecision(1) << "Absolute error: deviation: " << absoluteError.GetStdDevString()
|
||||
<< ", min: " << absoluteError.GetMin() << ", max: " << absoluteError.GetMax() << endl;
|
||||
cout << fixed << setprecision(3)
|
||||
<< "Relative error: deviation: " << relativeError.GetStdDevString()
|
||||
cout << fixed << setprecision(3) << "Relative error: deviation: " << relativeError.GetStdDevString()
|
||||
<< ", min: " << relativeError.GetMin() << ", max: " << relativeError.GetMax() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,10 +23,8 @@ bool IsHighwayLink(HighwayType type)
|
||||
case HighwayType::HighwayTrunkLink:
|
||||
case HighwayType::HighwayPrimaryLink:
|
||||
case HighwayType::HighwaySecondaryLink:
|
||||
case HighwayType::HighwayTertiaryLink:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
case HighwayType::HighwayTertiaryLink: return true;
|
||||
default: return false;
|
||||
}
|
||||
|
||||
UNREACHABLE();
|
||||
@@ -40,10 +38,8 @@ bool IsBigHighway(HighwayType type)
|
||||
case HighwayType::HighwayTrunk:
|
||||
case HighwayType::HighwayPrimary:
|
||||
case HighwayType::HighwaySecondary:
|
||||
case HighwayType::HighwayTertiary:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
case HighwayType::HighwayTertiary: return true;
|
||||
default: return false;
|
||||
}
|
||||
|
||||
UNREACHABLE();
|
||||
@@ -54,12 +50,8 @@ bool FromSmallerToBigger(HighwayType lhs, HighwayType rhs)
|
||||
CHECK_NOT_EQUAL(lhs, rhs, ());
|
||||
|
||||
static std::array<HighwayType, 5> constexpr kHighwayTypes = {
|
||||
HighwayType::HighwayTertiary,
|
||||
HighwayType::HighwaySecondary,
|
||||
HighwayType::HighwayPrimary,
|
||||
HighwayType::HighwayTrunk,
|
||||
HighwayType::HighwayMotorway
|
||||
};
|
||||
HighwayType::HighwayTertiary, HighwayType::HighwaySecondary, HighwayType::HighwayPrimary,
|
||||
HighwayType::HighwayTrunk, HighwayType::HighwayMotorway};
|
||||
|
||||
auto const lhsIt = find(kHighwayTypes.begin(), kHighwayTypes.end(), lhs);
|
||||
auto const rhsIt = find(kHighwayTypes.begin(), kHighwayTypes.end(), rhs);
|
||||
@@ -112,7 +104,8 @@ IsCrossroadChecker::Type IsCrossroadChecker::operator()(Segment const & current,
|
||||
|
||||
Type retType = Type::Count;
|
||||
auto const nextRoadPoint = next.GetRoadPoint(false /* isFront */);
|
||||
m_indexGraph.ForEachPoint(jointId, [&](RoadPoint const & point) {
|
||||
m_indexGraph.ForEachPoint(jointId, [&](RoadPoint const & point)
|
||||
{
|
||||
if (retType != IsCrossroadChecker::Type::Count)
|
||||
return;
|
||||
|
||||
@@ -129,11 +122,8 @@ IsCrossroadChecker::Type IsCrossroadChecker::operator()(Segment const & current,
|
||||
if (pointHwType == nextSegmentHwType)
|
||||
{
|
||||
// Is the same road but parted on different features.
|
||||
if (roadGeometry.IsEndPointId(point.GetPointId()) &&
|
||||
roadGeometry.IsEndPointId(nextRoadPoint.GetPointId()))
|
||||
{
|
||||
if (roadGeometry.IsEndPointId(point.GetPointId()) && roadGeometry.IsEndPointId(nextRoadPoint.GetPointId()))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (isCurrentLink && IsBigHighway(*pointHwType))
|
||||
|
||||
@@ -30,8 +30,7 @@ public:
|
||||
Type operator()(Segment const & current, Segment const & next) const;
|
||||
|
||||
static void MergeCrossroads(Type from, CrossroadInfo & to);
|
||||
static void MergeCrossroads(IsCrossroadChecker::CrossroadInfo const & from,
|
||||
IsCrossroadChecker::CrossroadInfo & to);
|
||||
static void MergeCrossroads(IsCrossroadChecker::CrossroadInfo const & from, IsCrossroadChecker::CrossroadInfo & to);
|
||||
|
||||
private:
|
||||
IndexGraph & m_indexGraph;
|
||||
|
||||
@@ -51,19 +51,17 @@ DEFINE_string_ext(output_dir, "", "output dir for gpx files");
|
||||
DEFINE_string_ext(mwm, "", "short mwm name");
|
||||
DEFINE_string_ext(user, "", "user id");
|
||||
DEFINE_int32(track, -1, "track index");
|
||||
DEFINE_string(
|
||||
input_distribution, "",
|
||||
"path to input data point distribution file. It's a csv file with data point count for "
|
||||
"some mwms. Usage:\n"
|
||||
"- It may be used with match and match_dir command. If so it's a path to save file with "
|
||||
"data point distribution by mwm. If it's empty no file is saved.\n"
|
||||
"- It may be used with balance_csv command. If so it's a path of a file with distribution which "
|
||||
"will be used for normalization (balancing) the result of the command. It should not be empty.");
|
||||
DEFINE_uint64(
|
||||
ignore_datapoints_number, 100,
|
||||
"The number of datapoints in an mwm to exclude the mwm from balancing process. If this number "
|
||||
"of datapoints or less number is in an mwm after matching and tabling, the mwm will not used "
|
||||
"for balancing. This param should be used with balance_csv command.");
|
||||
DEFINE_string(input_distribution, "",
|
||||
"path to input data point distribution file. It's a csv file with data point count for "
|
||||
"some mwms. Usage:\n"
|
||||
"- It may be used with match and match_dir command. If so it's a path to save file with "
|
||||
"data point distribution by mwm. If it's empty no file is saved.\n"
|
||||
"- It may be used with balance_csv command. If so it's a path of a file with distribution which "
|
||||
"will be used for normalization (balancing) the result of the command. It should not be empty.");
|
||||
DEFINE_uint64(ignore_datapoints_number, 100,
|
||||
"The number of datapoints in an mwm to exclude the mwm from balancing process. If this number "
|
||||
"of datapoints or less number is in an mwm after matching and tabling, the mwm will not used "
|
||||
"for balancing. This param should be used with balance_csv command.");
|
||||
|
||||
DEFINE_string(track_extension, ".track", "track files extension");
|
||||
DEFINE_bool(no_world_logs, false, "don't print world summary logs");
|
||||
@@ -86,7 +84,8 @@ size_t Checked_track()
|
||||
|
||||
StringFilter MakeFilter(string const & filter)
|
||||
{
|
||||
return [&](string const & value) {
|
||||
return [&](string const & value)
|
||||
{
|
||||
if (filter.empty())
|
||||
return false;
|
||||
return value != filter;
|
||||
@@ -97,8 +96,7 @@ StringFilter MakeFilter(string const & filter)
|
||||
namespace track_analyzing
|
||||
{
|
||||
// Print the specified track in C++ form that you can copy paste to C++ source for debugging.
|
||||
void CmdCppTrack(string const & trackFile, string const & mwmName, string const & user,
|
||||
size_t trackIdx);
|
||||
void CmdCppTrack(string const & trackFile, string const & mwmName, string const & user, size_t trackIdx);
|
||||
// Match raw gps logs to tracks.
|
||||
void CmdMatch(string const & logFile, string const & trackFile, string const & inputDistribution);
|
||||
// The same as match but applies for the directory with raw logs.
|
||||
@@ -106,15 +104,13 @@ void CmdMatchDir(string const & logDir, string const & trackExt, string const &
|
||||
// Parse |logFile| and save tracks (mwm name, aloha id, lats, lons, timestamps in seconds in csv).
|
||||
void CmdUnmatchedTracks(string const & logFile, string const & trackFileCsv);
|
||||
// Print aggregated tracks to csv table.
|
||||
void CmdTagsTable(string const & filepath, string const & trackExtension,
|
||||
StringFilter mwmIsFiltered, StringFilter userFilter);
|
||||
void CmdTagsTable(string const & filepath, string const & trackExtension, StringFilter mwmIsFiltered,
|
||||
StringFilter userFilter);
|
||||
// Print track information.
|
||||
void CmdTrack(string const & trackFile, string const & mwmName, string const & user,
|
||||
size_t trackIdx);
|
||||
void CmdTrack(string const & trackFile, string const & mwmName, string const & user, size_t trackIdx);
|
||||
// Print tracks statistics.
|
||||
void CmdTracks(string const & filepath, string const & trackExtension, StringFilter mwmFilter,
|
||||
StringFilter userFilter, TrackFilter const & filter, bool noTrackLogs,
|
||||
bool noMwmLogs, bool noWorldLogs);
|
||||
void CmdTracks(string const & filepath, string const & trackExtension, StringFilter mwmFilter, StringFilter userFilter,
|
||||
TrackFilter const & filter, bool noTrackLogs, bool noMwmLogs, bool noWorldLogs);
|
||||
|
||||
void CmdGPX(string const & logFile, string const & outputFilesDir, string const & userID);
|
||||
} // namespace track_analyzing
|
||||
@@ -145,10 +141,10 @@ int main(int argc, char ** argv)
|
||||
}
|
||||
else if (cmd == "tracks")
|
||||
{
|
||||
TrackFilter const filter(FLAGS_min_duration, FLAGS_min_length, FLAGS_min_speed,
|
||||
FLAGS_max_speed, FLAGS_ignore_traffic);
|
||||
CmdTracks(Checked_in(), FLAGS_track_extension, MakeFilter(FLAGS_mwm), MakeFilter(FLAGS_user),
|
||||
filter, FLAGS_no_track_logs, FLAGS_no_mwm_logs, FLAGS_no_world_logs);
|
||||
TrackFilter const filter(FLAGS_min_duration, FLAGS_min_length, FLAGS_min_speed, FLAGS_max_speed,
|
||||
FLAGS_ignore_traffic);
|
||||
CmdTracks(Checked_in(), FLAGS_track_extension, MakeFilter(FLAGS_mwm), MakeFilter(FLAGS_user), filter,
|
||||
FLAGS_no_track_logs, FLAGS_no_mwm_logs, FLAGS_no_world_logs);
|
||||
}
|
||||
else if (cmd == "track")
|
||||
{
|
||||
@@ -160,8 +156,7 @@ int main(int argc, char ** argv)
|
||||
}
|
||||
else if (cmd == "table")
|
||||
{
|
||||
CmdTagsTable(Checked_in(), FLAGS_track_extension, MakeFilter(FLAGS_mwm),
|
||||
MakeFilter(FLAGS_user));
|
||||
CmdTagsTable(Checked_in(), FLAGS_track_extension, MakeFilter(FLAGS_mwm), MakeFilter(FLAGS_user));
|
||||
}
|
||||
else if (cmd == "balance_csv")
|
||||
{
|
||||
@@ -171,8 +166,7 @@ int main(int argc, char ** argv)
|
||||
"distribution. Hint: this file may be saved by match or match_dir command."));
|
||||
return 1;
|
||||
}
|
||||
CmdBalanceCsv(FLAGS_in, FLAGS_input_distribution,
|
||||
base::checked_cast<uint64_t>(FLAGS_ignore_datapoints_number));
|
||||
CmdBalanceCsv(FLAGS_in, FLAGS_input_distribution, base::checked_cast<uint64_t>(FLAGS_ignore_datapoints_number));
|
||||
}
|
||||
else if (cmd == "gpx")
|
||||
{
|
||||
|
||||
@@ -31,8 +31,7 @@ namespace
|
||||
set<string> GetKeys(Stats::NameToCountMapping const & mapping)
|
||||
{
|
||||
set<string> keys;
|
||||
transform(mapping.begin(), mapping.end(), inserter(keys, keys.end()),
|
||||
[](auto const & kv) { return kv.first; });
|
||||
transform(mapping.begin(), mapping.end(), inserter(keys, keys.end()), [](auto const & kv) { return kv.first; });
|
||||
return keys;
|
||||
}
|
||||
|
||||
@@ -57,8 +56,8 @@ void Add(Stats::NameToCountMapping const & addition, Stats::NameToCountMapping &
|
||||
}
|
||||
}
|
||||
|
||||
void PrintMap(string const & keyName, string const & descr,
|
||||
Stats::NameToCountMapping const & mapping, ostringstream & ss)
|
||||
void PrintMap(string const & keyName, string const & descr, Stats::NameToCountMapping const & mapping,
|
||||
ostringstream & ss)
|
||||
{
|
||||
ss << descr << '\n';
|
||||
if (mapping.empty())
|
||||
@@ -74,17 +73,15 @@ void PrintMap(string const & keyName, string const & descr,
|
||||
namespace track_analyzing
|
||||
{
|
||||
// Stats ===========================================================================================
|
||||
Stats::Stats(NameToCountMapping const & mwmToTotalDataPoints,
|
||||
NameToCountMapping const & countryToTotalDataPoint)
|
||||
Stats::Stats(NameToCountMapping const & mwmToTotalDataPoints, NameToCountMapping const & countryToTotalDataPoint)
|
||||
: m_mwmToTotalDataPoints(mwmToTotalDataPoints)
|
||||
, m_countryToTotalDataPoints(countryToTotalDataPoint)
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
bool Stats::operator==(Stats const & stats) const
|
||||
{
|
||||
return m_mwmToTotalDataPoints == stats.m_mwmToTotalDataPoints &&
|
||||
m_countryToTotalDataPoints == stats.m_countryToTotalDataPoints;
|
||||
m_countryToTotalDataPoints == stats.m_countryToTotalDataPoints;
|
||||
}
|
||||
|
||||
void Stats::Add(Stats const & stats)
|
||||
@@ -93,8 +90,7 @@ void Stats::Add(Stats const & stats)
|
||||
::Add(stats.m_countryToTotalDataPoints, m_countryToTotalDataPoints);
|
||||
}
|
||||
|
||||
void Stats::AddTracksStats(MwmToTracks const & mwmToTracks, NumMwmIds const & numMwmIds,
|
||||
Storage const & storage)
|
||||
void Stats::AddTracksStats(MwmToTracks const & mwmToTracks, NumMwmIds const & numMwmIds, Storage const & storage)
|
||||
{
|
||||
for (auto const & kv : mwmToTracks)
|
||||
{
|
||||
@@ -109,15 +105,13 @@ void Stats::AddTracksStats(MwmToTracks const & mwmToTracks, NumMwmIds const & nu
|
||||
}
|
||||
}
|
||||
|
||||
void Stats::AddDataPoints(string const & mwmName, string const & countryName,
|
||||
uint64_t dataPointNum)
|
||||
void Stats::AddDataPoints(string const & mwmName, string const & countryName, uint64_t dataPointNum)
|
||||
{
|
||||
m_mwmToTotalDataPoints[mwmName] += dataPointNum;
|
||||
m_countryToTotalDataPoints[countryName] += dataPointNum;
|
||||
}
|
||||
|
||||
void Stats::AddDataPoints(string const & mwmName, storage::Storage const & storage,
|
||||
uint64_t dataPointNum)
|
||||
void Stats::AddDataPoints(string const & mwmName, storage::Storage const & storage, uint64_t dataPointNum)
|
||||
{
|
||||
auto const countryName = storage.GetTopmostParentFor(mwmName);
|
||||
// Note. In case of disputed mwms |countryName| will be empty.
|
||||
@@ -126,8 +120,7 @@ void Stats::AddDataPoints(string const & mwmName, storage::Storage const & stora
|
||||
|
||||
void Stats::SaveMwmDistributionToCsv(string const & csvPath) const
|
||||
{
|
||||
LOG(LINFO, ("Saving mwm distribution to", csvPath, "m_mwmToTotalDataPoints size is",
|
||||
m_mwmToTotalDataPoints.size()));
|
||||
LOG(LINFO, ("Saving mwm distribution to", csvPath, "m_mwmToTotalDataPoints size is", m_mwmToTotalDataPoints.size()));
|
||||
if (csvPath.empty())
|
||||
return;
|
||||
|
||||
@@ -162,8 +155,8 @@ void Stats::LogCountries() const
|
||||
LogNameToCountMapping("country", "Country name to data points number:", m_countryToTotalDataPoints);
|
||||
}
|
||||
|
||||
void MappingToCsv(string const & keyName, Stats::NameToCountMapping const & mapping,
|
||||
bool printPercentage, basic_ostream<char> & ss)
|
||||
void MappingToCsv(string const & keyName, Stats::NameToCountMapping const & mapping, bool printPercentage,
|
||||
basic_ostream<char> & ss)
|
||||
{
|
||||
struct KeyValue
|
||||
{
|
||||
@@ -208,8 +201,7 @@ void MappingToCsv(string const & keyName, Stats::NameToCountMapping const & mapp
|
||||
|
||||
void MappingFromCsv(basic_istream<char> & ss, Stats::NameToCountMapping & mapping)
|
||||
{
|
||||
for (auto const & row :
|
||||
coding::CSVRunner(coding::CSVReader(ss, true /* hasHeader */, ',' /* kCsvDelimiter */)))
|
||||
for (auto const & row : coding::CSVRunner(coding::CSVReader(ss, true /* hasHeader */, ',' /* kCsvDelimiter */)))
|
||||
{
|
||||
CHECK_EQUAL(row.size(), 2, (row));
|
||||
auto const & key = row[0];
|
||||
@@ -220,8 +212,7 @@ void MappingFromCsv(basic_istream<char> & ss, Stats::NameToCountMapping & mappin
|
||||
}
|
||||
}
|
||||
|
||||
void ParseTracks(string const & logFile, shared_ptr<NumMwmIds> const & numMwmIds,
|
||||
MwmToTracks & mwmToTracks)
|
||||
void ParseTracks(string const & logFile, shared_ptr<NumMwmIds> const & numMwmIds, MwmToTracks & mwmToTracks)
|
||||
{
|
||||
Platform const & platform = GetPlatform();
|
||||
string const dataDir = platform.WritableDir();
|
||||
@@ -240,8 +231,7 @@ void WriteCsvTableHeader(basic_ostream<char> & stream)
|
||||
"intersection with big\n";
|
||||
}
|
||||
|
||||
void LogNameToCountMapping(string const & keyName, string const & descr,
|
||||
Stats::NameToCountMapping const & mapping)
|
||||
void LogNameToCountMapping(string const & keyName, string const & descr, Stats::NameToCountMapping const & mapping)
|
||||
{
|
||||
ostringstream ss;
|
||||
LOG(LINFO, ("\n"));
|
||||
|
||||
@@ -23,8 +23,7 @@ public:
|
||||
using NameToCountMapping = std::map<std::string, uint64_t>;
|
||||
|
||||
Stats() = default;
|
||||
Stats(NameToCountMapping const & mwmToTotalDataPoints,
|
||||
NameToCountMapping const & countryToTotalDataPoint);
|
||||
Stats(NameToCountMapping const & mwmToTotalDataPoints, NameToCountMapping const & countryToTotalDataPoint);
|
||||
|
||||
bool operator==(Stats const & stats) const;
|
||||
void Add(Stats const & stats);
|
||||
@@ -34,11 +33,9 @@ public:
|
||||
storage::Storage const & storage);
|
||||
|
||||
/// \brief Adds |dataPointNum| to |m_mwmToTotalDataPoints| and |m_countryToTotalDataPoints|.
|
||||
void AddDataPoints(std::string const & mwmName, std::string const & countryName,
|
||||
uint64_t dataPointNum);
|
||||
void AddDataPoints(std::string const & mwmName, std::string const & countryName, uint64_t dataPointNum);
|
||||
|
||||
void AddDataPoints(std::string const & mwmName, storage::Storage const & storage,
|
||||
uint64_t dataPointNum);
|
||||
void AddDataPoints(std::string const & mwmName, storage::Storage const & storage, uint64_t dataPointNum);
|
||||
|
||||
/// \brief Saves csv file with numbers of DataPoints for each mwm to |csvPath|.
|
||||
/// If |csvPath| is empty it does nothing.
|
||||
@@ -60,8 +57,8 @@ private:
|
||||
};
|
||||
|
||||
/// \brief Saves |mapping| as csv to |ss|.
|
||||
void MappingToCsv(std::string const & keyName, Stats::NameToCountMapping const & mapping,
|
||||
bool printPercentage, std::basic_ostream<char> & ss);
|
||||
void MappingToCsv(std::string const & keyName, Stats::NameToCountMapping const & mapping, bool printPercentage,
|
||||
std::basic_ostream<char> & ss);
|
||||
/// \breif Fills |mapping| according to csv in |ss|. Csv header is skipped.
|
||||
void MappingFromCsv(std::basic_istream<char> & ss, Stats::NameToCountMapping & mapping);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user