remove redundant local variable

This commit is contained in:
Dennis Luxen 2014-10-28 10:39:29 -04:00
parent 8a5538356b
commit b227c90c18
14 changed files with 43 additions and 40 deletions

View File

@ -72,7 +72,7 @@ bool FixedPointCoordinate::isSet() const
{
return (std::numeric_limits<int>::min() != lat) && (std::numeric_limits<int>::min() != lon);
}
bool FixedPointCoordinate::isValid() const
bool FixedPointCoordinate::is_valid() const
{
if (lat > 90 * COORDINATE_PRECISION || lat < -90 * COORDINATE_PRECISION ||
lon > 180 * COORDINATE_PRECISION || lon < -180 * COORDINATE_PRECISION)
@ -246,7 +246,7 @@ FixedPointCoordinate::ComputePerpendicularDistance(const FixedPointCoordinate &s
nearest_location.lon = static_cast<int>(q * COORDINATE_PRECISION);
}
BOOST_ASSERT(nearest_location.isValid());
BOOST_ASSERT(nearest_location.is_valid());
return FixedPointCoordinate::ApproximateEuclideanDistance(point, nearest_location);
}
@ -256,7 +256,7 @@ float FixedPointCoordinate::ComputePerpendicularDistance(const FixedPointCoordin
FixedPointCoordinate &nearest_location,
float &ratio)
{
BOOST_ASSERT(query_location.isValid());
BOOST_ASSERT(query_location.is_valid());
// initialize values
const double x = lat2y(query_location.lat / COORDINATE_PRECISION);
@ -319,7 +319,7 @@ float FixedPointCoordinate::ComputePerpendicularDistance(const FixedPointCoordin
nearest_location.lat = static_cast<int>(y2lat(p) * COORDINATE_PRECISION);
nearest_location.lon = static_cast<int>(q * COORDINATE_PRECISION);
}
BOOST_ASSERT(nearest_location.isValid());
BOOST_ASSERT(nearest_location.is_valid());
const float approximate_distance =
FixedPointCoordinate::ApproximateEuclideanDistance(query_location, nearest_location);

View File

@ -640,7 +640,7 @@ class StaticRTree
}
}
}
return result_coordinate.isValid();
return result_coordinate.is_valid();
}
// implementation of the Hjaltason/Samet query [3], a BFS traversal of the tree
@ -1097,7 +1097,7 @@ class StaticRTree
}
}
if (result_phantom_node.location.isValid())
if (result_phantom_node.location.is_valid())
{
// Hack to fix rounding errors and wandering via nodes.
FixUpRoundingIssue(input_coordinate, result_phantom_node);
@ -1105,7 +1105,7 @@ class StaticRTree
// set forward and reverse weights on the phantom node
SetForwardAndReverseWeightsOnPhantomNode(nearest_edge, result_phantom_node);
}
return result_phantom_node.location.isValid();
return result_phantom_node.location.is_valid();
}
private:
@ -1121,11 +1121,11 @@ class StaticRTree
if (SPECIAL_NODEID != result_phantom_node.forward_node_id)
{
result_phantom_node.forward_weight *= static_cast<decltype(result_phantom_node.forward_weight)>(ratio);
result_phantom_node.forward_weight *= ratio;
}
if (SPECIAL_NODEID != result_phantom_node.reverse_node_id)
{
result_phantom_node.reverse_weight *= static_cast<decltype(result_phantom_node.reverse_weight)>(1.f - ratio);
result_phantom_node.reverse_weight *= (1.f - ratio);
}
}

View File

@ -78,37 +78,37 @@ int PhantomNode::GetReverseWeightPlusOffset() const
return reverse_offset + reverse_weight;
}
bool PhantomNode::isBidirected() const
bool PhantomNode::is_bidirected() const
{
return (forward_node_id != SPECIAL_NODEID) &&
(reverse_node_id != SPECIAL_NODEID);
}
bool PhantomNode::IsCompressed() const
bool PhantomNode::is_compressed() const
{
return (forward_offset != 0) || (reverse_offset != 0);
}
bool PhantomNode::isValid(const unsigned numberOfNodes) const
bool PhantomNode::is_valid(const unsigned number_of_nodes) const
{
return
location.isValid() &&
location.is_valid() &&
(
(forward_node_id < numberOfNodes) ||
(reverse_node_id < numberOfNodes)
(forward_node_id < number_of_nodes) ||
(reverse_node_id < number_of_nodes)
) &&
(
(forward_weight != INVALID_EDGE_WEIGHT) ||
(reverse_weight != INVALID_EDGE_WEIGHT)
) &&
(name_id != std::numeric_limits<unsigned>::max()
(name_id != INVALID_NAMEID
);
}
bool PhantomNode::isValid() const
bool PhantomNode::is_valid() const
{
return location.isValid() &&
(name_id != std::numeric_limits<unsigned>::max());
return location.is_valid() &&
(name_id != INVALID_NAMEID);
}
bool PhantomNode::operator==(const PhantomNode & other) const

View File

@ -30,9 +30,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <osrm/Coordinate.h>
#include "../DataStructures/TravelMode.h"
#include "../Util/simple_logger.hpp"
#include "../typedefs.h"
#include <iostream>
#include <vector>
struct PhantomNode
@ -62,13 +62,13 @@ struct PhantomNode
int GetReverseWeightPlusOffset() const;
bool isBidirected() const;
bool is_bidirected() const;
bool IsCompressed() const;
bool is_compressed() const;
bool isValid(const unsigned numberOfNodes) const;
bool is_valid(const unsigned numberOfNodes) const;
bool isValid() const;
bool is_valid() const;
bool operator==(const PhantomNode & other) const;
};

View File

@ -37,6 +37,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../DataStructures/SegmentInformation.h"
#include "../DataStructures/TurnInstructions.h"
#include "../Util/Azimuth.h"
#include "../Util/simple_logger.hpp"
#include "../Util/StringUtil.h"
#include "../Util/TimingUtil.h"

View File

@ -32,8 +32,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <string>
#include <type_traits>
namespace
{
constexpr float COORDINATE_PRECISION = 1000000.f;
}
struct FixedPointCoordinate
{
int lat;
@ -51,7 +53,7 @@ struct FixedPointCoordinate
void Reset();
bool isSet() const;
bool isValid() const;
bool is_valid() const;
bool operator==(const FixedPointCoordinate &other) const;
static double

View File

@ -45,12 +45,12 @@ class BasePlugin
virtual void HandleRequest(const RouteParameters &routeParameters, http::Reply &reply) = 0;
virtual bool check_all_coordinates(const std::vector<FixedPointCoordinate> coordinates) const final
{
if (2 > coordinates.size() ||
if (2 > coordinates.size() ||
std::any_of(std::begin(coordinates),
std::end(coordinates),
[](const FixedPointCoordinate &coordinate)
{
return !coordinate.isValid();
return !coordinate.is_valid();
}))
{
return false;

View File

@ -81,7 +81,7 @@ template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin
{
PhantomNode current_phantom_node;
ObjectEncoder::DecodeFromBase64(route_parameters.hints[i], current_phantom_node);
if (current_phantom_node.isValid(facade->GetNumberOfNodes()))
if (current_phantom_node.is_valid(facade->GetNumberOfNodes()))
{
phantom_node_vector[i].emplace_back(std::move(current_phantom_node));
continue;
@ -92,7 +92,7 @@ template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin
route_parameters.zoom_level,
1);
BOOST_ASSERT(phantom_node_vector[i].front().isValid(facade->GetNumberOfNodes()));
BOOST_ASSERT(phantom_node_vector[i].front().is_valid(facade->GetNumberOfNodes()));
}
// TIMER_START(distance_table);

View File

@ -44,7 +44,7 @@ template <class DataFacadeT> class LocatePlugin final : public BasePlugin
void HandleRequest(const RouteParameters &route_parameters, http::Reply &reply) final
{
// check number of parameters
if (route_parameters.coordinates.empty() || !route_parameters.coordinates.front().isValid())
if (route_parameters.coordinates.empty() || !route_parameters.coordinates.front().is_valid())
{
reply = http::Reply::StockReply(http::Reply::badRequest);
return;

View File

@ -49,7 +49,7 @@ template <class DataFacadeT> class NearestPlugin final : public BasePlugin
void HandleRequest(const RouteParameters &route_parameters, http::Reply &reply) final
{
// check number of parameters
if (route_parameters.coordinates.empty() || !route_parameters.coordinates.front().isValid())
if (route_parameters.coordinates.empty() || !route_parameters.coordinates.front().is_valid())
{
reply = http::Reply::StockReply(http::Reply::badRequest);
return;
@ -62,7 +62,7 @@ template <class DataFacadeT> class NearestPlugin final : public BasePlugin
static_cast<int>(number_of_results));
JSON::Object json_result;
if (phantom_node_vector.empty() || !phantom_node_vector.front().isValid())
if (phantom_node_vector.empty() || !phantom_node_vector.front().is_valid())
{
json_result.values["status"] = 207;
}

View File

@ -86,7 +86,7 @@ template <class DataFacadeT> class ViaRoutePlugin final : public BasePlugin
!route_parameters.hints[i].empty())
{
ObjectEncoder::DecodeFromBase64(route_parameters.hints[i], phantom_node_vector[i]);
if (phantom_node_vector[i].isValid(facade->GetNumberOfNodes()))
if (phantom_node_vector[i].is_valid(facade->GetNumberOfNodes()))
{
continue;
}
@ -103,7 +103,7 @@ template <class DataFacadeT> class ViaRoutePlugin final : public BasePlugin
};
osrm::for_each_pair(phantom_node_vector, build_phantom_pairs);
if (route_parameters.alternate_route &&
if (route_parameters.alternate_route &&
1 == raw_route.segment_end_coordinates.size())
{
search_engine_ptr->alternative_path(

View File

@ -288,7 +288,7 @@ template <class DataFacadeT> class ShortestPathRouting final : public BasicRouti
BOOST_ASSERT(packed_legs2[current_leg].size() == temporary_packed_leg2.size());
if (!allow_u_turn && (packed_legs1[current_leg].back() == packed_legs2[current_leg].back()) &&
phantom_node_pair.target_phantom.isBidirected())
phantom_node_pair.target_phantom.is_bidirected())
{
const NodeID last_node_id = packed_legs2[current_leg].back();
search_from_1st_node &=

View File

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

View File

@ -74,7 +74,7 @@ class LinearSearchNN
}
result_coordinate = min_coord;
return result_coordinate.isValid();
return result_coordinate.is_valid();
}
bool FindPhantomNodeForCoordinate(const FixedPointCoordinate &input_coordinate,
@ -116,7 +116,7 @@ class LinearSearchNN
}
}
if (result_phantom_node.location.isValid())
if (result_phantom_node.location.is_valid())
{
// Hack to fix rounding errors and wandering via nodes.
if (1 == std::abs(input_coordinate.lon - result_phantom_node.location.lon))
@ -144,7 +144,7 @@ class LinearSearchNN
}
}
return result_phantom_node.location.isValid();
return result_phantom_node.location.is_valid();
}
private: