| 154 | } |
| 155 | |
| 156 | UserPreferences ServerApi06::GetUserPreferences() const |
| 157 | { |
| 158 | try |
| 159 | { |
| 160 | OsmOAuth::Response const response = m_auth.Request("/user/details"); |
| 161 | if (response.first != OsmOAuth::HTTP::OK) |
| 162 | MYTHROW(CantGetUserPreferences, (response)); |
| 163 | |
| 164 | pugi::xml_document details; |
| 165 | if (!details.load_string(response.second.c_str())) |
| 166 | MYTHROW(CantParseUserPreferences, (response)); |
| 167 | |
| 168 | pugi::xml_node const user = details.child("osm").child("user"); |
| 169 | if (!user || !user.attribute("id")) |
| 170 | MYTHROW(CantParseUserPreferences, ("No <user> or 'id' attribute", response)); |
| 171 | |
| 172 | UserPreferences pref; |
| 173 | pref.m_id = user.attribute("id").as_ullong(); |
| 174 | pref.m_displayName = user.attribute("display_name").as_string(); |
| 175 | pref.m_accountCreated = base::StringToTimestamp(user.attribute("account_created").as_string()); |
| 176 | pref.m_imageUrl = user.child("img").attribute("href").as_string(); |
| 177 | pref.m_changesets = user.child("changesets").attribute("count").as_uint(); |
| 178 | return pref; |
| 179 | } |
| 180 | catch (std::exception const & e) |
| 181 | { |
| 182 | LOG(LWARNING, ("Can't load user preferences from server: ", e.what())); |
| 183 | } |
| 184 | |
| 185 | return {}; |
| 186 | } |
| 187 | |
| 188 | OsmOAuth::Response ServerApi06::GetXmlFeaturesInRect(double minLat, double minLon, double maxLat, double maxLon) const |
| 189 | { |