| 28 | namespace feature |
| 29 | { |
| 30 | bool ReadRegionDataImpl(std::string const & countryName, RegionData & data) |
| 31 | { |
| 32 | /// @todo How LEAP_SPEEDS_FILE was generated before? It's always absent now. |
| 33 | if (Platform::IsFileExistsByFullPath(LEAP_SPEEDS_FILE)) |
| 34 | { |
| 35 | try |
| 36 | { |
| 37 | auto crossMwmDataReader = GetPlatform().GetReader(LEAP_SPEEDS_FILE); |
| 38 | std::string crossMwmDataBuffer; |
| 39 | crossMwmDataReader->ReadAsString(crossMwmDataBuffer); |
| 40 | base::Json crossMwmData(crossMwmDataBuffer.data()); |
| 41 | |
| 42 | json_t const * crossMwmJsonData = nullptr; |
| 43 | FromJSONObjectOptionalField(crossMwmData.get(), countryName, crossMwmJsonData); |
| 44 | if (crossMwmJsonData) |
| 45 | { |
| 46 | double leapSpeed = FromJSONObject<double>(crossMwmJsonData, "leapspeed"); |
| 47 | if (leapSpeed > 0.0) |
| 48 | data.SetLeapWeightSpeed(leapSpeed); |
| 49 | } |
| 50 | } |
| 51 | catch (FileAbsentException const & e) |
| 52 | { |
| 53 | LOG(LERROR, ("Error missing file", LEAP_SPEEDS_FILE, ":", e.Msg())); |
| 54 | return false; |
| 55 | } |
| 56 | catch (Reader::Exception const & e) |
| 57 | { |
| 58 | LOG(LERROR, ("Error reading", LEAP_SPEEDS_FILE, ":", e.Msg())); |
| 59 | return false; |
| 60 | } |
| 61 | catch (base::Json::Exception const & e) |
| 62 | { |
| 63 | LOG(LERROR, ("Error parsing JSON in", LEAP_SPEEDS_FILE, ":", e.Msg())); |
| 64 | return false; |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | try |
| 69 | { |
| 70 | auto reader = GetPlatform().GetReader(COUNTRIES_META_FILE); |
| 71 | std::string buffer; |
| 72 | reader->ReadAsString(buffer); |
| 73 | base::Json root(buffer.data()); |
| 74 | |
| 75 | json_t const * jsonData = nullptr; |
| 76 | FromJSONObjectOptionalField(root.get(), countryName, jsonData); |
| 77 | if (!jsonData) |
| 78 | return false; |
| 79 | |
| 80 | std::vector<std::string> languages; |
| 81 | FromJSONObjectOptionalField(jsonData, "languages", languages); |
| 82 | if (!languages.empty()) |
| 83 | data.SetLanguages(languages); |
| 84 | |
| 85 | std::string driving; |
| 86 | FromJSONObjectOptionalField(jsonData, "driving", driving); |
| 87 | if (driving == "l" || driving == "r") |
no test coverage detected