2016-03-10 06:43:36 -05:00
|
|
|
/*
|
|
|
|
|
|
|
|
Copyright (c) 2016, Project OSRM contributors
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without modification,
|
|
|
|
are permitted provided that the following conditions are met:
|
|
|
|
|
|
|
|
Redistributions of source code must retain the above copyright notice, this list
|
|
|
|
of conditions and the following disclaimer.
|
|
|
|
Redistributions in binary form must reproduce the above copyright notice, this
|
|
|
|
list of conditions and the following disclaimer in the documentation and/or
|
|
|
|
other materials provided with the distribution.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
|
|
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2014-11-28 09:00:48 -05:00
|
|
|
#ifndef EXTRACTOR_HPP
|
|
|
|
#define EXTRACTOR_HPP
|
2014-07-02 08:05:37 -04:00
|
|
|
|
2016-01-11 10:55:22 -05:00
|
|
|
#include "extractor/edge_based_edge.hpp"
|
2016-01-02 11:13:44 -05:00
|
|
|
#include "extractor/edge_based_graph_factory.hpp"
|
2016-04-26 07:27:40 -04:00
|
|
|
#include "extractor/extractor_config.hpp"
|
2016-01-02 11:13:44 -05:00
|
|
|
#include "extractor/graph_compressor.hpp"
|
2014-07-02 08:05:37 -04:00
|
|
|
|
2016-04-26 07:27:40 -04:00
|
|
|
#include "util/guidance/bearing_class.hpp"
|
|
|
|
#include "util/guidance/entry_class.hpp"
|
2016-06-30 03:31:08 -04:00
|
|
|
#include "util/guidance/turn_lanes.hpp"
|
2016-04-26 07:27:40 -04:00
|
|
|
|
2016-01-07 04:33:47 -05:00
|
|
|
#include "util/typedefs.hpp"
|
|
|
|
|
2016-01-05 10:51:13 -05:00
|
|
|
namespace osrm
|
|
|
|
{
|
|
|
|
namespace extractor
|
|
|
|
{
|
|
|
|
|
2016-07-11 11:44:58 -04:00
|
|
|
class ScriptingEnvironment;
|
2016-03-22 16:23:25 -04:00
|
|
|
struct ProfileProperties;
|
2016-03-21 17:42:47 -04:00
|
|
|
|
2016-01-07 04:33:47 -05:00
|
|
|
class Extractor
|
2014-07-02 08:05:37 -04:00
|
|
|
{
|
2015-12-11 17:11:04 -05:00
|
|
|
public:
|
2016-01-07 04:33:47 -05:00
|
|
|
Extractor(ExtractorConfig extractor_config) : config(std::move(extractor_config)) {}
|
2016-07-11 11:44:58 -04:00
|
|
|
int run(ScriptingEnvironment &scripting_environment);
|
2015-12-11 17:11:04 -05:00
|
|
|
|
|
|
|
private:
|
2015-10-01 15:47:29 -04:00
|
|
|
ExtractorConfig config;
|
2016-01-07 04:33:47 -05:00
|
|
|
|
2016-06-11 11:23:29 -04:00
|
|
|
std::pair<std::size_t, EdgeID>
|
2016-07-11 11:44:58 -04:00
|
|
|
BuildEdgeExpandedGraph(ScriptingEnvironment &scripting_environment,
|
2017-04-02 19:58:06 -04:00
|
|
|
std::vector<util::Coordinate> &coordinates,
|
2017-04-10 16:15:25 -04:00
|
|
|
extractor::PackedOSMIDs &osm_node_ids,
|
2015-12-11 17:11:04 -05:00
|
|
|
std::vector<EdgeBasedNode> &node_based_edge_list,
|
|
|
|
std::vector<bool> &node_is_startpoint,
|
2016-01-07 04:33:47 -05:00
|
|
|
std::vector<EdgeWeight> &edge_based_node_weights,
|
2016-04-26 07:27:40 -04:00
|
|
|
util::DeallocatingVector<EdgeBasedEdge> &edge_based_edge_list,
|
|
|
|
const std::string &intersection_class_output_file);
|
|
|
|
void WriteProfileProperties(const std::string &output_path,
|
|
|
|
const ProfileProperties &properties) const;
|
2015-12-11 17:11:04 -05:00
|
|
|
void FindComponents(unsigned max_edge_id,
|
2016-01-05 10:51:13 -05:00
|
|
|
const util::DeallocatingVector<EdgeBasedEdge> &edges,
|
2015-12-11 17:11:04 -05:00
|
|
|
std::vector<EdgeBasedNode> &nodes) const;
|
|
|
|
void BuildRTree(std::vector<EdgeBasedNode> node_based_edge_list,
|
|
|
|
std::vector<bool> node_is_startpoint,
|
2017-04-02 19:58:06 -04:00
|
|
|
const std::vector<util::Coordinate> &coordinates);
|
2015-10-01 15:47:29 -04:00
|
|
|
std::shared_ptr<RestrictionMap> LoadRestrictionMap();
|
2016-01-05 10:51:13 -05:00
|
|
|
std::shared_ptr<util::NodeBasedDynamicGraph>
|
2015-10-01 15:47:29 -04:00
|
|
|
LoadNodeBasedGraph(std::unordered_set<NodeID> &barrier_nodes,
|
|
|
|
std::unordered_set<NodeID> &traffic_lights,
|
2017-04-02 19:58:06 -04:00
|
|
|
std::vector<util::Coordinate> &coordinates,
|
2017-04-10 16:15:25 -04:00
|
|
|
extractor::PackedOSMIDs &osm_node_ids);
|
2015-10-01 15:47:29 -04:00
|
|
|
|
2016-01-07 04:33:47 -05:00
|
|
|
void WriteEdgeBasedGraph(const std::string &output_file_filename,
|
2016-06-11 11:23:29 -04:00
|
|
|
const EdgeID max_edge_id,
|
2016-01-05 10:51:13 -05:00
|
|
|
util::DeallocatingVector<EdgeBasedEdge> const &edge_based_edge_list);
|
2016-04-26 07:27:40 -04:00
|
|
|
|
|
|
|
void WriteIntersectionClassificationData(
|
|
|
|
const std::string &output_file_name,
|
|
|
|
const std::vector<std::uint32_t> &node_based_intersection_classes,
|
|
|
|
const std::vector<util::guidance::BearingClass> &bearing_classes,
|
|
|
|
const std::vector<util::guidance::EntryClass> &entry_classes) const;
|
2016-06-30 03:31:08 -04:00
|
|
|
|
|
|
|
void WriteTurnLaneData(const std::string &turn_lane_file) const;
|
|
|
|
|
2017-01-26 11:53:19 -05:00
|
|
|
// Writes compressed node based graph and its embedding into a file for osrm-partition to use.
|
|
|
|
static void WriteCompressedNodeBasedGraph(const std::string &path,
|
|
|
|
const util::NodeBasedDynamicGraph &graph,
|
2017-04-02 19:58:06 -04:00
|
|
|
const std::vector<util::Coordinate> &coordiantes);
|
2017-01-26 11:53:19 -05:00
|
|
|
|
2016-06-30 03:31:08 -04:00
|
|
|
// globals persisting during the extraction process and the graph generation process
|
|
|
|
|
|
|
|
// during turn lane analysis, we might have to combine lanes for roads that are modelled as two
|
|
|
|
// but are more or less experienced as one. This can be due to solid lines in between lanes, for
|
|
|
|
// example, that genereate a small separation between them. As a result, we might have to
|
|
|
|
// augment the turn lane map during processing, further adding more types.
|
|
|
|
guidance::LaneDescriptionMap turn_lane_map;
|
2014-07-02 08:05:37 -04:00
|
|
|
};
|
2016-01-05 10:51:13 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-28 09:00:48 -05:00
|
|
|
#endif /* EXTRACTOR_HPP */
|