2012-08-29 12:33:18 -04:00
|
|
|
/*
|
2013-10-14 07:42:28 -04:00
|
|
|
|
2015-02-19 03:19:51 -05:00
|
|
|
Copyright (c) 2015, Project OSRM contributors
|
2013-10-14 07:42:28 -04:00
|
|
|
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.
|
|
|
|
|
|
|
|
*/
|
2012-08-29 12:33:18 -04:00
|
|
|
|
2014-11-28 09:00:48 -05:00
|
|
|
#ifndef EXTRACTION_CONTAINERS_HPP
|
|
|
|
#define EXTRACTION_CONTAINERS_HPP
|
2012-08-29 12:33:18 -04:00
|
|
|
|
2014-11-28 09:00:48 -05:00
|
|
|
#include "internal_extractor_edge.hpp"
|
|
|
|
#include "first_and_last_segment_of_way.hpp"
|
2015-05-29 20:28:29 -04:00
|
|
|
#include "scripting_environment.hpp"
|
2014-11-28 06:13:18 -05:00
|
|
|
#include "../data_structures/external_memory_node.hpp"
|
|
|
|
#include "../data_structures/restriction.hpp"
|
2012-08-29 12:33:18 -04:00
|
|
|
|
2013-11-12 17:33:03 -05:00
|
|
|
#include <stxxl/vector>
|
2015-05-12 19:26:54 -04:00
|
|
|
#include <unordered_map>
|
2013-06-26 09:43:13 -04:00
|
|
|
|
2015-04-10 10:10:00 -04:00
|
|
|
/**
|
|
|
|
* Uses external memory containers from stxxl to store all the data that
|
|
|
|
* is collected by the extractor callbacks.
|
2015-05-09 11:21:36 -04:00
|
|
|
*
|
|
|
|
* The data is the filtered, aggregated and finally written to disk.
|
2015-04-10 10:10:00 -04:00
|
|
|
*/
|
2014-05-09 10:17:31 -04:00
|
|
|
class ExtractionContainers
|
|
|
|
{
|
2014-05-23 11:49:14 -04:00
|
|
|
#ifndef _MSC_VER
|
2015-01-22 06:19:11 -05:00
|
|
|
constexpr static unsigned stxxl_memory =
|
|
|
|
((sizeof(std::size_t) == 4) ? std::numeric_limits<int>::max()
|
|
|
|
: std::numeric_limits<unsigned>::max());
|
2014-05-23 11:49:14 -04:00
|
|
|
#else
|
|
|
|
const static unsigned stxxl_memory = ((sizeof(std::size_t) == 4) ? INT_MAX : UINT_MAX);
|
|
|
|
#endif
|
2015-05-09 11:21:36 -04:00
|
|
|
void PrepareNodes();
|
|
|
|
void PrepareRestrictions();
|
2015-05-29 20:28:29 -04:00
|
|
|
void PrepareEdges(lua_State *segment_state);
|
2015-05-09 11:21:36 -04:00
|
|
|
|
|
|
|
void WriteNodes(std::ofstream& file_out_stream) const;
|
|
|
|
void WriteRestrictions(const std::string& restrictions_file_name) const;
|
|
|
|
void WriteEdges(std::ofstream& file_out_stream) const;
|
|
|
|
void WriteNames(const std::string& names_file_name) const;
|
2014-05-09 10:17:31 -04:00
|
|
|
public:
|
2015-01-22 06:19:11 -05:00
|
|
|
using STXXLNodeIDVector = stxxl::vector<NodeID>;
|
|
|
|
using STXXLNodeVector = stxxl::vector<ExternalMemoryNode>;
|
|
|
|
using STXXLEdgeVector = stxxl::vector<InternalExtractorEdge>;
|
|
|
|
using STXXLStringVector = stxxl::vector<std::string>;
|
|
|
|
using STXXLRestrictionsVector = stxxl::vector<InputRestrictionContainer>;
|
|
|
|
using STXXLWayIDStartEndVector = stxxl::vector<FirstAndLastSegmentOfWay>;
|
2013-11-13 15:23:44 -05:00
|
|
|
|
2014-05-09 10:17:31 -04:00
|
|
|
STXXLNodeIDVector used_node_id_list;
|
|
|
|
STXXLNodeVector all_nodes_list;
|
|
|
|
STXXLEdgeVector all_edges_list;
|
|
|
|
STXXLStringVector name_list;
|
|
|
|
STXXLRestrictionsVector restrictions_list;
|
|
|
|
STXXLWayIDStartEndVector way_start_end_id_list;
|
2015-05-12 19:26:54 -04:00
|
|
|
std::unordered_map<NodeID, NodeID> external_to_internal_node_id_map;
|
2012-08-29 12:33:18 -04:00
|
|
|
|
2014-01-09 10:13:35 -05:00
|
|
|
ExtractionContainers();
|
2013-08-05 11:28:57 -04:00
|
|
|
|
2014-08-18 04:19:33 -04:00
|
|
|
~ExtractionContainers();
|
2012-08-29 12:33:18 -04:00
|
|
|
|
2014-05-09 10:17:31 -04:00
|
|
|
void PrepareData(const std::string &output_file_name,
|
2015-05-09 11:21:36 -04:00
|
|
|
const std::string &restrictions_file_name,
|
2015-05-29 20:28:29 -04:00
|
|
|
const std::string &names_file_name,
|
|
|
|
lua_State *segment_state);
|
2012-08-29 12:33:18 -04:00
|
|
|
};
|
|
|
|
|
2014-11-28 09:00:48 -05:00
|
|
|
#endif /* EXTRACTION_CONTAINERS_HPP */
|