| 100 | }; |
| 101 | |
| 102 | bool ReadPolygon(std::istream & stream, Polygon & poly, std::string const & filename) |
| 103 | { |
| 104 | std::string line, name; |
| 105 | double lon, lat; |
| 106 | |
| 107 | // read ring id, fail if it's empty |
| 108 | std::getline(stream, name); |
| 109 | if (name.empty() || name == "END") |
| 110 | return false; |
| 111 | |
| 112 | while (stream.good()) |
| 113 | { |
| 114 | std::getline(stream, line); |
| 115 | strings::Trim(line); |
| 116 | |
| 117 | if (line.empty()) |
| 118 | continue; |
| 119 | |
| 120 | if (line == "END") |
| 121 | break; |
| 122 | |
| 123 | std::istringstream iss(line); |
| 124 | iss >> lon >> lat; |
| 125 | CHECK(!iss.fail(), ("Incorrect data in", filename)); |
| 126 | |
| 127 | poly.AddPoint(mercator::FromLatLon(lat, lon)); |
| 128 | } |
| 129 | |
| 130 | // drop inner rings |
| 131 | return name[0] != '!'; |
| 132 | } |
| 133 | } // namespace |
| 134 | |
| 135 | bool CountryPolygons::Contains(m2::PointD const & point) const |
no test coverage detected