Fix naming in FixedPointCoordinate

This commit is contained in:
Patrick Niklaus 2016-01-04 19:55:35 +01:00
parent 4312013552
commit 4f7369ed02
7 changed files with 14 additions and 24 deletions

View File

@ -270,7 +270,7 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
SimpleLogger().Write() << "number of geometries: " << m_coordinate_list->size(); SimpleLogger().Write() << "number of geometries: " << m_coordinate_list->size();
for (unsigned i = 0; i < m_coordinate_list->size(); ++i) for (unsigned i = 0; i < m_coordinate_list->size(); ++i)
{ {
if (!GetCoordinateOfNode(i).is_valid()) if (!GetCoordinateOfNode(i).IsValid())
{ {
SimpleLogger().Write() << "coordinate " << i << " not valid"; SimpleLogger().Write() << "coordinate " << i << " not valid";
} }

View File

@ -27,7 +27,7 @@ template <class DataFacadeT> class NearestPlugin final : public BasePlugin
{ {
// check number of parameters // check number of parameters
if (route_parameters.coordinates.empty() || if (route_parameters.coordinates.empty() ||
!route_parameters.coordinates.front().is_valid()) !route_parameters.coordinates.front().IsValid())
{ {
return Status::Error; return Status::Error;
} }

View File

@ -33,7 +33,7 @@ class BasePlugin
if (min > coordinates.size() || std::any_of(std::begin(coordinates), std::end(coordinates), if (min > coordinates.size() || std::any_of(std::begin(coordinates), std::end(coordinates),
[](const FixedPointCoordinate &coordinate) [](const FixedPointCoordinate &coordinate)
{ {
return !coordinate.is_valid(); return !coordinate.IsValid();
})) }))
{ {
return false; return false;

View File

@ -55,17 +55,11 @@ struct FixedPointCoordinate
"coordinate types incompatible"); "coordinate types incompatible");
} }
bool is_valid() const; bool IsValid() const;
bool operator==(const FixedPointCoordinate &other) const; bool operator==(const FixedPointCoordinate &other) const;
friend std::ostream &operator<<(std::ostream &out, const FixedPointCoordinate &coordinate);
double bearing(const FixedPointCoordinate &other) const;
void output(std::ostream &out) const;
}; };
inline std::ostream &operator<<(std::ostream &out_stream, FixedPointCoordinate const &coordinate) std::ostream &operator<<(std::ostream &out, const FixedPointCoordinate &coordinate);
{
coordinate.output(out_stream);
return out_stream;
}
#endif /* COORDINATE_HPP_ */ #endif /* COORDINATE_HPP_ */

View File

@ -65,12 +65,12 @@ bool PhantomNode::is_compressed() const { return (forward_offset != 0) || (rever
bool PhantomNode::is_valid(const unsigned number_of_nodes) const bool PhantomNode::is_valid(const unsigned number_of_nodes) const
{ {
return location.is_valid() && return location.IsValid() &&
((forward_node_id < number_of_nodes) || (reverse_node_id < number_of_nodes)) && ((forward_node_id < number_of_nodes) || (reverse_node_id < number_of_nodes)) &&
((forward_weight != INVALID_EDGE_WEIGHT) || (reverse_weight != INVALID_EDGE_WEIGHT)) && ((forward_weight != INVALID_EDGE_WEIGHT) || (reverse_weight != INVALID_EDGE_WEIGHT)) &&
(component.id != INVALID_COMPONENTID) && (name_id != INVALID_NAMEID); (component.id != INVALID_COMPONENTID) && (name_id != INVALID_NAMEID);
} }
bool PhantomNode::is_valid() const { return location.is_valid() && (name_id != INVALID_NAMEID); } bool PhantomNode::is_valid() const { return location.IsValid() && (name_id != INVALID_NAMEID); }
bool PhantomNode::operator==(const PhantomNode &other) const { return location == other.location; } bool PhantomNode::operator==(const PhantomNode &other) const { return location == other.location; }

View File

@ -34,7 +34,7 @@ FixedPointCoordinate::FixedPointCoordinate(int lat, int lon) : lat(lat), lon(lon
#endif #endif
} }
bool FixedPointCoordinate::is_valid() const bool FixedPointCoordinate::IsValid() const
{ {
return !(lat > 90 * COORDINATE_PRECISION || lat < -90 * COORDINATE_PRECISION || return !(lat > 90 * COORDINATE_PRECISION || lat < -90 * COORDINATE_PRECISION ||
lon > 180 * COORDINATE_PRECISION || lon < -180 * COORDINATE_PRECISION); lon > 180 * COORDINATE_PRECISION || lon < -180 * COORDINATE_PRECISION);
@ -45,12 +45,8 @@ bool FixedPointCoordinate::operator==(const FixedPointCoordinate &other) const
return lat == other.lat && lon == other.lon; return lat == other.lat && lon == other.lon;
} }
void FixedPointCoordinate::output(std::ostream &out) const std::ostream &operator<<(std::ostream &out, const FixedPointCoordinate &coordinate)
{ {
out << "(" << lat / COORDINATE_PRECISION << "," << lon / COORDINATE_PRECISION << ")"; out << "(" << static_cast<double>(coordinate.lat / COORDINATE_PRECISION) << "," << static_cast<double>(coordinate.lon / COORDINATE_PRECISION) << ")";
} return out;
double FixedPointCoordinate::bearing(const FixedPointCoordinate &other) const
{
return coordinate_calculation::bearing(other, *this);
} }

View File

@ -124,7 +124,7 @@ perpendicularDistanceFromProjectedCoordinate(const FixedPointCoordinate &segment
FixedPointCoordinate &nearest_location, FixedPointCoordinate &nearest_location,
double &ratio) double &ratio)
{ {
BOOST_ASSERT(query_location.is_valid()); BOOST_ASSERT(query_location.IsValid());
// initialize values // initialize values
const double x = projected_coordinate.first; const double x = projected_coordinate.first;
@ -188,7 +188,7 @@ perpendicularDistanceFromProjectedCoordinate(const FixedPointCoordinate &segment
nearest_location.lat = static_cast<int>(mercator::y2lat(p) * COORDINATE_PRECISION); nearest_location.lat = static_cast<int>(mercator::y2lat(p) * COORDINATE_PRECISION);
nearest_location.lon = static_cast<int>(q * COORDINATE_PRECISION); nearest_location.lon = static_cast<int>(q * COORDINATE_PRECISION);
} }
BOOST_ASSERT(nearest_location.is_valid()); BOOST_ASSERT(nearest_location.IsValid());
const double approximate_distance = greatCircleDistance(query_location, nearest_location); const double approximate_distance = greatCircleDistance(query_location, nearest_location);
BOOST_ASSERT(0.0 <= approximate_distance); BOOST_ASSERT(0.0 <= approximate_distance);