Skip to content

Commit

Permalink
[bookmarks] Support float altitudes in kml files.
Browse files Browse the repository at this point in the history
  • Loading branch information
darina authored and jbenua committed Mar 12, 2020
1 parent 58b8af8 commit db865a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions kml/serdes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,9 @@ bool ParsePoint(std::string const & s, char const * delim, m2::PointD & pt,
{
pt = mercator::FromLatLon(lat, lon);

int rawAltitude;
if (++iter && strings::to_int(*iter, rawAltitude))
altitude = static_cast<geometry::Altitude>(rawAltitude);
double rawAltitude;
if (++iter && strings::to_double(*iter, rawAltitude))
altitude = static_cast<geometry::Altitude>(round(rawAltitude));

return true;
}
Expand Down
6 changes: 4 additions & 2 deletions map/map_tests/bookmarks_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1123,12 +1123,14 @@ UNIT_CLASS_TEST(Runner, TrackParsingTest_1)
dp::Color(171, 230, 0, 255),
dp::Color(0, 230, 117, 255),
dp::Color(0, 59, 230, 255)}};
array<double, 4> const length = {{3525.46839061, 27172.44338132, 27046.0456586, 23967.35765800}};

array<double, 4> const length = {{3525.46839061, 27174.11393166, 27046.0456586, 23967.35765800}};
array<geometry::Altitude, 4> const altitudes = {{0, 27, -3, -2}};
size_t i = 0;
for (auto trackId : bmManager.GetTrackIds(catId))
{
auto const * track = bmManager.GetTrack(trackId);
TEST_EQUAL(track->GetPointsWithAltitudes()[0].GetAltitude(), altitudes[i],
(track->GetPointsWithAltitudes()[0].GetAltitude(), altitudes[i]));
TEST_EQUAL(names[i], track->GetName(), ());
TEST(fabs(track->GetLengthMeters() - length[i]) < 1.0E-6, (track->GetLengthMeters(), length[i]));
TEST_GREATER(track->GetLayerCount(), 0, ());
Expand Down

0 comments on commit db865a6

Please sign in to comment.