| 86 | } |
| 87 | |
| 88 | bool LoadBrands(string const & brandsFilename, string const & translationsFilename, map<GeoObjectId, string> & brands) |
| 89 | { |
| 90 | string jsonBuffer; |
| 91 | try |
| 92 | { |
| 93 | GetPlatform().GetReader(brandsFilename)->ReadAsString(jsonBuffer); |
| 94 | } |
| 95 | catch (RootException const & e) |
| 96 | { |
| 97 | LOG(LERROR, ("Can't open", brandsFilename, e.Msg())); |
| 98 | return false; |
| 99 | } |
| 100 | |
| 101 | vector<pair<GeoObjectId, uint32_t>> objects; |
| 102 | try |
| 103 | { |
| 104 | base::Json root(jsonBuffer.c_str()); |
| 105 | CHECK(root.get() != nullptr, ("Cannot parse the json file:", brandsFilename)); |
| 106 | |
| 107 | ParseFeatureToBrand(root.get(), "nodes", GeoObjectId::Type::ObsoleteOsmNode, objects); |
| 108 | ParseFeatureToBrand(root.get(), "ways", GeoObjectId::Type::ObsoleteOsmWay, objects); |
| 109 | ParseFeatureToBrand(root.get(), "relations", GeoObjectId::Type::ObsoleteOsmRelation, objects); |
| 110 | } |
| 111 | catch (base::Json::Exception const &) |
| 112 | { |
| 113 | LOG(LERROR, ("Cannot create base::Json from", brandsFilename)); |
| 114 | return false; |
| 115 | } |
| 116 | catch (ParsingError const & e) |
| 117 | { |
| 118 | LOG(LERROR, ("Invalid data in", brandsFilename, e.Msg())); |
| 119 | return false; |
| 120 | } |
| 121 | |
| 122 | try |
| 123 | { |
| 124 | GetPlatform().GetReader(translationsFilename)->ReadAsString(jsonBuffer); |
| 125 | } |
| 126 | catch (RootException const & e) |
| 127 | { |
| 128 | LOG(LERROR, ("Can't open", translationsFilename, e.Msg())); |
| 129 | return false; |
| 130 | } |
| 131 | |
| 132 | map<uint32_t, string> idToKey; |
| 133 | try |
| 134 | { |
| 135 | base::Json root(jsonBuffer.c_str()); |
| 136 | CHECK(root.get() != nullptr, ("Cannot parse the json file:", translationsFilename)); |
| 137 | auto const & keys = indexer::GetDefaultBrands().GetKeys(); |
| 138 | ParseTranslations(root.get(), keys, idToKey); |
| 139 | } |
| 140 | catch (base::Json::Exception const &) |
| 141 | { |
| 142 | LOG(LERROR, ("Cannot create base::Json from", translationsFilename)); |
| 143 | return false; |
| 144 | } |
| 145 | catch (ParsingError const & e) |