git-clang-format

This commit is contained in:
Vladimir Byko-Ianko 2016-09-05 14:52:53 +03:00
parent c7c726975c
commit 037d271dbe
8 changed files with 51 additions and 68 deletions

View file

@ -2984,11 +2984,7 @@ bool Framework::OriginalFeatureHasDefaultName(FeatureID const & fid) const
return osm::Editor::Instance().OriginalFeatureHasDefaultName(fid);
}
bool Framework::HasRouteAltitude() const
{
return m_routingSession.HasRouteAltitude();
}
bool Framework::HasRouteAltitude() const { return m_routingSession.HasRouteAltitude(); }
bool Framework::GenerateRouteAltitudeChart(size_t width, size_t height, bool day,
vector<uint8_t> & imageRGBAData) const
{

View file

@ -36,7 +36,8 @@ struct BlendAdaptor
using TBlendTable = agg::comp_op_table_rgba<Color, Order>;
if (p[Order::A])
{
TBlendTable::g_comp_op_func[op](p, (cr * ca + ScaleMask) >> ScaleShift, (cg * ca + ScaleMask) >> ScaleShift,
TBlendTable::g_comp_op_func[op](p, (cr * ca + ScaleMask) >> ScaleShift,
(cg * ca + ScaleMask) >> ScaleShift,
(cb * ca + ScaleMask) >> ScaleShift, ca, cover);
}
else
@ -47,11 +48,13 @@ struct BlendAdaptor
};
} // namespace
void NormalizeChartData(deque<double> const & distanceDataM, feature::TAltitudes const & altitudeDataM,
size_t resultPointCount, vector<double> & uniformAltitudeDataM)
void NormalizeChartData(deque<double> const & distanceDataM,
feature::TAltitudes const & altitudeDataM, size_t resultPointCount,
vector<double> & uniformAltitudeDataM)
{
uniformAltitudeDataM.clear();
if (distanceDataM.empty() || resultPointCount == 0 || distanceDataM.size() != altitudeDataM.size())
if (distanceDataM.empty() || resultPointCount == 0 ||
distanceDataM.size() != altitudeDataM.size())
return;
if (!is_sorted(distanceDataM.cbegin(), distanceDataM.cend()))
@ -62,11 +65,10 @@ void NormalizeChartData(deque<double> const & distanceDataM, feature::TAltitudes
uniformAltitudeDataM.resize(resultPointCount);
double const routeLenM = distanceDataM.back();
double const stepLenM = routeLenM / static_cast<double> (resultPointCount - 1);
double const stepLenM = routeLenM / static_cast<double>(resultPointCount - 1);
auto const calculateAltitude = [&](double distFormStartM)
{
if (distFormStartM <= distanceDataM.front() )
auto const calculateAltitude = [&](double distFormStartM) {
if (distFormStartM <= distanceDataM.front())
return static_cast<double>(altitudeDataM.front());
if (distFormStartM >= distanceDataM.back())
return static_cast<double>(altitudeDataM.back());
@ -85,8 +87,9 @@ void NormalizeChartData(deque<double> const & distanceDataM, feature::TAltitudes
return static_cast<double>(altitudeDataM[prevPointIdx]);
double const k = (altitudeDataM[nextPointIdx] - altitudeDataM[prevPointIdx]) /
(distanceDataM[nextPointIdx] - distanceDataM[prevPointIdx]);
return static_cast<double>(altitudeDataM[prevPointIdx]) + k * (distFormStartM - distanceDataM[prevPointIdx]);
(distanceDataM[nextPointIdx] - distanceDataM[prevPointIdx]);
return static_cast<double>(altitudeDataM[prevPointIdx]) +
k * (distFormStartM - distanceDataM[prevPointIdx]);
};
uniformAltitudeDataM.resize(resultPointCount);
@ -121,18 +124,19 @@ void GenerateYAxisChartData(size_t height, double minMetersPerPxl,
size_t const altitudeDataSz = altitudeDataM.size();
yAxisDataPxl.resize(altitudeDataSz);
for (size_t i = 0; i < altitudeDataSz; ++i)
yAxisDataPxl[i] = height - heightIndent - (altitudeDataM[i] - minAltM) / meterPerPxl;
yAxisDataPxl[i] = height - heightIndent - (altitudeDataM[i] - minAltM) / meterPerPxl;
}
void GenerateChartByPoints(size_t width, size_t height, vector<m2::PointD> const & geometry,
bool day, vector<uint8_t> & frameBuffer)
bool day, vector<uint8_t> & frameBuffer)
{
frameBuffer.clear();
if (width == 0 || height == 0 || geometry.empty())
return;
agg::rgba8 const kBackgroundColor = agg::rgba8(255, 255, 255, 0);
agg::rgba8 const kLineColor = day ? agg::rgba8(30, 150, 240, 255) : agg::rgba8(255, 230, 140, 255);
agg::rgba8 const kLineColor =
day ? agg::rgba8(30, 150, 240, 255) : agg::rgba8(255, 230, 140, 255);
agg::rgba8 const kCurveColor = day ? agg::rgba8(30, 150, 240, 20) : agg::rgba8(255, 230, 140, 20);
double constexpr kLineWidthPxl = 2.0;
uint32_t constexpr kBPP = 4;
@ -151,8 +155,7 @@ void GenerateChartByPoints(size_t width, size_t height, vector<m2::PointD> const
frameBuffer.assign(width * kBPP * height, 0);
renderBuffer.attach(&frameBuffer[0], static_cast<unsigned int>(width),
static_cast<unsigned int>(height),
static_cast<int>(width * kBPP));
static_cast<unsigned int>(height), static_cast<int>(width * kBPP));
m_baseRenderer.reset_clipping(true);
unsigned op = pixelFormat.comp_op();
pixelFormat.comp_op(agg::comp_op_src);
@ -186,9 +189,9 @@ void GenerateChartByPoints(size_t width, size_t height, vector<m2::PointD> const
agg::render_scanlines_aa_solid(rasterizer, scanline, m_baseRenderer, kLineColor);
}
void GenerateChart(size_t width, size_t height,
deque<double> const & distanceDataM, feature::TAltitudes const & altitudeDataM,
bool day, vector<uint8_t> & frameBuffer)
void GenerateChart(size_t width, size_t height, deque<double> const & distanceDataM,
feature::TAltitudes const & altitudeDataM, bool day,
vector<uint8_t> & frameBuffer)
{
frameBuffer.clear();
if (altitudeDataM.empty() || distanceDataM.size() != altitudeDataM.size())

View file

@ -10,8 +10,9 @@
/// \brief fills uniformAltitudeDataM with altitude data which evenly distributed by
/// |resultPointCount| points. |distanceDataM| and |altitudeDataM| form a curve of route altitude.
/// This method is used to generalize and evenly distribute points of the chart.
void NormalizeChartData(deque<double> const & distanceDataM, feature::TAltitudes const & altitudeDataM,
size_t resultPointCount, vector<double> & uniformAltitudeDataM);
void NormalizeChartData(deque<double> const & distanceDataM,
feature::TAltitudes const & altitudeDataM, size_t resultPointCount,
vector<double> & uniformAltitudeDataM);
/// \brief fills |yAxisDataPxl|. |yAxisDataPxl| is formed to pevent displaying
/// big waves on the chart in case of small deviation in absolute values in |yAxisData|.
@ -30,8 +31,8 @@ void GenerateYAxisChartData(size_t height, double minMetersPerPxl,
/// \param frameBuffer is a vector for a result image. It's resized in this method.
/// It's filled with RGBA(8888) image date.
void GenerateChartByPoints(size_t width, size_t height, vector<m2::PointD> const & geometry,
bool day, vector<uint8_t> & frameBuffer);
bool day, vector<uint8_t> & frameBuffer);
void GenerateChart(size_t width, size_t height,
deque<double> const & distanceDataM, feature::TAltitudes const & altitudeDataM,
bool day, vector<uint8_t> & frameBuffer);
void GenerateChart(size_t width, size_t height, deque<double> const & distanceDataM,
feature::TAltitudes const & altitudeDataM, bool day,
vector<uint8_t> & frameBuffer);

View file

@ -25,13 +25,13 @@ bool AlmostEqualAbs(vector<double> const & v1, vector<double> const & v2)
return true;
}
bool IsColor(vector<uint8_t> const & frameBuffer, size_t startColorIdx,
uint8_t expectedR, uint8_t expectedG, uint8_t expectedB, uint8_t expectedA)
bool IsColor(vector<uint8_t> const & frameBuffer, size_t startColorIdx, uint8_t expectedR,
uint8_t expectedG, uint8_t expectedB, uint8_t expectedA)
{
CHECK_LESS(startColorIdx + kBPP, frameBuffer.size(), ());
return frameBuffer[startColorIdx] == expectedR && frameBuffer[startColorIdx + 1] == expectedG
&& frameBuffer[startColorIdx + 2] == expectedB && frameBuffer[startColorIdx + 3] == expectedA;
return frameBuffer[startColorIdx] == expectedR && frameBuffer[startColorIdx + 1] == expectedG &&
frameBuffer[startColorIdx + 2] == expectedB && frameBuffer[startColorIdx + 3] == expectedA;
}
UNIT_TEST(NormalizeChartDataZeroTest)
@ -54,8 +54,8 @@ UNIT_TEST(NormalizeChartDataTest)
vector<double> uniformAltitudeDataM;
NormalizeChartData(distanceDataM, altitudeDataM, 10 /* resultPointCount */, uniformAltitudeDataM);
vector<double> const expectedUniformAltitudeDataM =
{-9.0, -6.0, -3.0, 0.0, 3.0, 6.0, 9.0, 12.0, 15.0, 18.0};
vector<double> const expectedUniformAltitudeDataM = {-9.0, -6.0, -3.0, 0.0, 3.0,
6.0, 9.0, 12.0, 15.0, 18.0};
TEST(AlmostEqualAbs(uniformAltitudeDataM, expectedUniformAltitudeDataM), ());
}
@ -88,9 +88,11 @@ UNIT_TEST(GenerateChartByPointsTest)
GenerateChartByPoints(width, 40 /* height */, geometry, true /* day */, frameBuffer);
TEST(IsColor(frameBuffer, 0 /* startColorIdx */, 30 /* expectedR */, 150 /* expectedG */,
240 /* expectedB */, 255 /* expectedA */), ());
TEST(IsColor(frameBuffer, kBPP * (width - 1) /* startColorIdx */, 255 /* expectedR */, 255 /* expectedG */,
255 /* expectedB */, 0 /* expectedA */), ());
240 /* expectedB */, 255 /* expectedA */),
());
TEST(IsColor(frameBuffer, kBPP * (width - 1) /* startColorIdx */, 255 /* expectedR */,
255 /* expectedG */, 255 /* expectedB */, 0 /* expectedA */),
());
}
UNIT_TEST(GenerateChartTest)
@ -106,8 +108,10 @@ UNIT_TEST(GenerateChartTest)
LOG(LINFO, (frameBuffer[2]));
LOG(LINFO, (frameBuffer[3]));
TEST(IsColor(frameBuffer, 0 /* startColorIdx */, 255 /* expectedR */, 255 /* expectedG */,
255 /* expectedB */, 0 /* expectedA */), ());
TEST(IsColor(frameBuffer, kBPP * 3 * width - kBPP /* startColorIdx */, 255 /* expectedR */, 230 /* expectedG */,
140 /* expectedB */, 255 /* expectedA */), ());
255 /* expectedB */, 0 /* expectedA */),
());
TEST(IsColor(frameBuffer, kBPP * 3 * width - kBPP /* startColorIdx */, 255 /* expectedR */,
230 /* expectedG */, 140 /* expectedB */, 255 /* expectedA */),
());
}
} // namespace

View file

@ -24,7 +24,6 @@ public:
m2::PolylineD const & GetPolyline() const { return m_poly; }
vector<double> const & GetSegDistanceM() const { return m_segDistance; }
double GetTotalDistanceM() const;
double GetDistanceFromBeginM() const;
double GetDistanceToEndM() const;

View file

@ -9,8 +9,8 @@
#include "coding/reader_wrapper.hpp"
#include "indexer/feature_altitude.hpp"
#include "indexer/feature.hpp"
#include "indexer/feature_altitude.hpp"
#include "indexer/ftypes_matcher.hpp"
#include "indexer/index.hpp"

View file

@ -55,26 +55,10 @@ public:
Update();
}
inline void SwapTurnInstructions(TTurns & v)
{
swap(m_turns, v);
}
inline void SwapSectionTimes(TTimes & v)
{
swap(m_times, v);
}
inline void SwapStreetNames(TStreets & v)
{
swap(m_streets, v);
}
inline void SwapAltitudes(feature::TAltitudes & v)
{
swap(m_altitudes, v);
}
inline void SwapTurnInstructions(TTurns & v) { swap(m_turns, v); }
inline void SwapSectionTimes(TTimes & v) { swap(m_times, v); }
inline void SwapStreetNames(TStreets & v) { swap(m_streets, v); }
inline void SwapAltitudes(feature::TAltitudes & v) { swap(m_altitudes, v); }
uint32_t GetTotalTimeSec() const;
uint32_t GetCurrentTimeToEndSec() const;

View file

@ -523,11 +523,7 @@ void RoutingSession::EmitCloseRoutingEvent() const
alohalytics::Location::FromLatLon(lastGoodPoint.lat, lastGoodPoint.lon));
}
bool RoutingSession::HasRouteAltitudeImpl() const
{
return !m_route.GetAltitudes().empty();
}
bool RoutingSession::HasRouteAltitudeImpl() const { return !m_route.GetAltitudes().empty(); }
bool RoutingSession::HasRouteAltitude() const
{
threads::MutexGuard guard(m_routeSessionMutex);