| 269 | } |
| 270 | |
| 271 | bool GenerateChart(uint32_t width, uint32_t height, vector<double> const & distanceDataM, |
| 272 | geometry::Altitudes const & altitudeDataM, MapStyle mapStyle, vector<uint8_t> & frameBuffer) |
| 273 | { |
| 274 | if (distanceDataM.size() != altitudeDataM.size()) |
| 275 | { |
| 276 | LOG(LERROR, ("The route is in inconsistent state. Size of altitudes is", altitudeDataM.size(), |
| 277 | ". Number of segment is", distanceDataM.size())); |
| 278 | return false; |
| 279 | } |
| 280 | |
| 281 | vector<double> uniformAltitudeDataM; |
| 282 | if (!NormalizeChartData(distanceDataM, altitudeDataM, width, uniformAltitudeDataM)) |
| 283 | return false; |
| 284 | |
| 285 | vector<double> yAxisDataPxl; |
| 286 | if (!GenerateYAxisChartData(height, 1.0 /* minMetersPerPxl */, uniformAltitudeDataM, yAxisDataPxl)) |
| 287 | return false; |
| 288 | |
| 289 | size_t const uniformAltitudeDataSize = yAxisDataPxl.size(); |
| 290 | vector<m2::PointD> geometry(uniformAltitudeDataSize); |
| 291 | |
| 292 | if (uniformAltitudeDataSize != 0) |
| 293 | { |
| 294 | double const oneSegLenPix = |
| 295 | static_cast<double>(width) / (uniformAltitudeDataSize == 1 ? 1 : (uniformAltitudeDataSize - 1)); |
| 296 | for (size_t i = 0; i < uniformAltitudeDataSize; ++i) |
| 297 | geometry[i] = m2::PointD(i * oneSegLenPix, yAxisDataPxl[i]); |
| 298 | } |
| 299 | |
| 300 | return GenerateChartByPoints(width, height, geometry, mapStyle, frameBuffer); |
| 301 | } |
| 302 | } // namespace maps |