Skip to content

Commit e45352d

Browse files
committed
Use accessor functions in osmium::Location internally
1 parent bd774fd commit e45352d

1 file changed

Lines changed: 14 additions & 20 deletions

File tree

include/osmium/osm/location.hpp

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -350,10 +350,10 @@ namespace osmium {
350350
* See also is_defined() and is_undefined().
351351
*/
352352
constexpr bool valid() const noexcept {
353-
return m_x >= -180 * precision()
354-
&& m_x <= 180 * precision()
355-
&& m_y >= -90 * precision()
356-
&& m_y <= 90 * precision();
353+
return x() >= -180 * precision()
354+
&& x() <= 180 * precision()
355+
&& y() >= -90 * precision()
356+
&& y() <= 90 * precision();
357357
}
358358

359359
/**
@@ -401,14 +401,14 @@ namespace osmium {
401401
if (!valid()) {
402402
throw osmium::invalid_location{"invalid location"};
403403
}
404-
return fix_to_double(m_x);
404+
return fix_to_double(x());
405405
}
406406

407407
/**
408408
* Get longitude without checking the validity.
409409
*/
410410
double lon_without_check() const noexcept {
411-
return fix_to_double(m_x);
411+
return fix_to_double(x());
412412
}
413413

414414
/**
@@ -420,24 +420,22 @@ namespace osmium {
420420
if (!valid()) {
421421
throw osmium::invalid_location{"invalid location"};
422422
}
423-
return fix_to_double(m_y);
423+
return fix_to_double(y());
424424
}
425425

426426
/**
427427
* Get latitude without checking the validity.
428428
*/
429429
double lat_without_check() const noexcept {
430-
return fix_to_double(m_y);
430+
return fix_to_double(y());
431431
}
432432

433433
Location& set_lon(double lon) noexcept {
434-
m_x = double_to_fix(lon);
435-
return *this;
434+
return set_x(double_to_fix(lon));
436435
}
437436

438437
Location& set_lat(double lat) noexcept {
439-
m_y = double_to_fix(lat);
440-
return *this;
438+
return set_y(double_to_fix(lat));
441439
}
442440

443441
Location& set_lon(const char* str) {
@@ -446,8 +444,7 @@ namespace osmium {
446444
if (**data != '\0') {
447445
throw invalid_location{std::string{"characters after coordinate: '"} + *data + "'"};
448446
}
449-
m_x = value;
450-
return *this;
447+
return set_x(value);
451448
}
452449

453450
Location& set_lat(const char* str) {
@@ -456,18 +453,15 @@ namespace osmium {
456453
if (**data != '\0') {
457454
throw invalid_location{std::string{"characters after coordinate: '"} + *data + "'"};
458455
}
459-
m_y = value;
460-
return *this;
456+
return set_y(value);
461457
}
462458

463459
Location& set_lon_partial(const char** str) {
464-
m_x = detail::string_to_location_coordinate(str);
465-
return *this;
460+
return set_x(detail::string_to_location_coordinate(str));
466461
}
467462

468463
Location& set_lat_partial(const char** str) {
469-
m_y = detail::string_to_location_coordinate(str);
470-
return *this;
464+
return set_y(detail::string_to_location_coordinate(str));
471465
}
472466

473467
template <typename T>

0 commit comments

Comments
 (0)