| 75 | } |
| 76 | |
| 77 | void LatLonParser::operator()(std::string name, std::string const & value) |
| 78 | { |
| 79 | strings::AsciiToLower(name); |
| 80 | if (name == "z" || name == "zoom") |
| 81 | { |
| 82 | double x; |
| 83 | if (strings::to_double(value, x)) |
| 84 | m_info->SetZoom(x); |
| 85 | return; |
| 86 | } |
| 87 | |
| 88 | int const priority = GetCoordinatesPriority(name); |
| 89 | if (priority == -1 || priority < m_latPriority || priority < m_lonPriority) |
| 90 | return; |
| 91 | |
| 92 | if (priority != kXYPriority && priority != kLatLonPriority) |
| 93 | { |
| 94 | boost::smatch m; |
| 95 | if (boost::regex_search(value, m, m_regexp) && m.size() == 3) |
| 96 | { |
| 97 | double lat, lon; |
| 98 | VERIFY(strings::to_double(m[1].str(), lat), ()); |
| 99 | VERIFY(strings::to_double(m[2].str(), lon), ()); |
| 100 | |
| 101 | if (m_swapLatLon) |
| 102 | std::swap(lat, lon); |
| 103 | |
| 104 | if (m_info->SetLat(lat) && m_info->SetLon(lon)) |
| 105 | { |
| 106 | m_latPriority = priority; |
| 107 | m_lonPriority = priority; |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | return; |
| 112 | } |
| 113 | |
| 114 | double x; |
| 115 | if (strings::to_double(value, x)) |
| 116 | { |
| 117 | if (name == "lat" || name == "mlat" || name == "y") |
| 118 | { |
| 119 | if (m_info->SetLat(x)) |
| 120 | m_latPriority = priority; |
| 121 | } |
| 122 | else |
| 123 | { |
| 124 | ASSERT(name == "lon" || name == "mlon" || name == "x", (name)); |
| 125 | if (m_info->SetLon(x)) |
| 126 | m_lonPriority = priority; |
| 127 | } |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | int LatLonParser::GetCoordinatesPriority(string const & token) |
| 132 | { |