| 11 | uint32_t constexpr SpeedCameraMwmHeader::kLatestVersion; |
| 12 | |
| 13 | void SerializeSpeedCamera(FileWriter & writer, routing::SpeedCameraMetadata const & data, uint32_t & prevFeatureId) |
| 14 | { |
| 15 | CHECK_EQUAL(data.m_ways.size(), 1, ()); |
| 16 | |
| 17 | auto const & way = data.m_ways.back(); |
| 18 | auto featureId = way.m_featureId; |
| 19 | CHECK_GREATER_OR_EQUAL(featureId, prevFeatureId, ()); |
| 20 | |
| 21 | uint32_t const saveFeatureId = featureId; |
| 22 | featureId -= prevFeatureId; // delta coding |
| 23 | prevFeatureId = saveFeatureId; |
| 24 | |
| 25 | WriteVarUint(writer, featureId); |
| 26 | WriteVarUint(writer, way.m_segmentId); |
| 27 | |
| 28 | uint32_t const coef = DoubleToUint32(way.m_coef, 0.0 /* min */, 1.0 /* max */, 32 /* bits */); |
| 29 | WriteToSink(writer, coef); |
| 30 | |
| 31 | WriteToSink(writer, data.m_maxSpeedKmPH); |
| 32 | |
| 33 | auto const direction = static_cast<uint8_t>(data.m_direction); |
| 34 | WriteToSink(writer, direction); |
| 35 | |
| 36 | // TODO (@gmoryes) add implementation of this feature |
| 37 | // List of time conditions will be saved here. For example: |
| 38 | // "maxspeed:conditional": "60 @ (23:00-05:00)" |
| 39 | // or |
| 40 | // "60 @ (Su 00:00-24:00; Mo-Sa 00:00-06:00,22:30-24:00)" |
| 41 | // We store number of conditions first, then each condition in 3 bytes: |
| 42 | // 1. Type of condition (day, hour, month) + start value of range. |
| 43 | // 2. End value of range. |
| 44 | // 3. SpeedMacro in this time range. |
| 45 | WriteVarInt(writer, 0 /* number of time conditions */); |
| 46 | } |
| 47 | } // namespace routing |