First round of lat,lng -> lng,lat switcheroo
This commit is contained in:
@@ -26,8 +26,7 @@ class BaseAPI
|
||||
{
|
||||
}
|
||||
|
||||
util::json::Array
|
||||
MakeWaypoints(const std::vector<PhantomNodes> &segment_end_coordinates) const
|
||||
util::json::Array MakeWaypoints(const std::vector<PhantomNodes> &segment_end_coordinates) const
|
||||
{
|
||||
BOOST_ASSERT(parameters.coordinates.size() > 0);
|
||||
BOOST_ASSERT(parameters.coordinates.size() == segment_end_coordinates.size() + 1);
|
||||
@@ -47,8 +46,8 @@ class BaseAPI
|
||||
}
|
||||
|
||||
protected:
|
||||
util::json::Object MakeWaypoint(const util::FixedPointCoordinate input_coordinate,
|
||||
const PhantomNode &phantom) const
|
||||
util::json::Object MakeWaypoint(const util::Coordinate input_coordinate,
|
||||
const PhantomNode &phantom) const
|
||||
{
|
||||
return json::makeWaypoint(phantom.location, facade.get_name_for_id(phantom.name_id),
|
||||
Hint{input_coordinate, phantom, facade.GetCheckSum()});
|
||||
|
||||
@@ -23,7 +23,7 @@ struct BaseParameters
|
||||
short range;
|
||||
};
|
||||
|
||||
std::vector<util::FixedPointCoordinate> coordinates;
|
||||
std::vector<util::Coordinate> coordinates;
|
||||
std::vector<boost::optional<Hint>> hints;
|
||||
std::vector<boost::optional<double>> radiuses;
|
||||
std::vector<boost::optional<Bearing>> bearings;
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace detail
|
||||
|
||||
std::string instructionToString(extractor::TurnInstruction instruction);
|
||||
|
||||
util::json::Array coordinateToLonLat(const FixedPointCoordinate &coordinate);
|
||||
util::json::Array coordinateToLonLat(const util::Coordinate &coordinate);
|
||||
|
||||
std::string modeToString(const extractor::TravelMode mode);
|
||||
|
||||
@@ -58,7 +58,7 @@ util::json::Object makeGeoJSONLineString(ForwardIter begin, ForwardIter end)
|
||||
geojson.values["type"] = "LineString";
|
||||
util::json::Array coordinates;
|
||||
std::transform(begin, end, std::back_inserter(coordinates.values),
|
||||
[](const util::FixedPointCoordinate loc)
|
||||
[](const util::Coordinate loc)
|
||||
{
|
||||
return detail::coordinateToLonLat(loc);
|
||||
});
|
||||
@@ -76,7 +76,7 @@ util::json::Object makeRoute(const guidance::Route &route,
|
||||
boost::optional<util::json::Value> geometry);
|
||||
|
||||
util::json::Object
|
||||
makeWaypoint(const FixedPointCoordinate location, std::string &&name, const Hint &hint);
|
||||
makeWaypoint(const util::Coordinate location, std::string &&name, const Hint &hint);
|
||||
|
||||
util::json::Object makeRouteLeg(guidance::RouteLeg &&leg, util::json::Array &&steps);
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ class BaseDataFacade
|
||||
FindEdgeIndicateIfReverse(const NodeID from, const NodeID to, bool &result) const = 0;
|
||||
|
||||
// node and edge information access
|
||||
virtual util::FixedPointCoordinate GetCoordinateOfNode(const unsigned id) const = 0;
|
||||
virtual util::Coordinate GetCoordinateOfNode(const unsigned id) const = 0;
|
||||
|
||||
virtual unsigned GetGeometryIndexForEdgeID(const unsigned id) const = 0;
|
||||
|
||||
@@ -80,49 +80,48 @@ class BaseDataFacade
|
||||
|
||||
virtual extractor::TravelMode GetTravelModeForEdgeID(const unsigned id) const = 0;
|
||||
|
||||
virtual std::vector<RTreeLeaf> GetEdgesInBox(const util::FixedPointCoordinate &south_west,
|
||||
const util::FixedPointCoordinate &north_east) = 0;
|
||||
virtual std::vector<RTreeLeaf> GetEdgesInBox(const util::Coordinate south_west,
|
||||
const util::Coordinate north_east) = 0;
|
||||
|
||||
virtual std::vector<PhantomNodeWithDistance>
|
||||
NearestPhantomNodesInRange(const util::FixedPointCoordinate input_coordinate,
|
||||
NearestPhantomNodesInRange(const util::Coordinate input_coordinate,
|
||||
const float max_distance,
|
||||
const int bearing,
|
||||
const int bearing_range) = 0;
|
||||
virtual std::vector<PhantomNodeWithDistance>
|
||||
NearestPhantomNodesInRange(const util::FixedPointCoordinate input_coordinate,
|
||||
NearestPhantomNodesInRange(const util::Coordinate input_coordinate,
|
||||
const float max_distance) = 0;
|
||||
|
||||
virtual std::vector<PhantomNodeWithDistance>
|
||||
NearestPhantomNodes(const util::FixedPointCoordinate input_coordinate,
|
||||
NearestPhantomNodes(const util::Coordinate input_coordinate,
|
||||
const unsigned max_results,
|
||||
const double max_distance,
|
||||
const int bearing,
|
||||
const int bearing_range) = 0;
|
||||
virtual std::vector<PhantomNodeWithDistance>
|
||||
NearestPhantomNodes(const util::FixedPointCoordinate input_coordinate,
|
||||
NearestPhantomNodes(const util::Coordinate input_coordinate,
|
||||
const unsigned max_results,
|
||||
const int bearing,
|
||||
const int bearing_range) = 0;
|
||||
virtual std::vector<PhantomNodeWithDistance>
|
||||
NearestPhantomNodes(const util::FixedPointCoordinate input_coordinate,
|
||||
const unsigned max_results) = 0;
|
||||
NearestPhantomNodes(const util::Coordinate input_coordinate, const unsigned max_results) = 0;
|
||||
virtual std::vector<PhantomNodeWithDistance>
|
||||
NearestPhantomNodes(const util::FixedPointCoordinate input_coordinate,
|
||||
const unsigned max_results, const double max_distance) = 0;
|
||||
NearestPhantomNodes(const util::Coordinate input_coordinate,
|
||||
const unsigned max_results,
|
||||
const double max_distance) = 0;
|
||||
|
||||
virtual std::pair<PhantomNode, PhantomNode>
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate) = 0;
|
||||
virtual std::pair<PhantomNode, PhantomNode>
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
|
||||
const double max_distance) = 0;
|
||||
virtual std::pair<PhantomNode, PhantomNode>
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
|
||||
const double max_distance,
|
||||
const int bearing,
|
||||
const int bearing_range) = 0;
|
||||
virtual std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
const util::FixedPointCoordinate input_coordinate) = 0;
|
||||
virtual std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
const util::FixedPointCoordinate input_coordinate, const double max_distance) = 0;
|
||||
virtual std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
const util::FixedPointCoordinate input_coordinate,
|
||||
const double max_distance,
|
||||
const int bearing,
|
||||
const int bearing_range) = 0;
|
||||
virtual std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
const util::FixedPointCoordinate input_coordinate,
|
||||
const int bearing,
|
||||
const int bearing_range) = 0;
|
||||
const util::Coordinate input_coordinate, const int bearing, const int bearing_range) = 0;
|
||||
|
||||
virtual unsigned GetCheckSum() const = 0;
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ class InternalDataFacade final : public BaseDataFacade
|
||||
using InputEdge = typename QueryGraph::InputEdge;
|
||||
using RTreeLeaf = typename super::RTreeLeaf;
|
||||
using InternalRTree =
|
||||
util::StaticRTree<RTreeLeaf, util::ShM<util::FixedPointCoordinate, false>::vector, false>;
|
||||
util::StaticRTree<RTreeLeaf, util::ShM<util::Coordinate, false>::vector, false>;
|
||||
using InternalGeospatialQuery = GeospatialQuery<InternalRTree, BaseDataFacade>;
|
||||
|
||||
InternalDataFacade() {}
|
||||
@@ -65,7 +65,7 @@ class InternalDataFacade final : public BaseDataFacade
|
||||
std::unique_ptr<QueryGraph> m_query_graph;
|
||||
std::string m_timestamp;
|
||||
|
||||
std::shared_ptr<util::ShM<util::FixedPointCoordinate, false>::vector> m_coordinate_list;
|
||||
std::shared_ptr<util::ShM<util::Coordinate, false>::vector> m_coordinate_list;
|
||||
util::ShM<NodeID, false>::vector m_via_node_list;
|
||||
util::ShM<unsigned, false>::vector m_name_ID_list;
|
||||
util::ShM<extractor::TurnInstruction, false>::vector m_turn_instruction_list;
|
||||
@@ -132,15 +132,12 @@ class InternalDataFacade final : public BaseDataFacade
|
||||
extractor::QueryNode current_node;
|
||||
unsigned number_of_coordinates = 0;
|
||||
nodes_input_stream.read((char *)&number_of_coordinates, sizeof(unsigned));
|
||||
m_coordinate_list =
|
||||
std::make_shared<std::vector<util::FixedPointCoordinate>>(number_of_coordinates);
|
||||
m_coordinate_list = std::make_shared<std::vector<util::Coordinate>>(number_of_coordinates);
|
||||
for (unsigned i = 0; i < number_of_coordinates; ++i)
|
||||
{
|
||||
nodes_input_stream.read((char *)¤t_node, sizeof(extractor::QueryNode));
|
||||
m_coordinate_list->at(i) =
|
||||
util::FixedPointCoordinate(current_node.lat, current_node.lon);
|
||||
BOOST_ASSERT((std::abs(m_coordinate_list->at(i).lat) >> 30) == 0);
|
||||
BOOST_ASSERT((std::abs(m_coordinate_list->at(i).lon) >> 30) == 0);
|
||||
m_coordinate_list->at(i) = util::Coordinate(current_node.lon, current_node.lat);
|
||||
BOOST_ASSERT(m_coordinate_list->at(i).IsValid());
|
||||
}
|
||||
|
||||
boost::filesystem::ifstream edges_input_stream(edges_file, std::ios::binary);
|
||||
@@ -325,7 +322,7 @@ class InternalDataFacade final : public BaseDataFacade
|
||||
}
|
||||
|
||||
// node and edge information access
|
||||
util::FixedPointCoordinate GetCoordinateOfNode(const unsigned id) const override final
|
||||
util::Coordinate GetCoordinateOfNode(const unsigned id) const override final
|
||||
{
|
||||
return m_coordinate_list->at(id);
|
||||
}
|
||||
@@ -340,22 +337,21 @@ class InternalDataFacade final : public BaseDataFacade
|
||||
return m_travel_mode_list.at(id);
|
||||
}
|
||||
|
||||
std::vector<RTreeLeaf>
|
||||
GetEdgesInBox(const util::FixedPointCoordinate &south_west,
|
||||
const util::FixedPointCoordinate &north_east) override final
|
||||
std::vector<RTreeLeaf> GetEdgesInBox(const util::Coordinate south_west,
|
||||
const util::Coordinate north_east) override final
|
||||
{
|
||||
if (!m_static_rtree.get())
|
||||
{
|
||||
LoadRTree();
|
||||
BOOST_ASSERT(m_geospatial_query.get());
|
||||
}
|
||||
const util::RectangleInt2D bbox{
|
||||
south_west.lon, north_east.lon, south_west.lat, north_east.lat};
|
||||
const util::RectangleInt2D bbox{south_west.lon, north_east.lon, south_west.lat,
|
||||
north_east.lat};
|
||||
return m_geospatial_query->Search(bbox);
|
||||
}
|
||||
|
||||
std::vector<PhantomNodeWithDistance>
|
||||
NearestPhantomNodesInRange(const util::FixedPointCoordinate input_coordinate,
|
||||
NearestPhantomNodesInRange(const util::Coordinate input_coordinate,
|
||||
const float max_distance) override final
|
||||
{
|
||||
if (!m_static_rtree.get())
|
||||
@@ -368,7 +364,7 @@ class InternalDataFacade final : public BaseDataFacade
|
||||
}
|
||||
|
||||
std::vector<PhantomNodeWithDistance>
|
||||
NearestPhantomNodesInRange(const util::FixedPointCoordinate input_coordinate,
|
||||
NearestPhantomNodesInRange(const util::Coordinate input_coordinate,
|
||||
const float max_distance,
|
||||
const int bearing,
|
||||
const int bearing_range) override final
|
||||
@@ -384,7 +380,7 @@ class InternalDataFacade final : public BaseDataFacade
|
||||
}
|
||||
|
||||
std::vector<PhantomNodeWithDistance>
|
||||
NearestPhantomNodes(const util::FixedPointCoordinate input_coordinate,
|
||||
NearestPhantomNodes(const util::Coordinate input_coordinate,
|
||||
const unsigned max_results) override final
|
||||
{
|
||||
if (!m_static_rtree.get())
|
||||
@@ -397,7 +393,7 @@ class InternalDataFacade final : public BaseDataFacade
|
||||
}
|
||||
|
||||
std::vector<PhantomNodeWithDistance>
|
||||
NearestPhantomNodes(const util::FixedPointCoordinate input_coordinate,
|
||||
NearestPhantomNodes(const util::Coordinate input_coordinate,
|
||||
const unsigned max_results,
|
||||
const double max_distance) override final
|
||||
{
|
||||
@@ -411,7 +407,7 @@ class InternalDataFacade final : public BaseDataFacade
|
||||
}
|
||||
|
||||
std::vector<PhantomNodeWithDistance>
|
||||
NearestPhantomNodes(const util::FixedPointCoordinate input_coordinate,
|
||||
NearestPhantomNodes(const util::Coordinate input_coordinate,
|
||||
const unsigned max_results,
|
||||
const int bearing,
|
||||
const int bearing_range) override final
|
||||
@@ -427,7 +423,7 @@ class InternalDataFacade final : public BaseDataFacade
|
||||
}
|
||||
|
||||
std::vector<PhantomNodeWithDistance>
|
||||
NearestPhantomNodes(const util::FixedPointCoordinate input_coordinate,
|
||||
NearestPhantomNodes(const util::Coordinate input_coordinate,
|
||||
const unsigned max_results,
|
||||
const double max_distance,
|
||||
const int bearing,
|
||||
@@ -443,8 +439,9 @@ class InternalDataFacade final : public BaseDataFacade
|
||||
bearing, bearing_range);
|
||||
}
|
||||
|
||||
std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
const util::FixedPointCoordinate input_coordinate, const double max_distance) override final
|
||||
std::pair<PhantomNode, PhantomNode>
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
|
||||
const double max_distance) override final
|
||||
{
|
||||
if (!m_static_rtree.get())
|
||||
{
|
||||
@@ -457,7 +454,7 @@ class InternalDataFacade final : public BaseDataFacade
|
||||
}
|
||||
|
||||
std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
const util::FixedPointCoordinate input_coordinate) override final
|
||||
const util::Coordinate input_coordinate) override final
|
||||
{
|
||||
if (!m_static_rtree.get())
|
||||
{
|
||||
@@ -469,11 +466,11 @@ class InternalDataFacade final : public BaseDataFacade
|
||||
input_coordinate);
|
||||
}
|
||||
|
||||
std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
const util::FixedPointCoordinate input_coordinate,
|
||||
const double max_distance,
|
||||
const int bearing,
|
||||
const int bearing_range) override final
|
||||
std::pair<PhantomNode, PhantomNode>
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
|
||||
const double max_distance,
|
||||
const int bearing,
|
||||
const int bearing_range) override final
|
||||
{
|
||||
if (!m_static_rtree.get())
|
||||
{
|
||||
@@ -485,10 +482,10 @@ class InternalDataFacade final : public BaseDataFacade
|
||||
input_coordinate, max_distance, bearing, bearing_range);
|
||||
}
|
||||
|
||||
std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
const util::FixedPointCoordinate input_coordinate,
|
||||
const int bearing,
|
||||
const int bearing_range) override final
|
||||
std::pair<PhantomNode, PhantomNode>
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
|
||||
const int bearing,
|
||||
const int bearing_range) override final
|
||||
{
|
||||
if (!m_static_rtree.get())
|
||||
{
|
||||
|
||||
@@ -48,7 +48,7 @@ class SharedDataFacade final : public BaseDataFacade
|
||||
using InputEdge = typename QueryGraph::InputEdge;
|
||||
using RTreeLeaf = typename super::RTreeLeaf;
|
||||
using SharedRTree =
|
||||
util::StaticRTree<RTreeLeaf, util::ShM<util::FixedPointCoordinate, true>::vector, true>;
|
||||
util::StaticRTree<RTreeLeaf, util::ShM<util::Coordinate, true>::vector, true>;
|
||||
using SharedGeospatialQuery = GeospatialQuery<SharedRTree, BaseDataFacade>;
|
||||
using TimeStampedRTreePair = std::pair<unsigned, std::shared_ptr<SharedRTree>>;
|
||||
using RTreeNode = typename SharedRTree::TreeNode;
|
||||
@@ -67,7 +67,7 @@ class SharedDataFacade final : public BaseDataFacade
|
||||
std::unique_ptr<storage::SharedMemory> m_large_memory;
|
||||
std::string m_timestamp;
|
||||
|
||||
std::shared_ptr<util::ShM<util::FixedPointCoordinate, true>::vector> m_coordinate_list;
|
||||
std::shared_ptr<util::ShM<util::Coordinate, true>::vector> m_coordinate_list;
|
||||
util::ShM<NodeID, true>::vector m_via_node_list;
|
||||
util::ShM<unsigned, true>::vector m_name_ID_list;
|
||||
util::ShM<extractor::TurnInstruction, true>::vector m_turn_instruction_list;
|
||||
@@ -133,9 +133,9 @@ class SharedDataFacade final : public BaseDataFacade
|
||||
|
||||
void LoadNodeAndEdgeInformation()
|
||||
{
|
||||
auto coordinate_list_ptr = data_layout->GetBlockPtr<util::FixedPointCoordinate>(
|
||||
auto coordinate_list_ptr = data_layout->GetBlockPtr<util::Coordinate>(
|
||||
shared_memory, storage::SharedDataLayout::COORDINATE_LIST);
|
||||
m_coordinate_list = util::make_unique<util::ShM<util::FixedPointCoordinate, true>::vector>(
|
||||
m_coordinate_list = util::make_unique<util::ShM<util::Coordinate, true>::vector>(
|
||||
coordinate_list_ptr,
|
||||
data_layout->num_entries[storage::SharedDataLayout::COORDINATE_LIST]);
|
||||
|
||||
@@ -365,7 +365,7 @@ class SharedDataFacade final : public BaseDataFacade
|
||||
}
|
||||
|
||||
// node and edge information access
|
||||
util::FixedPointCoordinate GetCoordinateOfNode(const NodeID id) const override final
|
||||
util::Coordinate GetCoordinateOfNode(const NodeID id) const override final
|
||||
{
|
||||
return m_coordinate_list->at(id);
|
||||
}
|
||||
@@ -408,22 +408,21 @@ class SharedDataFacade final : public BaseDataFacade
|
||||
return m_travel_mode_list.at(id);
|
||||
}
|
||||
|
||||
std::vector<RTreeLeaf>
|
||||
GetEdgesInBox(const util::FixedPointCoordinate &south_west,
|
||||
const util::FixedPointCoordinate &north_east) override final
|
||||
std::vector<RTreeLeaf> GetEdgesInBox(const util::Coordinate south_west,
|
||||
const util::Coordinate north_east) override final
|
||||
{
|
||||
if (!m_static_rtree.get() || CURRENT_TIMESTAMP != m_static_rtree->first)
|
||||
{
|
||||
LoadRTree();
|
||||
BOOST_ASSERT(m_geospatial_query.get());
|
||||
}
|
||||
const util::RectangleInt2D bbox{
|
||||
south_west.lon, north_east.lon, south_west.lat, north_east.lat};
|
||||
const util::RectangleInt2D bbox{south_west.lon, north_east.lon, south_west.lat,
|
||||
north_east.lat};
|
||||
return m_geospatial_query->Search(bbox);
|
||||
}
|
||||
|
||||
std::vector<PhantomNodeWithDistance>
|
||||
NearestPhantomNodesInRange(const util::FixedPointCoordinate input_coordinate,
|
||||
NearestPhantomNodesInRange(const util::Coordinate input_coordinate,
|
||||
const float max_distance) override final
|
||||
{
|
||||
if (!m_static_rtree.get() || CURRENT_TIMESTAMP != m_static_rtree->first)
|
||||
@@ -436,7 +435,7 @@ class SharedDataFacade final : public BaseDataFacade
|
||||
}
|
||||
|
||||
std::vector<PhantomNodeWithDistance>
|
||||
NearestPhantomNodesInRange(const util::FixedPointCoordinate input_coordinate,
|
||||
NearestPhantomNodesInRange(const util::Coordinate input_coordinate,
|
||||
const float max_distance,
|
||||
const int bearing,
|
||||
const int bearing_range) override final
|
||||
@@ -452,7 +451,7 @@ class SharedDataFacade final : public BaseDataFacade
|
||||
}
|
||||
|
||||
std::vector<PhantomNodeWithDistance>
|
||||
NearestPhantomNodes(const util::FixedPointCoordinate input_coordinate,
|
||||
NearestPhantomNodes(const util::Coordinate input_coordinate,
|
||||
const unsigned max_results) override final
|
||||
{
|
||||
if (!m_static_rtree.get() || CURRENT_TIMESTAMP != m_static_rtree->first)
|
||||
@@ -465,7 +464,7 @@ class SharedDataFacade final : public BaseDataFacade
|
||||
}
|
||||
|
||||
std::vector<PhantomNodeWithDistance>
|
||||
NearestPhantomNodes(const util::FixedPointCoordinate input_coordinate,
|
||||
NearestPhantomNodes(const util::Coordinate input_coordinate,
|
||||
const unsigned max_results,
|
||||
const double max_distance) override final
|
||||
{
|
||||
@@ -479,7 +478,7 @@ class SharedDataFacade final : public BaseDataFacade
|
||||
}
|
||||
|
||||
std::vector<PhantomNodeWithDistance>
|
||||
NearestPhantomNodes(const util::FixedPointCoordinate input_coordinate,
|
||||
NearestPhantomNodes(const util::Coordinate input_coordinate,
|
||||
const unsigned max_results,
|
||||
const int bearing,
|
||||
const int bearing_range) override final
|
||||
@@ -495,7 +494,7 @@ class SharedDataFacade final : public BaseDataFacade
|
||||
}
|
||||
|
||||
std::vector<PhantomNodeWithDistance>
|
||||
NearestPhantomNodes(const util::FixedPointCoordinate input_coordinate,
|
||||
NearestPhantomNodes(const util::Coordinate input_coordinate,
|
||||
const unsigned max_results,
|
||||
const double max_distance,
|
||||
const int bearing,
|
||||
@@ -512,7 +511,7 @@ class SharedDataFacade final : public BaseDataFacade
|
||||
}
|
||||
|
||||
std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
const util::FixedPointCoordinate input_coordinate) override final
|
||||
const util::Coordinate input_coordinate) override final
|
||||
{
|
||||
if (!m_static_rtree.get() || CURRENT_TIMESTAMP != m_static_rtree->first)
|
||||
{
|
||||
@@ -524,8 +523,9 @@ class SharedDataFacade final : public BaseDataFacade
|
||||
input_coordinate);
|
||||
}
|
||||
|
||||
std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
const util::FixedPointCoordinate input_coordinate, const double max_distance) override final
|
||||
std::pair<PhantomNode, PhantomNode>
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
|
||||
const double max_distance) override final
|
||||
{
|
||||
if (!m_static_rtree.get() || CURRENT_TIMESTAMP != m_static_rtree->first)
|
||||
{
|
||||
@@ -537,11 +537,11 @@ class SharedDataFacade final : public BaseDataFacade
|
||||
input_coordinate, max_distance);
|
||||
}
|
||||
|
||||
std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
const util::FixedPointCoordinate input_coordinate,
|
||||
const double max_distance,
|
||||
const int bearing,
|
||||
const int bearing_range) override final
|
||||
std::pair<PhantomNode, PhantomNode>
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
|
||||
const double max_distance,
|
||||
const int bearing,
|
||||
const int bearing_range) override final
|
||||
{
|
||||
if (!m_static_rtree.get() || CURRENT_TIMESTAMP != m_static_rtree->first)
|
||||
{
|
||||
@@ -553,10 +553,10 @@ class SharedDataFacade final : public BaseDataFacade
|
||||
input_coordinate, max_distance, bearing, bearing_range);
|
||||
}
|
||||
|
||||
std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
const util::FixedPointCoordinate input_coordinate,
|
||||
const int bearing,
|
||||
const int bearing_range) override final
|
||||
std::pair<PhantomNode, PhantomNode>
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
|
||||
const int bearing,
|
||||
const int bearing_range) override final
|
||||
{
|
||||
if (!m_static_rtree.get() || CURRENT_TIMESTAMP != m_static_rtree->first)
|
||||
{
|
||||
|
||||
@@ -44,14 +44,13 @@ const constexpr auto DOUGLAS_PEUCKER_THRESHOLDS_SIZE =
|
||||
// Input is vector of pairs. Each pair consists of the point information and a
|
||||
// bit indicating if the points is present in the generalization.
|
||||
// Note: points may also be pre-selected*/
|
||||
std::vector<util::FixedPointCoordinate>
|
||||
douglasPeucker(std::vector<util::FixedPointCoordinate>::const_iterator begin,
|
||||
std::vector<util::FixedPointCoordinate>::const_iterator end,
|
||||
const unsigned zoom_level);
|
||||
std::vector<util::Coordinate> douglasPeucker(std::vector<util::Coordinate>::const_iterator begin,
|
||||
std::vector<util::Coordinate>::const_iterator end,
|
||||
const unsigned zoom_level);
|
||||
|
||||
// Convenience range-based function
|
||||
inline std::vector<util::FixedPointCoordinate>
|
||||
douglasPeucker(const std::vector<util::FixedPointCoordinate> &geometry, const unsigned zoom_level)
|
||||
inline std::vector<util::Coordinate> douglasPeucker(const std::vector<util::Coordinate> &geometry,
|
||||
const unsigned zoom_level)
|
||||
{
|
||||
return douglasPeucker(begin(geometry), end(geometry), zoom_level);
|
||||
}
|
||||
|
||||
@@ -41,16 +41,17 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
// Returns nearest PhantomNodes in the given bearing range within max_distance.
|
||||
// Does not filter by small/big component!
|
||||
std::vector<PhantomNodeWithDistance>
|
||||
NearestPhantomNodesInRange(const util::FixedPointCoordinate input_coordinate,
|
||||
const double max_distance)
|
||||
NearestPhantomNodesInRange(const util::Coordinate input_coordinate, const double max_distance)
|
||||
{
|
||||
auto results =
|
||||
rtree.Nearest(input_coordinate,
|
||||
[] (const EdgeData &) { return std::make_pair(true, true); },
|
||||
[max_distance](const std::size_t, const double min_dist)
|
||||
{
|
||||
return min_dist > max_distance;
|
||||
});
|
||||
auto results = rtree.Nearest(input_coordinate,
|
||||
[](const EdgeData &)
|
||||
{
|
||||
return std::make_pair(true, true);
|
||||
},
|
||||
[max_distance](const std::size_t, const double min_dist)
|
||||
{
|
||||
return min_dist > max_distance;
|
||||
});
|
||||
|
||||
return MakePhantomNodes(input_coordinate, results);
|
||||
}
|
||||
@@ -58,7 +59,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
// Returns nearest PhantomNodes in the given bearing range within max_distance.
|
||||
// Does not filter by small/big component!
|
||||
std::vector<PhantomNodeWithDistance>
|
||||
NearestPhantomNodesInRange(const util::FixedPointCoordinate input_coordinate,
|
||||
NearestPhantomNodesInRange(const util::Coordinate input_coordinate,
|
||||
const double max_distance,
|
||||
const int bearing,
|
||||
const int bearing_range)
|
||||
@@ -80,7 +81,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
// Returns max_results nearest PhantomNodes in the given bearing range.
|
||||
// Does not filter by small/big component!
|
||||
std::vector<PhantomNodeWithDistance>
|
||||
NearestPhantomNodes(const util::FixedPointCoordinate input_coordinate,
|
||||
NearestPhantomNodes(const util::Coordinate input_coordinate,
|
||||
const unsigned max_results,
|
||||
const int bearing,
|
||||
const int bearing_range)
|
||||
@@ -98,24 +99,26 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
return MakePhantomNodes(input_coordinate, results);
|
||||
}
|
||||
|
||||
// Returns max_results nearest PhantomNodes in the given bearing range within the maximum distance.
|
||||
// Returns max_results nearest PhantomNodes in the given bearing range within the maximum
|
||||
// distance.
|
||||
// Does not filter by small/big component!
|
||||
std::vector<PhantomNodeWithDistance>
|
||||
NearestPhantomNodes(const util::FixedPointCoordinate input_coordinate,
|
||||
NearestPhantomNodes(const util::Coordinate input_coordinate,
|
||||
const unsigned max_results,
|
||||
const double max_distance,
|
||||
const int bearing,
|
||||
const int bearing_range)
|
||||
{
|
||||
auto results = rtree.Nearest(input_coordinate,
|
||||
[this, bearing, bearing_range](const EdgeData &data)
|
||||
{
|
||||
return checkSegmentBearing(data, bearing, bearing_range);
|
||||
},
|
||||
[max_results, max_distance](const std::size_t num_results, const double min_dist)
|
||||
{
|
||||
return num_results >= max_results || min_dist > max_distance;
|
||||
});
|
||||
auto results = rtree.Nearest(
|
||||
input_coordinate,
|
||||
[this, bearing, bearing_range](const EdgeData &data)
|
||||
{
|
||||
return checkSegmentBearing(data, bearing, bearing_range);
|
||||
},
|
||||
[max_results, max_distance](const std::size_t num_results, const double min_dist)
|
||||
{
|
||||
return num_results >= max_results || min_dist > max_distance;
|
||||
});
|
||||
|
||||
return MakePhantomNodes(input_coordinate, results);
|
||||
}
|
||||
@@ -123,8 +126,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
// Returns max_results nearest PhantomNodes.
|
||||
// Does not filter by small/big component!
|
||||
std::vector<PhantomNodeWithDistance>
|
||||
NearestPhantomNodes(const util::FixedPointCoordinate input_coordinate,
|
||||
const unsigned max_results)
|
||||
NearestPhantomNodes(const util::Coordinate input_coordinate, const unsigned max_results)
|
||||
{
|
||||
auto results = rtree.Nearest(input_coordinate,
|
||||
[](const EdgeData &)
|
||||
@@ -142,27 +144,29 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
// Returns max_results nearest PhantomNodes in the given max distance.
|
||||
// Does not filter by small/big component!
|
||||
std::vector<PhantomNodeWithDistance>
|
||||
NearestPhantomNodes(const util::FixedPointCoordinate input_coordinate,
|
||||
NearestPhantomNodes(const util::Coordinate input_coordinate,
|
||||
const unsigned max_results,
|
||||
const double max_distance)
|
||||
{
|
||||
auto results = rtree.Nearest(input_coordinate,
|
||||
[](const EdgeData &)
|
||||
{
|
||||
return std::make_pair(true, true);
|
||||
},
|
||||
[max_results, max_distance](const std::size_t num_results, const double min_dist)
|
||||
{
|
||||
return num_results >= max_results || min_dist > max_distance;
|
||||
});
|
||||
auto results = rtree.Nearest(
|
||||
input_coordinate,
|
||||
[](const EdgeData &)
|
||||
{
|
||||
return std::make_pair(true, true);
|
||||
},
|
||||
[max_results, max_distance](const std::size_t num_results, const double min_dist)
|
||||
{
|
||||
return num_results >= max_results || min_dist > max_distance;
|
||||
});
|
||||
|
||||
return MakePhantomNodes(input_coordinate, results);
|
||||
}
|
||||
|
||||
// Returns the nearest phantom node. If this phantom node is not from a big component
|
||||
// a second phantom node is return that is the nearest coordinate in a big component.
|
||||
std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
const util::FixedPointCoordinate input_coordinate, const double max_distance)
|
||||
std::pair<PhantomNode, PhantomNode>
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
|
||||
const double max_distance)
|
||||
{
|
||||
bool has_small_component = false;
|
||||
bool has_big_component = false;
|
||||
@@ -196,8 +200,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
|
||||
// Returns the nearest phantom node. If this phantom node is not from a big component
|
||||
// a second phantom node is return that is the nearest coordinate in a big component.
|
||||
std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
const util::FixedPointCoordinate input_coordinate)
|
||||
std::pair<PhantomNode, PhantomNode>
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate)
|
||||
{
|
||||
bool has_small_component = false;
|
||||
bool has_big_component = false;
|
||||
@@ -232,9 +236,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
// Returns the nearest phantom node. If this phantom node is not from a big component
|
||||
// a second phantom node is return that is the nearest coordinate in a big component.
|
||||
std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
const util::FixedPointCoordinate input_coordinate,
|
||||
const int bearing,
|
||||
const int bearing_range)
|
||||
const util::Coordinate input_coordinate, const int bearing, const int bearing_range)
|
||||
{
|
||||
bool has_small_component = false;
|
||||
bool has_big_component = false;
|
||||
@@ -276,11 +278,11 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
|
||||
// Returns the nearest phantom node. If this phantom node is not from a big component
|
||||
// a second phantom node is return that is the nearest coordinate in a big component.
|
||||
std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
|
||||
const util::FixedPointCoordinate input_coordinate,
|
||||
const double max_distance,
|
||||
const int bearing,
|
||||
const int bearing_range)
|
||||
std::pair<PhantomNode, PhantomNode>
|
||||
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
|
||||
const double max_distance,
|
||||
const int bearing,
|
||||
const int bearing_range)
|
||||
{
|
||||
bool has_small_component = false;
|
||||
bool has_big_component = false;
|
||||
@@ -322,7 +324,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
|
||||
private:
|
||||
std::vector<PhantomNodeWithDistance>
|
||||
MakePhantomNodes(const util::FixedPointCoordinate input_coordinate,
|
||||
MakePhantomNodes(const util::Coordinate input_coordinate,
|
||||
const std::vector<EdgeData> &results) const
|
||||
{
|
||||
std::vector<PhantomNodeWithDistance> distance_and_phantoms(results.size());
|
||||
@@ -334,10 +336,10 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
|
||||
return distance_and_phantoms;
|
||||
}
|
||||
|
||||
PhantomNodeWithDistance MakePhantomNode(const util::FixedPointCoordinate input_coordinate,
|
||||
PhantomNodeWithDistance MakePhantomNode(const util::Coordinate input_coordinate,
|
||||
const EdgeData &data) const
|
||||
{
|
||||
util::FixedPointCoordinate point_on_segment;
|
||||
util::Coordinate point_on_segment;
|
||||
double ratio;
|
||||
const auto current_perpendicular_distance =
|
||||
util::coordinate_calculation::perpendicularDistance(
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include "engine/guidance/leg_geometry.hpp"
|
||||
|
||||
#include "util/coordinate.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
@@ -12,8 +14,8 @@ namespace engine
|
||||
namespace guidance
|
||||
{
|
||||
|
||||
std::vector<util::FixedPointCoordinate>
|
||||
assembleOverview(const std::vector<LegGeometry> &leg_geometries, const bool use_simplification);
|
||||
std::vector<util::Coordinate> assembleOverview(const std::vector<LegGeometry> &leg_geometries,
|
||||
const bool use_simplification);
|
||||
|
||||
} // namespace guidance
|
||||
} // namespace engine
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace guidance
|
||||
// offsets 0 2 n-1 n
|
||||
struct LegGeometry
|
||||
{
|
||||
std::vector<util::FixedPointCoordinate> locations;
|
||||
std::vector<util::Coordinate> locations;
|
||||
// segment_offset[i] .. segment_offset[i+1] (inclusive)
|
||||
// contains the geometry of segment i
|
||||
std::vector<std::size_t> segment_offsets;
|
||||
@@ -45,7 +45,6 @@ struct LegGeometry
|
||||
BOOST_ASSERT(segment_offsets.size() > 0);
|
||||
return segment_offsets.size() - 1;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,14 +13,12 @@ namespace guidance
|
||||
|
||||
struct StepManeuver
|
||||
{
|
||||
util::FixedPointCoordinate location;
|
||||
util::Coordinate location;
|
||||
double bearing_before;
|
||||
double bearing_after;
|
||||
extractor::TurnInstruction instruction;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
#include "engine/object_encoder.hpp"
|
||||
#include "engine/phantom_node.hpp"
|
||||
|
||||
#include "util/coordinate.hpp"
|
||||
#include "phantom_node.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
@@ -19,15 +22,15 @@ namespace engine
|
||||
// Is returned as a temporary identifier for snapped coodinates
|
||||
struct Hint
|
||||
{
|
||||
FixedPointCoordinate input_coordinate;
|
||||
util::Coordinate input_coordinate;
|
||||
PhantomNode phantom;
|
||||
std::uint32_t data_checksum;
|
||||
|
||||
template <typename DataFacadeT>
|
||||
bool IsValid(const FixedPointCoordinate new_input_coordinates, DataFacadeT &facade) const
|
||||
bool IsValid(const util::Coordinate new_input_coordinates, DataFacadeT &facade) const
|
||||
{
|
||||
auto is_same_input_coordinate = new_input_coordinates.lat == input_coordinate.lat &&
|
||||
new_input_coordinates.lon == input_coordinate.lon;
|
||||
auto is_same_input_coordinate = new_input_coordinates.lon == input_coordinate.lon &&
|
||||
new_input_coordinates.lat == input_coordinate.lat;
|
||||
return is_same_input_coordinate && phantom.IsValid(facade.GetNumberOfNodes()) &&
|
||||
facade.GetCheckSum() == data_checksum;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ struct PhantomNode
|
||||
unsigned reverse_packed_geometry_id_,
|
||||
bool is_tiny_component,
|
||||
unsigned component_id,
|
||||
util::FixedPointCoordinate location,
|
||||
util::Coordinate location,
|
||||
unsigned short fwd_segment_position,
|
||||
extractor::TravelMode forward_travel_mode,
|
||||
extractor::TravelMode backward_travel_mode)
|
||||
@@ -37,9 +37,9 @@ struct PhantomNode
|
||||
forward_offset(forward_offset), reverse_offset(reverse_offset),
|
||||
forward_packed_geometry_id(forward_packed_geometry_id_),
|
||||
reverse_packed_geometry_id(reverse_packed_geometry_id_),
|
||||
component{component_id, is_tiny_component},
|
||||
location(std::move(location)), fwd_segment_position(fwd_segment_position),
|
||||
forward_travel_mode(forward_travel_mode), backward_travel_mode(backward_travel_mode)
|
||||
component{component_id, is_tiny_component}, location(std::move(location)),
|
||||
fwd_segment_position(fwd_segment_position), forward_travel_mode(forward_travel_mode),
|
||||
backward_travel_mode(backward_travel_mode)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -47,10 +47,9 @@ struct PhantomNode
|
||||
: forward_node_id(SPECIAL_NODEID), reverse_node_id(SPECIAL_NODEID),
|
||||
name_id(std::numeric_limits<unsigned>::max()), forward_weight(INVALID_EDGE_WEIGHT),
|
||||
reverse_weight(INVALID_EDGE_WEIGHT), forward_offset(0), reverse_offset(0),
|
||||
forward_packed_geometry_id(SPECIAL_EDGEID),
|
||||
reverse_packed_geometry_id(SPECIAL_EDGEID),
|
||||
component{INVALID_COMPONENTID, false},
|
||||
fwd_segment_position(0), forward_travel_mode(TRAVEL_MODE_INACCESSIBLE),
|
||||
forward_packed_geometry_id(SPECIAL_EDGEID), reverse_packed_geometry_id(SPECIAL_EDGEID),
|
||||
component{INVALID_COMPONENTID, false}, fwd_segment_position(0),
|
||||
forward_travel_mode(TRAVEL_MODE_INACCESSIBLE),
|
||||
backward_travel_mode(TRAVEL_MODE_INACCESSIBLE)
|
||||
{
|
||||
}
|
||||
@@ -94,7 +93,12 @@ struct PhantomNode
|
||||
bool operator==(const PhantomNode &other) const { return location == other.location; }
|
||||
|
||||
template <class OtherT>
|
||||
explicit PhantomNode(const OtherT &other, int forward_weight_, int forward_offset_, int reverse_weight_, int reverse_offset_, const util::FixedPointCoordinate foot_point)
|
||||
explicit PhantomNode(const OtherT &other,
|
||||
int forward_weight_,
|
||||
int forward_offset_,
|
||||
int reverse_weight_,
|
||||
int reverse_offset_,
|
||||
const util::Coordinate foot_point)
|
||||
{
|
||||
forward_node_id = other.forward_edge_based_node_id;
|
||||
reverse_node_id = other.reverse_edge_based_node_id;
|
||||
@@ -137,7 +141,7 @@ struct PhantomNode
|
||||
#ifndef _MSC_VER
|
||||
static_assert(sizeof(ComponentType) == 4, "ComponentType needs to 4 bytes big");
|
||||
#endif
|
||||
util::FixedPointCoordinate location;
|
||||
util::Coordinate location;
|
||||
unsigned short fwd_segment_position;
|
||||
// note 4 bits would suffice for each,
|
||||
// but the saved byte would be padding anyway
|
||||
|
||||
@@ -28,10 +28,10 @@ class BasePlugin
|
||||
datafacade::BaseDataFacade &facade;
|
||||
BasePlugin(datafacade::BaseDataFacade &facade_) : facade(facade_) {}
|
||||
|
||||
bool CheckAllCoordinates(const std::vector<util::FixedPointCoordinate> &coordinates)
|
||||
bool CheckAllCoordinates(const std::vector<util::Coordinate> &coordinates)
|
||||
{
|
||||
return !std::any_of(std::begin(coordinates), std::end(coordinates),
|
||||
[](const util::FixedPointCoordinate &coordinate)
|
||||
[](const util::Coordinate coordinate)
|
||||
{
|
||||
return !coordinate.IsValid();
|
||||
});
|
||||
@@ -150,9 +150,11 @@ class BasePlugin
|
||||
return phantom_nodes;
|
||||
}
|
||||
|
||||
std::vector<std::vector<PhantomNodeWithDistance>> GetPhantomNodes(const api::BaseParameters ¶meters, unsigned number_of_results)
|
||||
std::vector<std::vector<PhantomNodeWithDistance>>
|
||||
GetPhantomNodes(const api::BaseParameters ¶meters, unsigned number_of_results)
|
||||
{
|
||||
std::vector<std::vector<PhantomNodeWithDistance>> phantom_nodes(parameters.coordinates.size());
|
||||
std::vector<std::vector<PhantomNodeWithDistance>> phantom_nodes(
|
||||
parameters.coordinates.size());
|
||||
|
||||
const bool use_hints = !parameters.hints.empty();
|
||||
const bool use_bearings = !parameters.bearings.empty();
|
||||
@@ -176,32 +178,28 @@ class BasePlugin
|
||||
{
|
||||
if (use_radiuses && parameters.radiuses[i])
|
||||
{
|
||||
phantom_nodes[i] =
|
||||
facade.NearestPhantomNodes(
|
||||
parameters.coordinates[i], number_of_results, *parameters.radiuses[i],
|
||||
parameters.bearings[i]->bearing, parameters.bearings[i]->range);
|
||||
phantom_nodes[i] = facade.NearestPhantomNodes(
|
||||
parameters.coordinates[i], number_of_results, *parameters.radiuses[i],
|
||||
parameters.bearings[i]->bearing, parameters.bearings[i]->range);
|
||||
}
|
||||
else
|
||||
{
|
||||
phantom_nodes[i] =
|
||||
facade.NearestPhantomNodes(
|
||||
parameters.coordinates[i], number_of_results, parameters.bearings[i]->bearing,
|
||||
parameters.bearings[i]->range);
|
||||
phantom_nodes[i] = facade.NearestPhantomNodes(
|
||||
parameters.coordinates[i], number_of_results,
|
||||
parameters.bearings[i]->bearing, parameters.bearings[i]->range);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (use_radiuses && parameters.radiuses[i])
|
||||
{
|
||||
phantom_nodes[i] =
|
||||
facade.NearestPhantomNodes(
|
||||
parameters.coordinates[i], number_of_results, *parameters.radiuses[i]);
|
||||
phantom_nodes[i] = facade.NearestPhantomNodes(
|
||||
parameters.coordinates[i], number_of_results, *parameters.radiuses[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
phantom_nodes[i] =
|
||||
facade.NearestPhantomNodes(
|
||||
parameters.coordinates[i], number_of_results);
|
||||
facade.NearestPhantomNodes(parameters.coordinates[i], number_of_results);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef POLYLINECOMPRESSOR_H_
|
||||
#define POLYLINECOMPRESSOR_H_
|
||||
|
||||
#include "osrm/coordinate.hpp"
|
||||
#include "util/coordinate.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -12,19 +12,19 @@ namespace engine
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
constexpr double POLYLINE_PECISION = 1e5;
|
||||
constexpr double COORDINATE_TO_POLYLINE = POLYLINE_PECISION / COORDINATE_PRECISION;
|
||||
constexpr double POLYLINE_TO_COORDINATE = COORDINATE_PRECISION / POLYLINE_PECISION;
|
||||
constexpr double POLYLINE_PECISION = 1e5;
|
||||
constexpr double COORDINATE_TO_POLYLINE = POLYLINE_PECISION / COORDINATE_PRECISION;
|
||||
constexpr double POLYLINE_TO_COORDINATE = COORDINATE_PRECISION / POLYLINE_PECISION;
|
||||
}
|
||||
|
||||
using CoordVectorForwardIter = std::vector<FixedPointCoordinate>::const_iterator;
|
||||
using CoordVectorForwardIter = std::vector<util::Coordinate>::const_iterator;
|
||||
// Encodes geometry into polyline format.
|
||||
// See: https://developers.google.com/maps/documentation/utilities/polylinealgorithm
|
||||
std::string encodePolyline(CoordVectorForwardIter begin, CoordVectorForwardIter end);
|
||||
|
||||
// Decodes geometry from polyline format
|
||||
// See: https://developers.google.com/maps/documentation/utilities/polylinealgorithm
|
||||
std::vector<util::FixedPointCoordinate> decodePolyline(const std::string &polyline);
|
||||
std::vector<util::Coordinate> decodePolyline(const std::string &polyline);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
||||
|
||||
SubMatchingList
|
||||
operator()(const CandidateLists &candidates_list,
|
||||
const std::vector<util::FixedPointCoordinate> &trace_coordinates,
|
||||
const std::vector<util::Coordinate> &trace_coordinates,
|
||||
const std::vector<unsigned> &trace_timestamps,
|
||||
const std::vector<boost::optional<double>> &trace_gps_precision) const
|
||||
{
|
||||
|
||||
@@ -334,7 +334,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
id_vector);
|
||||
const bool is_local_path = (phantom_node_pair.source_phantom.forward_packed_geometry_id ==
|
||||
phantom_node_pair.target_phantom.forward_packed_geometry_id) &&
|
||||
unpacked_path.empty();
|
||||
unpacked_path.empty();
|
||||
|
||||
std::size_t start_index = 0;
|
||||
if (is_local_path)
|
||||
@@ -351,8 +351,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
if (target_traversed_in_reverse)
|
||||
{
|
||||
std::reverse(id_vector.begin(), id_vector.end());
|
||||
end_index =
|
||||
id_vector.size() - phantom_node_pair.target_phantom.fwd_segment_position;
|
||||
end_index = id_vector.size() - phantom_node_pair.target_phantom.fwd_segment_position;
|
||||
}
|
||||
|
||||
if (start_index > end_index)
|
||||
@@ -365,8 +364,8 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
BOOST_ASSERT(i < id_vector.size());
|
||||
BOOST_ASSERT(phantom_node_pair.target_phantom.forward_travel_mode > 0);
|
||||
unpacked_path.emplace_back(
|
||||
PathData{id_vector[i], phantom_node_pair.target_phantom.name_id,
|
||||
0, extractor::TurnInstruction::NoTurn,
|
||||
PathData{id_vector[i], phantom_node_pair.target_phantom.name_id, 0,
|
||||
extractor::TurnInstruction::NoTurn,
|
||||
target_traversed_in_reverse
|
||||
? phantom_node_pair.target_phantom.backward_travel_mode
|
||||
: phantom_node_pair.target_phantom.forward_travel_mode});
|
||||
@@ -385,7 +384,8 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
// looks like a trivially true check but tests for underflow
|
||||
BOOST_ASSERT(last_index > second_to_last_index);
|
||||
|
||||
if (unpacked_path[last_index].turn_via_node == unpacked_path[second_to_last_index].turn_via_node)
|
||||
if (unpacked_path[last_index].turn_via_node ==
|
||||
unpacked_path[second_to_last_index].turn_via_node)
|
||||
{
|
||||
unpacked_path.pop_back();
|
||||
}
|
||||
@@ -743,8 +743,8 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||
nodes.target_phantom = target_phantom;
|
||||
UnpackPath(packed_path.begin(), packed_path.end(), nodes, unpacked_path);
|
||||
|
||||
util::FixedPointCoordinate previous_coordinate = source_phantom.location;
|
||||
util::FixedPointCoordinate current_coordinate;
|
||||
util::Coordinate previous_coordinate = source_phantom.location;
|
||||
util::Coordinate current_coordinate;
|
||||
double distance = 0;
|
||||
for (const auto &p : unpacked_path)
|
||||
{
|
||||
|
||||
@@ -22,8 +22,7 @@ struct EdgeBasedNode
|
||||
EdgeBasedNode()
|
||||
: forward_edge_based_node_id(SPECIAL_NODEID), reverse_edge_based_node_id(SPECIAL_NODEID),
|
||||
u(SPECIAL_NODEID), v(SPECIAL_NODEID), name_id(0),
|
||||
forward_packed_geometry_id(SPECIAL_EDGEID),
|
||||
reverse_packed_geometry_id(SPECIAL_EDGEID),
|
||||
forward_packed_geometry_id(SPECIAL_EDGEID), reverse_packed_geometry_id(SPECIAL_EDGEID),
|
||||
component{INVALID_COMPONENTID, false},
|
||||
fwd_segment_position(std::numeric_limits<unsigned short>::max()),
|
||||
forward_travel_mode(TRAVEL_MODE_INACCESSIBLE),
|
||||
@@ -47,21 +46,19 @@ struct EdgeBasedNode
|
||||
reverse_edge_based_node_id(reverse_edge_based_node_id), u(u), v(v), name_id(name_id),
|
||||
forward_packed_geometry_id(forward_weight_or_packed_geometry_id_),
|
||||
reverse_packed_geometry_id(reverse_weight_or_packed_geometry_id_),
|
||||
component{component_id, is_tiny_component},
|
||||
fwd_segment_position(fwd_segment_position), forward_travel_mode(forward_travel_mode),
|
||||
backward_travel_mode(backward_travel_mode)
|
||||
component{component_id, is_tiny_component}, fwd_segment_position(fwd_segment_position),
|
||||
forward_travel_mode(forward_travel_mode), backward_travel_mode(backward_travel_mode)
|
||||
{
|
||||
BOOST_ASSERT((forward_edge_based_node_id != SPECIAL_NODEID) ||
|
||||
(reverse_edge_based_node_id != SPECIAL_NODEID));
|
||||
}
|
||||
|
||||
static inline util::FixedPointCoordinate Centroid(const util::FixedPointCoordinate a,
|
||||
const util::FixedPointCoordinate b)
|
||||
static inline util::Coordinate Centroid(const util::Coordinate a, const util::Coordinate b)
|
||||
{
|
||||
util::FixedPointCoordinate centroid;
|
||||
util::Coordinate centroid;
|
||||
// The coordinates of the midpoint are given by:
|
||||
centroid.lat = (a.lat + b.lat) / 2;
|
||||
centroid.lon = (a.lon + b.lon) / 2;
|
||||
centroid.lon = (a.lon + b.lon) / util::FixedLongitude(2);
|
||||
centroid.lat = (a.lat + b.lat) / util::FixedLatitude(2);
|
||||
return centroid;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,12 @@ namespace extractor
|
||||
|
||||
struct ExternalMemoryNode : QueryNode
|
||||
{
|
||||
ExternalMemoryNode(int lat, int lon, OSMNodeID node_id, bool barrier, bool traffic_lights)
|
||||
: QueryNode(lat, lon, node_id), barrier(barrier), traffic_lights(traffic_lights)
|
||||
ExternalMemoryNode(const util::FixedLongitude lon_,
|
||||
const util::FixedLatitude lat_,
|
||||
OSMNodeID node_id_,
|
||||
bool barrier_,
|
||||
bool traffic_lights_)
|
||||
: QueryNode(lon_, lat_, node_id_), barrier(barrier_), traffic_lights(traffic_lights_)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -21,12 +25,14 @@ struct ExternalMemoryNode : QueryNode
|
||||
|
||||
static ExternalMemoryNode min_value()
|
||||
{
|
||||
return ExternalMemoryNode(0, 0, MIN_OSM_NODEID, false, false);
|
||||
return ExternalMemoryNode(util::FixedLongitude(0), util::FixedLatitude(0), MIN_OSM_NODEID,
|
||||
false, false);
|
||||
}
|
||||
|
||||
static ExternalMemoryNode max_value()
|
||||
{
|
||||
return ExternalMemoryNode(std::numeric_limits<int>::max(), std::numeric_limits<int>::max(),
|
||||
return ExternalMemoryNode(util::FixedLongitude(std::numeric_limits<int>::max()),
|
||||
util::FixedLatitude(std::numeric_limits<int>::max()),
|
||||
MAX_OSM_NODEID, false, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ struct InternalExtractorEdge
|
||||
// intermediate edge weight
|
||||
WeightData weight_data;
|
||||
// coordinate of the source node
|
||||
util::FixedPointCoordinate source_coordinate;
|
||||
util::Coordinate source_coordinate;
|
||||
|
||||
// necessary static util functions for stxxl's sorting
|
||||
static InternalExtractorEdge min_osm_value()
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include "osrm/coordinate.hpp"
|
||||
#include "util/coordinate.hpp"
|
||||
|
||||
#include <limits>
|
||||
|
||||
@@ -17,30 +17,32 @@ struct QueryNode
|
||||
using key_type = OSMNodeID; // type of NodeID
|
||||
using value_type = int; // type of lat,lons
|
||||
|
||||
explicit QueryNode(int lat, int lon, key_type node_id)
|
||||
: lat(lat), lon(lon), node_id(std::move(node_id))
|
||||
explicit QueryNode(const util::FixedLongitude lon_,
|
||||
const util::FixedLatitude lat_,
|
||||
key_type node_id)
|
||||
: lon(lon_), lat(lat_), node_id(std::move(node_id))
|
||||
{
|
||||
}
|
||||
QueryNode()
|
||||
: lat(std::numeric_limits<int>::max()), lon(std::numeric_limits<int>::max()),
|
||||
: lon(std::numeric_limits<int>::max()), lat(std::numeric_limits<int>::max()),
|
||||
node_id(SPECIAL_OSM_NODEID)
|
||||
{
|
||||
}
|
||||
|
||||
int lat;
|
||||
int lon;
|
||||
util::FixedLongitude lon;
|
||||
util::FixedLatitude lat;
|
||||
key_type node_id;
|
||||
|
||||
static QueryNode min_value()
|
||||
{
|
||||
return QueryNode(static_cast<int>(-90 * COORDINATE_PRECISION),
|
||||
static_cast<int>(-180 * COORDINATE_PRECISION), MIN_OSM_NODEID);
|
||||
return QueryNode(util::FixedLongitude(-180 * COORDINATE_PRECISION),
|
||||
util::FixedLatitude(-90 * COORDINATE_PRECISION), MIN_OSM_NODEID);
|
||||
}
|
||||
|
||||
static QueryNode max_value()
|
||||
{
|
||||
return QueryNode(static_cast<int>(90 * COORDINATE_PRECISION),
|
||||
static_cast<int>(180 * COORDINATE_PRECISION), MAX_OSM_NODEID);
|
||||
return QueryNode(util::FixedLongitude(180 * COORDINATE_PRECISION),
|
||||
util::FixedLatitude(90 * COORDINATE_PRECISION), MAX_OSM_NODEID);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
using util::FixedPointCoordinate;
|
||||
using util::Coordinate;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -33,7 +33,7 @@ template <typename ParameterT,
|
||||
typename std::enable_if<detail::is_parameter_t<ParameterT>::value, int>::type = 0>
|
||||
boost::optional<ParameterT> parseParameters(std::string options_string)
|
||||
{
|
||||
const auto first = options_string.begin();
|
||||
auto first = options_string.begin();
|
||||
const auto last = options_string.end();
|
||||
return parseParameters<ParameterT>(first, last);
|
||||
}
|
||||
|
||||
@@ -18,10 +18,9 @@ struct ParsedURL
|
||||
std::string service;
|
||||
unsigned version;
|
||||
std::string profile;
|
||||
std::vector<util::FixedPointCoordinate> coordinates;
|
||||
std::vector<util::Coordinate> coordinates;
|
||||
std::string options;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class BaseService
|
||||
BaseService(OSRM &routing_machine) : routing_machine(routing_machine) {}
|
||||
virtual ~BaseService() = default;
|
||||
|
||||
virtual engine::Status RunQuery(std::vector<util::FixedPointCoordinate> coordinates,
|
||||
virtual engine::Status RunQuery(std::vector<util::Coordinate> coordinates,
|
||||
std::string &options,
|
||||
util::json::Object &json_result) = 0;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class MatchService final : public BaseService
|
||||
public:
|
||||
MatchService(OSRM &routing_machine) : BaseService(routing_machine) {}
|
||||
|
||||
engine::Status RunQuery(std::vector<util::FixedPointCoordinate> coordinates,
|
||||
engine::Status RunQuery(std::vector<util::Coordinate> coordinates,
|
||||
std::string &options,
|
||||
util::json::Object &result) final override;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class NearestService final : public BaseService
|
||||
public:
|
||||
NearestService(OSRM &routing_machine) : BaseService(routing_machine) {}
|
||||
|
||||
engine::Status RunQuery(std::vector<util::FixedPointCoordinate> coordinates,
|
||||
engine::Status RunQuery(std::vector<util::Coordinate> coordinates,
|
||||
std::string &options,
|
||||
util::json::Object &result) final override;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class RouteService final : public BaseService
|
||||
public:
|
||||
RouteService(OSRM &routing_machine) : BaseService(routing_machine) {}
|
||||
|
||||
engine::Status RunQuery(std::vector<util::FixedPointCoordinate> coordinates,
|
||||
engine::Status RunQuery(std::vector<util::Coordinate> coordinates,
|
||||
std::string &options,
|
||||
util::json::Object &result) final override;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class TableService final : public BaseService
|
||||
public:
|
||||
TableService(OSRM &routing_machine) : BaseService(routing_machine) {}
|
||||
|
||||
engine::Status RunQuery(std::vector<util::FixedPointCoordinate> coordinates,
|
||||
engine::Status RunQuery(std::vector<util::Coordinate> coordinates,
|
||||
std::string &options,
|
||||
util::json::Object &result) final override;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class TripService final : public BaseService
|
||||
public:
|
||||
TripService(OSRM &routing_machine) : BaseService(routing_machine) {}
|
||||
|
||||
engine::Status RunQuery(std::vector<util::FixedPointCoordinate> coordinates,
|
||||
engine::Status RunQuery(std::vector<util::Coordinate> coordinates,
|
||||
std::string &options,
|
||||
util::json::Object &result) final override;
|
||||
|
||||
|
||||
+45
-17
@@ -28,9 +28,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#ifndef COORDINATE_HPP_
|
||||
#define COORDINATE_HPP_
|
||||
|
||||
#include "util/strong_typedef.hpp"
|
||||
|
||||
#include <iosfwd> //for std::ostream
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <cstddef>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
@@ -40,35 +43,60 @@ constexpr const double COORDINATE_PRECISION = 1e6;
|
||||
namespace util
|
||||
{
|
||||
|
||||
struct FixedPointCoordinate
|
||||
OSRM_STRONG_TYPEDEF(int32_t, FixedLatitude)
|
||||
OSRM_STRONG_TYPEDEF(int32_t, FixedLongitude)
|
||||
OSRM_STRONG_TYPEDEF(double, FloatLatitude)
|
||||
OSRM_STRONG_TYPEDEF(double, FloatLongitude)
|
||||
|
||||
inline FixedLatitude toFixed(const FloatLatitude floating)
|
||||
{
|
||||
int lat;
|
||||
int lon;
|
||||
return FixedLatitude(static_cast<double>(floating) * COORDINATE_PRECISION);
|
||||
}
|
||||
|
||||
FixedPointCoordinate();
|
||||
FixedPointCoordinate(int lat, int lon);
|
||||
inline FixedLongitude toFixed(const FloatLongitude floating)
|
||||
{
|
||||
return FixedLongitude(static_cast<double>(floating) * COORDINATE_PRECISION);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
FixedPointCoordinate(const T &coordinate)
|
||||
: lat(coordinate.lat), lon(coordinate.lon)
|
||||
inline FloatLatitude toFloating(const FixedLatitude fixed)
|
||||
{
|
||||
return FloatLatitude(static_cast<int32_t>(fixed) / COORDINATE_PRECISION);
|
||||
}
|
||||
|
||||
inline FloatLongitude toFloating(const FixedLongitude fixed)
|
||||
{
|
||||
return FloatLongitude(static_cast<int32_t>(fixed) / COORDINATE_PRECISION);
|
||||
}
|
||||
|
||||
// Coordinate encoded as longitude, latitude
|
||||
struct Coordinate
|
||||
{
|
||||
FixedLongitude lon;
|
||||
FixedLatitude lat;
|
||||
|
||||
Coordinate();
|
||||
Coordinate(const FixedLongitude lon_, const FixedLatitude lat_);
|
||||
Coordinate(const FloatLongitude lon_, const FloatLatitude lat_);
|
||||
|
||||
template <class T> Coordinate(const T &coordinate) : lon(coordinate.lon), lat(coordinate.lat)
|
||||
{
|
||||
static_assert(!std::is_same<T, FixedPointCoordinate>::value, "This constructor should not be used for FixedPointCoordinates");
|
||||
static_assert(std::is_same<decltype(lat), decltype(coordinate.lat)>::value,
|
||||
"coordinate types incompatible");
|
||||
static_assert(!std::is_same<T, Coordinate>::value,
|
||||
"This constructor should not be used for Coordinates");
|
||||
static_assert(std::is_same<decltype(lon), decltype(coordinate.lon)>::value,
|
||||
"coordinate types incompatible");
|
||||
static_assert(std::is_same<decltype(lat), decltype(coordinate.lat)>::value,
|
||||
"coordinate types incompatible");
|
||||
}
|
||||
|
||||
bool IsValid() const;
|
||||
friend bool operator==(const FixedPointCoordinate lhs, const FixedPointCoordinate rhs);
|
||||
friend bool operator!=(const FixedPointCoordinate lhs, const FixedPointCoordinate rhs);
|
||||
friend std::ostream &operator<<(std::ostream &out, const FixedPointCoordinate coordinate);
|
||||
friend bool operator==(const Coordinate lhs, const Coordinate rhs);
|
||||
friend bool operator!=(const Coordinate lhs, const Coordinate rhs);
|
||||
friend std::ostream &operator<<(std::ostream &out, const Coordinate coordinate);
|
||||
};
|
||||
|
||||
bool operator==(const FixedPointCoordinate lhs, const FixedPointCoordinate rhs);
|
||||
std::ostream &operator<<(std::ostream &out, const FixedPointCoordinate coordinate);
|
||||
bool operator==(const Coordinate lhs, const Coordinate rhs);
|
||||
std::ostream &operator<<(std::ostream &out, const Coordinate coordinate);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif /* COORDINATE_HPP_ */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef COORDINATE_CALCULATION
|
||||
#define COORDINATE_CALCULATION
|
||||
|
||||
#include "osrm/coordinate.hpp"
|
||||
#include "util/coordinate.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
@@ -18,55 +18,47 @@ const constexpr long double EARTH_RADIUS = 6372797.560856;
|
||||
|
||||
namespace coordinate_calculation
|
||||
{
|
||||
double haversineDistance(const int lat1, const int lon1, const int lat2, const int lon2);
|
||||
|
||||
double haversineDistance(const FixedPointCoordinate first_coordinate,
|
||||
const FixedPointCoordinate second_coordinate);
|
||||
double haversineDistance(const Coordinate first_coordinate, const Coordinate second_coordinate);
|
||||
|
||||
double greatCircleDistance(const FixedPointCoordinate first_coordinate,
|
||||
const FixedPointCoordinate second_coordinate);
|
||||
double greatCircleDistance(const Coordinate first_coordinate, const Coordinate second_coordinate);
|
||||
|
||||
double greatCircleDistance(const int lat1, const int lon1, const int lat2, const int lon2);
|
||||
double perpendicularDistance(const Coordinate segment_source,
|
||||
const Coordinate segment_target,
|
||||
const Coordinate query_location);
|
||||
|
||||
double perpendicularDistance(const FixedPointCoordinate segment_source,
|
||||
const FixedPointCoordinate segment_target,
|
||||
const FixedPointCoordinate query_location);
|
||||
|
||||
double perpendicularDistance(const FixedPointCoordinate segment_source,
|
||||
const FixedPointCoordinate segment_target,
|
||||
const FixedPointCoordinate query_location,
|
||||
FixedPointCoordinate &nearest_location,
|
||||
double perpendicularDistance(const Coordinate segment_source,
|
||||
const Coordinate segment_target,
|
||||
const Coordinate query_location,
|
||||
Coordinate &nearest_location,
|
||||
double &ratio);
|
||||
|
||||
double
|
||||
perpendicularDistanceFromProjectedCoordinate(const FixedPointCoordinate segment_source,
|
||||
const FixedPointCoordinate segment_target,
|
||||
const FixedPointCoordinate query_location,
|
||||
const std::pair<double, double> projected_coordinate);
|
||||
double perpendicularDistanceFromProjectedCoordinate(
|
||||
const Coordinate segment_source,
|
||||
const Coordinate segment_target,
|
||||
const Coordinate query_location,
|
||||
const std::pair<double, double> projected_xy_coordinate);
|
||||
|
||||
double
|
||||
perpendicularDistanceFromProjectedCoordinate(const FixedPointCoordinate segment_source,
|
||||
const FixedPointCoordinate segment_target,
|
||||
const FixedPointCoordinate query_location,
|
||||
const std::pair<double, double> projected_coordinate,
|
||||
FixedPointCoordinate &nearest_location,
|
||||
double &ratio);
|
||||
double perpendicularDistanceFromProjectedCoordinate(
|
||||
const Coordinate segment_source,
|
||||
const Coordinate segment_target,
|
||||
const Coordinate query_location,
|
||||
const std::pair<double, double> projected_xy_coordinate,
|
||||
Coordinate &nearest_location,
|
||||
double &ratio);
|
||||
|
||||
double degToRad(const double degree);
|
||||
double radToDeg(const double radian);
|
||||
|
||||
double bearing(const FixedPointCoordinate first_coordinate,
|
||||
const FixedPointCoordinate second_coordinate);
|
||||
double bearing(const Coordinate first_coordinate, const Coordinate second_coordinate);
|
||||
|
||||
// Get angle of line segment (A,C)->(C,B)
|
||||
double computeAngle(const FixedPointCoordinate first,
|
||||
const FixedPointCoordinate second,
|
||||
const FixedPointCoordinate third);
|
||||
double computeAngle(const Coordinate first, const Coordinate second, const Coordinate third);
|
||||
|
||||
namespace mercator
|
||||
{
|
||||
double yToLat(const double value);
|
||||
double latToY(const double latitude);
|
||||
FloatLatitude yToLat(const double value);
|
||||
double latToY(const FloatLatitude latitude);
|
||||
} // ns mercator
|
||||
} // ns coordinate_calculation
|
||||
} // ns util
|
||||
|
||||
@@ -86,7 +86,7 @@ NodeID loadNodesFromFile(std::istream &input_stream,
|
||||
{
|
||||
input_stream.read(reinterpret_cast<char *>(¤t_node),
|
||||
sizeof(extractor::ExternalMemoryNode));
|
||||
node_array.emplace_back(current_node.lat, current_node.lon, current_node.node_id);
|
||||
node_array.emplace_back(current_node.lon, current_node.lat, current_node.node_id);
|
||||
if (current_node.barrier)
|
||||
{
|
||||
barrier_node_list.emplace_back(i);
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace util
|
||||
{
|
||||
|
||||
// Computes a 64 bit value that corresponds to the hilbert space filling curve
|
||||
std::uint64_t hilbertCode(const FixedPointCoordinate coordinate);
|
||||
std::uint64_t hilbertCode(const Coordinate coordinate);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,9 +39,9 @@ struct MatchingDebugInfo
|
||||
{
|
||||
json::Object state;
|
||||
state.values["transitions"] = json::Array();
|
||||
state.values["coordinate"] =
|
||||
json::make_array(elem_s.phantom_node.location.lat / COORDINATE_PRECISION,
|
||||
elem_s.phantom_node.location.lon / COORDINATE_PRECISION);
|
||||
state.values["coordinate"] = json::make_array(
|
||||
static_cast<double>(toFloating(elem_s.phantom_node.location.lat)),
|
||||
static_cast<double>(toFloating(elem_s.phantom_node.location.lon)));
|
||||
state.values["viterbi"] =
|
||||
json::clamp_float(engine::map_matching::IMPOSSIBLE_LOG_PROB);
|
||||
state.values["pruned"] = 0u;
|
||||
@@ -124,8 +124,10 @@ struct MatchingDebugInfo
|
||||
json::Array a;
|
||||
for (const bool v : breakage)
|
||||
{
|
||||
if (v) a.values.emplace_back(json::True());
|
||||
else a.values.emplace_back(json::False());
|
||||
if (v)
|
||||
a.values.emplace_back(json::True());
|
||||
else
|
||||
a.values.emplace_back(json::False());
|
||||
}
|
||||
|
||||
json::get(*object, "breakage") = std::move(a);
|
||||
|
||||
+44
-35
@@ -29,16 +29,25 @@ struct RectangleInt2D
|
||||
{
|
||||
}
|
||||
|
||||
RectangleInt2D(std::int32_t min_lon_,
|
||||
std::int32_t max_lon_,
|
||||
std::int32_t min_lat_,
|
||||
std::int32_t max_lat_)
|
||||
RectangleInt2D(FixedLongitude min_lon_,
|
||||
FixedLongitude max_lon_,
|
||||
FixedLatitude min_lat_,
|
||||
FixedLatitude max_lat_)
|
||||
: min_lon(min_lon_), max_lon(max_lon_), min_lat(min_lat_), max_lat(max_lat_)
|
||||
{
|
||||
}
|
||||
|
||||
std::int32_t min_lon, max_lon;
|
||||
std::int32_t min_lat, max_lat;
|
||||
RectangleInt2D(FloatLongitude min_lon_,
|
||||
FloatLongitude max_lon_,
|
||||
FloatLatitude min_lat_,
|
||||
FloatLatitude max_lat_)
|
||||
: min_lon(toFixed(min_lon_)), max_lon(toFixed(max_lon_)), min_lat(toFixed(min_lat_)),
|
||||
max_lat(toFixed(max_lat_))
|
||||
{
|
||||
}
|
||||
|
||||
FixedLongitude min_lon, max_lon;
|
||||
FixedLatitude min_lat, max_lat;
|
||||
|
||||
void MergeBoundingBoxes(const RectangleInt2D &other)
|
||||
{
|
||||
@@ -46,19 +55,19 @@ struct RectangleInt2D
|
||||
max_lon = std::max(max_lon, other.max_lon);
|
||||
min_lat = std::min(min_lat, other.min_lat);
|
||||
max_lat = std::max(max_lat, other.max_lat);
|
||||
BOOST_ASSERT(min_lat != std::numeric_limits<std::int32_t>::min());
|
||||
BOOST_ASSERT(min_lon != std::numeric_limits<std::int32_t>::min());
|
||||
BOOST_ASSERT(max_lat != std::numeric_limits<std::int32_t>::min());
|
||||
BOOST_ASSERT(max_lon != std::numeric_limits<std::int32_t>::min());
|
||||
BOOST_ASSERT(min_lon != FixedLongitude(std::numeric_limits<std::int32_t>::min()));
|
||||
BOOST_ASSERT(min_lat != FixedLatitude(std::numeric_limits<std::int32_t>::min()));
|
||||
BOOST_ASSERT(max_lon != FixedLongitude(std::numeric_limits<std::int32_t>::min()));
|
||||
BOOST_ASSERT(max_lat != FixedLatitude(std::numeric_limits<std::int32_t>::min()));
|
||||
}
|
||||
|
||||
FixedPointCoordinate Centroid() const
|
||||
Coordinate Centroid() const
|
||||
{
|
||||
FixedPointCoordinate centroid;
|
||||
Coordinate centroid;
|
||||
// The coordinates of the midpoints are given by:
|
||||
// x = (x1 + x2) /2 and y = (y1 + y2) /2.
|
||||
centroid.lon = (min_lon + max_lon) / 2;
|
||||
centroid.lat = (min_lat + max_lat) / 2;
|
||||
centroid.lon = (min_lon + max_lon) / FixedLongitude(2);
|
||||
centroid.lat = (min_lat + max_lat) / FixedLatitude(2);
|
||||
return centroid;
|
||||
}
|
||||
|
||||
@@ -70,7 +79,7 @@ struct RectangleInt2D
|
||||
min_lat > other.max_lat);
|
||||
}
|
||||
|
||||
double GetMinDist(const FixedPointCoordinate location) const
|
||||
double GetMinDist(const Coordinate location) const
|
||||
{
|
||||
const bool is_contained = Contains(location);
|
||||
if (is_contained)
|
||||
@@ -108,35 +117,35 @@ struct RectangleInt2D
|
||||
{
|
||||
case NORTH:
|
||||
min_dist = coordinate_calculation::greatCircleDistance(
|
||||
location, FixedPointCoordinate(max_lat, location.lon));
|
||||
location, Coordinate(location.lon, max_lat));
|
||||
break;
|
||||
case SOUTH:
|
||||
min_dist = coordinate_calculation::greatCircleDistance(
|
||||
location, FixedPointCoordinate(min_lat, location.lon));
|
||||
location, Coordinate(location.lon, min_lat));
|
||||
break;
|
||||
case WEST:
|
||||
min_dist = coordinate_calculation::greatCircleDistance(
|
||||
location, FixedPointCoordinate(location.lat, min_lon));
|
||||
location, Coordinate(min_lon, location.lat));
|
||||
break;
|
||||
case EAST:
|
||||
min_dist = coordinate_calculation::greatCircleDistance(
|
||||
location, FixedPointCoordinate(location.lat, max_lon));
|
||||
location, Coordinate(max_lon, location.lat));
|
||||
break;
|
||||
case NORTH_EAST:
|
||||
min_dist = coordinate_calculation::greatCircleDistance(
|
||||
location, FixedPointCoordinate(max_lat, max_lon));
|
||||
min_dist =
|
||||
coordinate_calculation::greatCircleDistance(location, Coordinate(max_lon, max_lat));
|
||||
break;
|
||||
case NORTH_WEST:
|
||||
min_dist = coordinate_calculation::greatCircleDistance(
|
||||
location, FixedPointCoordinate(max_lat, min_lon));
|
||||
min_dist =
|
||||
coordinate_calculation::greatCircleDistance(location, Coordinate(min_lon, max_lat));
|
||||
break;
|
||||
case SOUTH_EAST:
|
||||
min_dist = coordinate_calculation::greatCircleDistance(
|
||||
location, FixedPointCoordinate(min_lat, max_lon));
|
||||
min_dist =
|
||||
coordinate_calculation::greatCircleDistance(location, Coordinate(max_lon, min_lat));
|
||||
break;
|
||||
case SOUTH_WEST:
|
||||
min_dist = coordinate_calculation::greatCircleDistance(
|
||||
location, FixedPointCoordinate(min_lat, min_lon));
|
||||
min_dist =
|
||||
coordinate_calculation::greatCircleDistance(location, Coordinate(min_lon, min_lat));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -147,14 +156,14 @@ struct RectangleInt2D
|
||||
return min_dist;
|
||||
}
|
||||
|
||||
double GetMinMaxDist(const FixedPointCoordinate location) const
|
||||
double GetMinMaxDist(const Coordinate location) const
|
||||
{
|
||||
double min_max_dist = std::numeric_limits<double>::max();
|
||||
// Get minmax distance to each of the four sides
|
||||
const FixedPointCoordinate upper_left(max_lat, min_lon);
|
||||
const FixedPointCoordinate upper_right(max_lat, max_lon);
|
||||
const FixedPointCoordinate lower_right(min_lat, max_lon);
|
||||
const FixedPointCoordinate lower_left(min_lat, min_lon);
|
||||
const Coordinate upper_left(min_lon, max_lat);
|
||||
const Coordinate upper_right(max_lon, max_lat);
|
||||
const Coordinate lower_right(max_lon, min_lat);
|
||||
const Coordinate lower_left(min_lon, min_lat);
|
||||
|
||||
min_max_dist =
|
||||
std::min(min_max_dist,
|
||||
@@ -178,11 +187,11 @@ struct RectangleInt2D
|
||||
return min_max_dist;
|
||||
}
|
||||
|
||||
bool Contains(const FixedPointCoordinate location) const
|
||||
bool Contains(const Coordinate location) const
|
||||
{
|
||||
const bool lats_contained = (location.lat >= min_lat) && (location.lat <= max_lat);
|
||||
const bool lons_contained = (location.lon >= min_lon) && (location.lon <= max_lon);
|
||||
return lats_contained && lons_contained;
|
||||
const bool lats_contained = (location.lat >= min_lat) && (location.lat <= max_lat);
|
||||
return lons_contained && lats_contained;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace util
|
||||
|
||||
// Static RTree for serving nearest neighbour queries
|
||||
template <class EdgeDataT,
|
||||
class CoordinateListT = std::vector<FixedPointCoordinate>,
|
||||
class CoordinateListT = std::vector<Coordinate>,
|
||||
bool UseSharedMemory = false,
|
||||
std::uint32_t BRANCHING_FACTOR = 64,
|
||||
std::uint32_t LEAF_NODE_SIZE = 1024>
|
||||
@@ -122,8 +122,8 @@ class StaticRTree
|
||||
// generate auxiliary vector of hilbert-values
|
||||
tbb::parallel_for(
|
||||
tbb::blocked_range<uint64_t>(0, m_element_count),
|
||||
[&input_data_vector, &input_wrapper_vector, &coordinate_list](
|
||||
const tbb::blocked_range<uint64_t> &range)
|
||||
[&input_data_vector, &input_wrapper_vector,
|
||||
&coordinate_list](const tbb::blocked_range<uint64_t> &range)
|
||||
{
|
||||
for (uint64_t element_counter = range.begin(), end = range.end();
|
||||
element_counter != end; ++element_counter)
|
||||
@@ -137,14 +137,14 @@ class StaticRTree
|
||||
BOOST_ASSERT(current_element.u < coordinate_list.size());
|
||||
BOOST_ASSERT(current_element.v < coordinate_list.size());
|
||||
|
||||
FixedPointCoordinate current_centroid = EdgeDataT::Centroid(
|
||||
FixedPointCoordinate(coordinate_list[current_element.u].lat,
|
||||
coordinate_list[current_element.u].lon),
|
||||
FixedPointCoordinate(coordinate_list[current_element.v].lat,
|
||||
coordinate_list[current_element.v].lon));
|
||||
current_centroid.lat =
|
||||
COORDINATE_PRECISION * coordinate_calculation::mercator::latToY(
|
||||
current_centroid.lat / COORDINATE_PRECISION);
|
||||
Coordinate current_centroid =
|
||||
EdgeDataT::Centroid(Coordinate(coordinate_list[current_element.u].lon,
|
||||
coordinate_list[current_element.u].lat),
|
||||
Coordinate(coordinate_list[current_element.v].lon,
|
||||
coordinate_list[current_element.v].lat));
|
||||
current_centroid.lat = FixedLatitude(
|
||||
COORDINATE_PRECISION *
|
||||
coordinate_calculation::mercator::latToY(toFloating(current_centroid.lat)));
|
||||
|
||||
current_wrapper.m_hilbert_value = hilbertCode(current_centroid);
|
||||
}
|
||||
@@ -377,8 +377,7 @@ class StaticRTree
|
||||
}
|
||||
|
||||
// Override filter and terminator for the desired behaviour.
|
||||
std::vector<EdgeDataT> Nearest(const FixedPointCoordinate input_coordinate,
|
||||
const std::size_t max_results)
|
||||
std::vector<EdgeDataT> Nearest(const Coordinate input_coordinate, const std::size_t max_results)
|
||||
{
|
||||
return Nearest(input_coordinate,
|
||||
[](const EdgeDataT &)
|
||||
@@ -393,14 +392,13 @@ class StaticRTree
|
||||
|
||||
// Override filter and terminator for the desired behaviour.
|
||||
template <typename FilterT, typename TerminationT>
|
||||
std::vector<EdgeDataT> Nearest(const FixedPointCoordinate input_coordinate,
|
||||
const FilterT filter,
|
||||
const TerminationT terminate)
|
||||
std::vector<EdgeDataT>
|
||||
Nearest(const Coordinate input_coordinate, const FilterT filter, const TerminationT terminate)
|
||||
{
|
||||
std::vector<EdgeDataT> results;
|
||||
std::pair<double, double> projected_coordinate = {
|
||||
coordinate_calculation::mercator::latToY(input_coordinate.lat / COORDINATE_PRECISION),
|
||||
input_coordinate.lon / COORDINATE_PRECISION};
|
||||
static_cast<double>(toFloating(input_coordinate.lon)),
|
||||
coordinate_calculation::mercator::latToY(toFloating(input_coordinate.lat))};
|
||||
|
||||
// initialize queue with root element
|
||||
std::priority_queue<QueryCandidate> traversal_queue;
|
||||
@@ -462,7 +460,7 @@ class StaticRTree
|
||||
private:
|
||||
template <typename QueueT>
|
||||
void ExploreLeafNode(const std::uint32_t leaf_id,
|
||||
const FixedPointCoordinate input_coordinate,
|
||||
const Coordinate input_coordinate,
|
||||
const std::pair<double, double> &projected_coordinate,
|
||||
QueueT &traversal_queue)
|
||||
{
|
||||
@@ -487,7 +485,7 @@ class StaticRTree
|
||||
|
||||
template <class QueueT>
|
||||
void ExploreTreeNode(const TreeNode &parent,
|
||||
const FixedPointCoordinate input_coordinate,
|
||||
const Coordinate input_coordinate,
|
||||
QueueT &traversal_queue)
|
||||
{
|
||||
for (std::uint32_t i = 0; i < parent.child_count; ++i)
|
||||
@@ -542,10 +540,10 @@ class StaticRTree
|
||||
std::max(rectangle.max_lat, std::max(coordinate_list[objects[i].u].lat,
|
||||
coordinate_list[objects[i].v].lat));
|
||||
}
|
||||
BOOST_ASSERT(rectangle.min_lat != std::numeric_limits<int>::min());
|
||||
BOOST_ASSERT(rectangle.min_lon != std::numeric_limits<int>::min());
|
||||
BOOST_ASSERT(rectangle.max_lat != std::numeric_limits<int>::min());
|
||||
BOOST_ASSERT(rectangle.max_lon != std::numeric_limits<int>::min());
|
||||
BOOST_ASSERT(rectangle.min_lon != FixedLongitude(std::numeric_limits<int>::min()));
|
||||
BOOST_ASSERT(rectangle.min_lat != FixedLatitude(std::numeric_limits<int>::min()));
|
||||
BOOST_ASSERT(rectangle.max_lon != FixedLongitude(std::numeric_limits<int>::min()));
|
||||
BOOST_ASSERT(rectangle.max_lat != FixedLatitude(std::numeric_limits<int>::min()));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -18,21 +18,30 @@ namespace osrm
|
||||
{ \
|
||||
static_assert(std::is_arithmetic<From>(), ""); \
|
||||
From x; \
|
||||
friend std::ostream& operator<<(std::ostream& stream, const To& inst); \
|
||||
friend std::ostream &operator<<(std::ostream &stream, const To &inst); \
|
||||
\
|
||||
public: \
|
||||
To() = default; \
|
||||
explicit To(const From x_) : x(x_) {} \
|
||||
explicit operator From &() { return x; } \
|
||||
explicit operator const From &() const { return x; } \
|
||||
bool operator<(const To &z_) const { return x < static_cast<const From>(z_); } \
|
||||
bool operator>(const To &z_) const { return x > static_cast<const From>(z_); } \
|
||||
bool operator<=(const To &z_) const { return x <= static_cast<const From>(z_); } \
|
||||
bool operator>=(const To &z_) const { return x >= static_cast<const From>(z_); } \
|
||||
bool operator==(const To &z_) const { return x == static_cast<const From>(z_); } \
|
||||
bool operator!=(const To &z_) const { return x != static_cast<const From>(z_); } \
|
||||
explicit operator From() const { return x; } \
|
||||
To operator+(const To rhs_) const { return To(x + static_cast<const From>(rhs_)); } \
|
||||
To operator-(const To rhs_) const { return To(x - static_cast<const From>(rhs_)); } \
|
||||
To operator*(const To rhs_) const { return To(x * static_cast<const From>(rhs_)); } \
|
||||
To operator/(const To rhs_) const { return To(x / static_cast<const From>(rhs_)); } \
|
||||
bool operator<(const To z_) const { return x < static_cast<const From>(z_); } \
|
||||
bool operator>(const To z_) const { return x > static_cast<const From>(z_); } \
|
||||
bool operator<=(const To z_) const { return x <= static_cast<const From>(z_); } \
|
||||
bool operator>=(const To z_) const { return x >= static_cast<const From>(z_); } \
|
||||
bool operator==(const To z_) const { return x == static_cast<const From>(z_); } \
|
||||
bool operator!=(const To z_) const { return x != static_cast<const From>(z_); } \
|
||||
}; \
|
||||
inline From To##_to_##From(To to) { return static_cast<From>(to); } \
|
||||
inline std::ostream &operator<<(std::ostream &stream, const To &inst) \
|
||||
{ \
|
||||
return stream << #To << '(' << inst.x << ')'; \
|
||||
}
|
||||
|
||||
#define OSRM_STRONG_TYPEDEF_HASHABLE(From, To) \
|
||||
namespace std \
|
||||
{ \
|
||||
template <> struct hash<To> \
|
||||
@@ -42,9 +51,6 @@ namespace osrm
|
||||
return std::hash<From>()(static_cast<const From>(k)); \
|
||||
} \
|
||||
}; \
|
||||
} \
|
||||
inline std::ostream& operator<<(std::ostream& stream, const To& inst) { \
|
||||
return stream << #To << '(' << inst.x << ')'; \
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#ifndef UTIL_TILES_HPP
|
||||
#define UTIL_TILES_HPP
|
||||
|
||||
#include "util/coordinate.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <cmath>
|
||||
@@ -46,20 +48,20 @@ inline unsigned getBBMaxZoom(const Tile top_left, const Tile bottom_left)
|
||||
}
|
||||
}
|
||||
|
||||
inline Tile pointToTile(const double lon, const double lat)
|
||||
inline Tile pointToTile(const FloatLongitude lon, const FloatLatitude lat)
|
||||
{
|
||||
auto sin_lat = std::sin(lat * M_PI / 180.);
|
||||
auto sin_lat = std::sin(static_cast<double>(lat) * M_PI / 180.);
|
||||
auto p2z = std::pow(2, detail::MAX_ZOOM);
|
||||
unsigned x = p2z * (lon / 360. + 0.5);
|
||||
unsigned x = p2z * (static_cast<double>(lon) / 360. + 0.5);
|
||||
unsigned y = p2z * (0.5 - 0.25 * std::log((1 + sin_lat) / (1 - sin_lat)) / M_PI);
|
||||
|
||||
return Tile{x, y, detail::MAX_ZOOM};
|
||||
}
|
||||
|
||||
inline Tile getBBMaxZoomTile(const double min_lon,
|
||||
const double min_lat,
|
||||
const double max_lon,
|
||||
const double max_lat)
|
||||
inline Tile getBBMaxZoomTile(const FloatLongitude min_lon,
|
||||
const FloatLatitude min_lat,
|
||||
const FloatLongitude max_lon,
|
||||
const FloatLatitude max_lat)
|
||||
{
|
||||
const auto top_left = pointToTile(min_lon, min_lat);
|
||||
const auto bottom_left = pointToTile(max_lon, max_lat);
|
||||
|
||||
@@ -8,7 +8,10 @@
|
||||
|
||||
// OpenStreetMap node ids are higher than 2^32
|
||||
OSRM_STRONG_TYPEDEF(uint64_t, OSMNodeID)
|
||||
OSRM_STRONG_TYPEDEF_HASHABLE(uint64_t, OSMNodeID)
|
||||
|
||||
OSRM_STRONG_TYPEDEF(uint32_t, OSMWayID)
|
||||
OSRM_STRONG_TYPEDEF_HASHABLE(uint32_t, OSMWayID)
|
||||
|
||||
static const OSMNodeID SPECIAL_OSM_NODEID = OSMNodeID(std::numeric_limits<std::uint64_t>::max());
|
||||
static const OSMWayID SPECIAL_OSM_WAYID = OSMWayID(std::numeric_limits<std::uint32_t>::max());
|
||||
|
||||
Reference in New Issue
Block a user