-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Isochrone Plugin #2189 #2477
Closed
Closed
Isochrone Plugin #2189 #2477
Changes from all commits
Commits
Show all changes
63 commits
Select commit
Hold shift + click to select a range
4e78329
started range analysis
roroettg 6025b46
first implementation of routing algo with pretty json-print
roroettg f552336
added testing
roroettg e887242
started range analysis
roroettg f9d9d9c
first implementation of routing algo with pretty json-print
roroettg 9059de0
added testing
roroettg bf036de
changes
roroettg 358a1f7
merge
roroettg a8d560d
helloworld-isochrone with new API
roroettg ab4e259
started range analysis
roroettg fc1b696
first implementation of routing algo with pretty json-print
roroettg fddfd0b
added testing
roroettg 2035618
started range analysis
roroettg be23a0d
first implementation of routing algo with pretty json-print
roroettg 06e3161
added testing
roroettg 7999911
changes
roroettg 25164a8
helloworld-isochrone with new API
roroettg 9a7d098
isochrone impl
roroettg 26bff90
Merge branch 'develop' of https://github.com/beemogmbh/osrm-backend i…
roroettg 0cf0608
added inline to functions to be able to use them for isochrones/avoid…
roroettg 1440e54
working isochrone calc, TODO: find out why distances are further than…
roroettg 1837567
merge
roroettg 8a8bc76
Merge branch 'develop' into HEAD
roroettg 383d1ab
merge with fork
roroettg 6bb0a16
added graham scan
roroettg 4a9f133
Merge remote-tracking branch 'upstream/master' into develop
roroettg b168f01
fixed isochrone for current version of master
roroettg 36c76c8
fixed integer overflow bug in graham scan
roroettg e111424
added Andrew's monotone chain convex hull algorithm
roroettg a22d169
added distance param to grammar
roroettg a8f081d
Merge remote-tracking branch 'upstream/master' into develop
roroettg 931281f
refactoring
roroettg 510585a
added convexhull api param
roroettg 8ce8a38
code format
roroettg 9f73b69
bug fixes and tests
roroettg ec161e4
Merge remote-tracking branch 'upstream/master'
roroettg fad6726
testfixes
roroettg f574658
merge
roroettg 17c06d2
implemented isochrone as plugin
roroettg e334402
refactoring
roroettg 8db63a9
Merge remote-tracking branch 'upstream/master'
roroettg 0ea7cde
refactoring #2
roroettg 4f8daac
added isochrone by distance or duration functionality
roroettg 8564f06
merge
roroettg bef74c9
Merge remote-tracking branch 'upstream/master'
roroettg 71ed41b
concave isochrones added
roroettg 1cf81e1
fixed mem leak
roroettg 4ca2945
merge
roroettg 826c165
Merge remote-tracking branch 'upstream/master'
roroettg baed9c7
Fixed bug multiple Requests
roroettg 814e4d8
Style Format
roroettg c1679a7
merge
roroettg 8f5d72d
Merge remote-tracking branch 'upstream/master'
roroettg 554303d
merge
roroettg 1408187
Merge remote-tracking branch 'upstream/master'
roroettg fbc5212
timing
roroettg 279461e
Merge remote-tracking branch 'osrm-upstream/master'
roroettg 667cc37
first docker impl
roroettg 1fe544e
Merge remote-tracking branch 'osrm-upstream/master'
roroettg b694ab6
removed docker
roroettg 8b9f1a1
Merge remote-tracking branch 'osrm-upstream/master'
roroettg 80062ae
merge
roroettg 547f293
merge
roroettg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
#ifndef ENGINE_API_ISOCHRONE_HPP | ||
#define ENGINE_API_ISOCHRONE_HPP | ||
|
||
#include "engine/api/base_api.hpp" | ||
#include "engine/api/isochrone_parameters.hpp" | ||
#include "engine/plugins/isochrone.hpp" | ||
#include "engine/plugins/plugin_base.hpp" | ||
|
||
namespace osrm | ||
{ | ||
namespace engine | ||
{ | ||
namespace api | ||
{ | ||
|
||
class IsochroneAPI final : public BaseAPI | ||
{ | ||
|
||
public: | ||
const IsochroneParameters ¶meters; | ||
|
||
IsochroneAPI(const datafacade::BaseDataFacade &facade_, const IsochroneParameters ¶meters_) | ||
: BaseAPI(facade_, parameters_), parameters(parameters_) | ||
{ | ||
} | ||
|
||
void MakeResponse(const std::vector<engine::plugins::IsochroneNode> isochroneNodes, | ||
const std::vector<engine::plugins::IsochroneNode> convexhull, | ||
const std::vector<engine::plugins::IsochroneNode> concavehull, | ||
util::json::Object &response) const | ||
{ | ||
util::json::Array isochroneJson; | ||
for (auto isochrone : isochroneNodes) | ||
{ | ||
util::json::Object object; | ||
|
||
util::json::Object source; | ||
source.values["lat"] = static_cast<double>(util::toFloating(isochrone.node.lat)); | ||
source.values["lon"] = static_cast<double>(util::toFloating(isochrone.node.lon)); | ||
object.values["p1"] = std::move(source); | ||
|
||
util::json::Object predecessor; | ||
predecessor.values["lat"] = | ||
static_cast<double>(util::toFloating(isochrone.predecessor.lat)); | ||
predecessor.values["lon"] = | ||
static_cast<double>(util::toFloating(isochrone.predecessor.lon)); | ||
object.values["p2"] = std::move(predecessor); | ||
|
||
util::json::Object distance; | ||
object.values["distance_from_start"] = isochrone.distance; | ||
|
||
util::json::Object duration; | ||
object.values["duration_from_start"] = isochrone.duration; | ||
|
||
isochroneJson.values.push_back(object); | ||
} | ||
response.values["isochrone"] = std::move(isochroneJson); | ||
|
||
if (!convexhull.empty()) | ||
{ | ||
util::json::Array convexhullArray; | ||
for (engine::plugins::IsochroneNode n : convexhull) | ||
{ | ||
util::json::Object point; | ||
point.values["lat"] = static_cast<double>(util::toFloating(n.node.lat)); | ||
point.values["lon"] = static_cast<double>(util::toFloating(n.node.lon)); | ||
convexhullArray.values.push_back(point); | ||
} | ||
response.values["convexhull"] = std::move(convexhullArray); | ||
} | ||
|
||
if (!concavehull.empty()) | ||
{ | ||
util::json::Array concavehullArray; | ||
for (engine::plugins::IsochroneNode n : concavehull) | ||
{ | ||
util::json::Object point; | ||
point.values["lat"] = static_cast<double>(util::toFloating(n.node.lat)); | ||
point.values["lon"] = static_cast<double>(util::toFloating(n.node.lon)); | ||
concavehullArray.values.push_back(point); | ||
} | ||
response.values["concavehull"] = std::move(concavehullArray); | ||
} | ||
} | ||
}; | ||
} | ||
} | ||
} | ||
#endif // ENGINE_API_ISOCHRONE_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#ifndef ENGINE_API_ISOCHRONE_PARAMETERS_HPP | ||
#define ENGINE_API_ISOCHRONE_PARAMETERS_HPP | ||
|
||
#include "engine/api/base_parameters.hpp" | ||
|
||
namespace osrm | ||
{ | ||
namespace engine | ||
{ | ||
namespace api | ||
{ | ||
|
||
struct IsochroneParameters : public BaseParameters | ||
{ | ||
unsigned int duration = 0; | ||
double distance = 0; | ||
bool convexhull = false; | ||
bool concavehull = false; | ||
double threshold = 1; // max precision | ||
|
||
bool IsValid() const { return BaseParameters::IsValid(); } | ||
}; | ||
} | ||
} | ||
} | ||
#endif // ENGINE_API_ISOCHRONE_PARAMETERS_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#ifndef ISOCHRONE_HPP | ||
#define ISOCHRONE_HPP | ||
|
||
#include "engine/api/isochrone_parameters.hpp" | ||
#include "engine/plugins/plugin_base.hpp" | ||
#include "osrm/json_container.hpp" | ||
#include "util/binary_heap.hpp" | ||
#include "util/static_graph.hpp" | ||
|
||
#include <boost/bind.hpp> | ||
#include <boost/filesystem.hpp> | ||
#include <boost/filesystem/fstream.hpp> | ||
#include <boost/function.hpp> | ||
#include <tbb/parallel_sort.h> | ||
|
||
#include <algorithm> | ||
#include <cstdlib> | ||
#include <utility> | ||
#include <vector> | ||
|
||
namespace osrm | ||
{ | ||
namespace engine | ||
{ | ||
namespace plugins | ||
{ | ||
struct HeapData | ||
{ | ||
NodeID parent; | ||
HeapData(NodeID p) : parent(p) {} | ||
}; | ||
struct SimpleEdgeData | ||
{ | ||
SimpleEdgeData() : weight(INVALID_EDGE_WEIGHT), real(false) {} | ||
SimpleEdgeData(unsigned weight_, bool real_) : weight(weight_), real(real_) {} | ||
unsigned weight; | ||
bool real; | ||
}; | ||
|
||
struct IsochroneNode | ||
{ | ||
IsochroneNode(){}; | ||
IsochroneNode(osrm::extractor::QueryNode node, | ||
osrm::extractor::QueryNode predecessor, | ||
double distance, | ||
int duration) | ||
: node(node), predecessor(predecessor), distance(distance), duration(duration) | ||
{ | ||
} | ||
|
||
osrm::extractor::QueryNode node; | ||
osrm::extractor::QueryNode predecessor; | ||
double distance; | ||
int duration; | ||
|
||
bool operator==(const IsochroneNode &n) const | ||
{ | ||
if (n.node.node_id == node.node_id) | ||
return true; | ||
else | ||
return false; | ||
} | ||
}; | ||
|
||
using SimpleGraph = util::StaticGraph<SimpleEdgeData>; | ||
using SimpleEdge = SimpleGraph::InputEdge; | ||
using QueryHeap = osrm::util:: | ||
BinaryHeap<NodeID, NodeID, int, HeapData, osrm::util::UnorderedMapStorage<NodeID, int>>; | ||
typedef std::vector<IsochroneNode> IsochroneVector; | ||
|
||
class IsochronePlugin final : public BasePlugin | ||
{ | ||
private: | ||
boost::filesystem::path base; | ||
std::shared_ptr<engine::plugins::SimpleGraph> graph; | ||
std::vector<osrm::extractor::QueryNode> coordinate_list; | ||
std::vector<engine::plugins::SimpleEdge> graph_edge_list; | ||
std::size_t number_of_nodes; | ||
|
||
std::size_t loadGraph(const std::string &path, | ||
std::vector<extractor::QueryNode> &coordinate_list, | ||
std::vector<SimpleEdge> &graph_edge_list); | ||
|
||
void dijkstraByDuration(IsochroneVector &set, NodeID &source, int duration); | ||
void dijkstraByDistance(IsochroneVector &isochroneSet, NodeID &source, double distance); | ||
void update(IsochroneVector &s, IsochroneNode node); | ||
|
||
public: | ||
explicit IsochronePlugin(const std::string base); | ||
|
||
Status HandleRequest(const std::shared_ptr<datafacade::BaseDataFacade> facade, | ||
const api::IsochroneParameters ¶ms, | ||
util::json::Object &json_result); | ||
}; | ||
} | ||
} | ||
} | ||
|
||
#endif // ISOCHRONE_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#ifndef SEARCH_ENGINE_HPP | ||
#define SEARCH_ENGINE_HPP | ||
|
||
#include "engine/routing_algorithms/alternative_path.hpp" | ||
#include "engine/routing_algorithms/direct_shortest_path.hpp" | ||
#include "engine/routing_algorithms/many_to_many.hpp" | ||
#include "engine/routing_algorithms/map_matching.hpp" | ||
#include "engine/routing_algorithms/one_to_many.hpp" | ||
#include "engine/routing_algorithms/shortest_path.hpp" | ||
#include "engine/search_engine_data.hpp" | ||
|
||
#include <type_traits> | ||
|
||
namespace osrm | ||
{ | ||
namespace engine | ||
{ | ||
|
||
template <class DataFacadeT> class SearchEngine | ||
{ | ||
private: | ||
DataFacadeT *facade; | ||
SearchEngineData engine_working_data; | ||
|
||
public: | ||
routing_algorithms::ShortestPathRouting<DataFacadeT> shortest_path; | ||
routing_algorithms::DirectShortestPathRouting<DataFacadeT> direct_shortest_path; | ||
routing_algorithms::AlternativeRouting<DataFacadeT> alternative_path; | ||
routing_algorithms::ManyToManyRouting<DataFacadeT> distance_table; | ||
routing_algorithms::MapMatching<DataFacadeT> map_matching; | ||
routing_algorithms::OneToManyRouting<DataFacadeT> oneToMany; | ||
|
||
explicit SearchEngine(DataFacadeT *facade) | ||
: facade(facade), shortest_path(facade, engine_working_data), | ||
direct_shortest_path(facade, engine_working_data), | ||
alternative_path(facade, engine_working_data), | ||
distance_table(facade, engine_working_data), map_matching(facade, engine_working_data), | ||
oneToMany(facade, engine_working_data) | ||
{ | ||
static_assert(!std::is_pointer<DataFacadeT>::value, "don't instantiate with ptr type"); | ||
static_assert(std::is_object<DataFacadeT>::value, | ||
"don't instantiate with void, function, or reference"); | ||
} | ||
|
||
~SearchEngine() {} | ||
}; | ||
} | ||
} | ||
|
||
#endif // SEARCH_ENGINE_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifndef GLOBAL_ISOCHRONE_PARAMETERS_HPP | ||
#define GLOBAL_ISOCHRONE_PARAMETERS_HPP | ||
|
||
#include "engine/api/isochrone_parameters.hpp" | ||
|
||
namespace osrm | ||
{ | ||
using engine::api::IsochroneParameters; | ||
} | ||
|
||
#endif // GLOBAL_ISOCHRONE_PARAMETERS_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can't compile
datafacade::BaseDataFacade
need to beconst
.