Skip to content

Commit

Permalink
[bookmarks][pykmlib] Support invalid altitude in tracks.
Browse files Browse the repository at this point in the history
  • Loading branch information
darina authored and jbenua committed Mar 12, 2020
1 parent 51e7959 commit 58b8af8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions kml/pykmlib/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ std::string IndexToClassificatorType(uint32_t index)
BOOST_PYTHON_MODULE(pykmlib)
{
scope().attr("__version__") = PYBINDINGS_VERSION;
scope().attr("invalid_altitude") = geometry::kInvalidAltitude;
register_exception_translator<std::runtime_error>(&TranslateRuntimeError);
TimestampConverter();
LatLonConverter();
Expand Down
2 changes: 1 addition & 1 deletion kml/pykmlib/bindings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_smoke(self):
pt2.set_altitude(110)
pt3 = pykmlib.PointWithAltitude()
pt3.set_point(pykmlib.LatLon(45.1964, 56.9832))
pt3.set_altitude(120)
pt3.set_altitude(pykmlib.invalid_altitude)
track.points_with_altitudes.set_list([pt1, pt2, pt3])
track.visible = True
track.nearest_toponyms.set_list(['12345', '54321', '98765'])
Expand Down
6 changes: 4 additions & 2 deletions kml/serdes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ std::string PointToString(m2::PointD const & org)

std::string PointToString(geometry::PointWithAltitude const & pt)
{
return PointToString(pt.GetPoint()) + "," + strings::to_string(pt.GetAltitude());
if (pt.GetAltitude() != geometry::kInvalidAltitude)
return PointToString(pt.GetPoint()) + "," + strings::to_string(pt.GetAltitude());
return PointToString(pt.GetPoint());
}

std::string GetLocalizableString(LocalizableString const & s, int8_t lang)
Expand Down Expand Up @@ -549,7 +551,7 @@ bool ParsePoint(std::string const & s, char const * delim, m2::PointD & pt)
bool ParsePointWithAltitude(std::string const & s, char const * delim,
geometry::PointWithAltitude & point)
{
geometry::Altitude altitude = geometry::kDefaultAltitudeMeters;
geometry::Altitude altitude = geometry::kInvalidAltitude;
m2::PointD pt;
auto result = ParsePoint(s, delim, pt, altitude);
point.SetPoint(std::move(pt));
Expand Down

0 comments on commit 58b8af8

Please sign in to comment.