Skip to content

Commit db865a6

Browse files
darinajbenua
authored andcommitted
[bookmarks] Support float altitudes in kml files.
1 parent 58b8af8 commit db865a6

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

kml/serdes.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,9 @@ bool ParsePoint(std::string const & s, char const * delim, m2::PointD & pt,
532532
{
533533
pt = mercator::FromLatLon(lat, lon);
534534

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

539539
return true;
540540
}

map/map_tests/bookmarks_test.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -1123,12 +1123,14 @@ UNIT_CLASS_TEST(Runner, TrackParsingTest_1)
11231123
dp::Color(171, 230, 0, 255),
11241124
dp::Color(0, 230, 117, 255),
11251125
dp::Color(0, 59, 230, 255)}};
1126-
array<double, 4> const length = {{3525.46839061, 27172.44338132, 27046.0456586, 23967.35765800}};
1127-
1126+
array<double, 4> const length = {{3525.46839061, 27174.11393166, 27046.0456586, 23967.35765800}};
1127+
array<geometry::Altitude, 4> const altitudes = {{0, 27, -3, -2}};
11281128
size_t i = 0;
11291129
for (auto trackId : bmManager.GetTrackIds(catId))
11301130
{
11311131
auto const * track = bmManager.GetTrack(trackId);
1132+
TEST_EQUAL(track->GetPointsWithAltitudes()[0].GetAltitude(), altitudes[i],
1133+
(track->GetPointsWithAltitudes()[0].GetAltitude(), altitudes[i]));
11321134
TEST_EQUAL(names[i], track->GetName(), ());
11331135
TEST(fabs(track->GetLengthMeters() - length[i]) < 1.0E-6, (track->GetLengthMeters(), length[i]));
11341136
TEST_GREATER(track->GetLayerCount(), 0, ());

0 commit comments

Comments
 (0)