Added indexed array data type with variable and fixed group blocks

This commit is contained in:
Michael Krasnyk
2017-01-19 15:14:30 +01:00
committed by Patrick Niklaus
parent cedeb15ade
commit 6e1c4bfecd
15 changed files with 781 additions and 193 deletions
+4 -37
View File
@@ -3,13 +3,13 @@
#include "extractor/extraction_way.hpp"
#include "util/coordinate_calculation.hpp"
#include "util/range_table.hpp"
#include "util/exception.hpp"
#include "util/exception_utils.hpp"
#include "util/fingerprint.hpp"
#include "util/io.hpp"
#include "util/log.hpp"
#include "util/name_table.hpp"
#include "util/timing_util.hpp"
#include <boost/assert.hpp>
@@ -176,43 +176,10 @@ void ExtractionContainers::WriteCharData(const std::string &file_name)
util::UnbufferedLog log;
log << "writing street name index ... ";
TIMER_START(write_index);
boost::filesystem::ofstream file_stream(file_name, std::ios::binary);
boost::filesystem::ofstream file(file_name, std::ios::binary);
// transforms in-place name offsets to name lengths
BOOST_ASSERT(!name_offsets.empty());
for (auto curr = name_offsets.begin(), next = name_offsets.begin() + 1;
next != name_offsets.end();
++curr, ++next)
{
*curr = *next - *curr;
}
// removes the total length sentinel
unsigned total_length = name_offsets.back();
name_offsets.pop_back();
// builds and writes the index
util::RangeTable<> index_range(name_offsets);
file_stream << index_range;
file_stream.write((char *)&total_length, sizeof(unsigned));
// write all chars consecutively
char write_buffer[WRITE_BLOCK_BUFFER_SIZE];
unsigned buffer_len = 0;
for (const auto c : name_char_data)
{
write_buffer[buffer_len++] = c;
if (buffer_len >= WRITE_BLOCK_BUFFER_SIZE)
{
file_stream.write(write_buffer, WRITE_BLOCK_BUFFER_SIZE);
buffer_len = 0;
}
}
file_stream.write(write_buffer, buffer_len);
const util::NameTable::IndexedData indexed_data;
indexed_data.write(file, name_offsets.begin(), name_offsets.end(), name_char_data.begin());
TIMER_STOP(write_index);
log << "ok, after " << TIMER_SEC(write_index) << "s";
+12 -18
View File
@@ -269,40 +269,34 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
const auto road_classification = parsed_way.road_classification;
const constexpr std::size_t MAX_STRING_LENGTH = 255u;
// Get the unique identifier for the street name, destination, and ref
const auto name_iterator = string_map.find(
MapKey(parsed_way.name, parsed_way.destinations, parsed_way.ref, parsed_way.pronunciation));
auto name_id = EMPTY_NAMEID;
NameID name_id = EMPTY_NAMEID;
if (string_map.end() == name_iterator)
{
const auto name_length = std::min(MAX_STRING_LENGTH, parsed_way.name.size());
const auto destinations_length =
std::min(MAX_STRING_LENGTH, parsed_way.destinations.size());
const auto pronunciation_length =
std::min(MAX_STRING_LENGTH, parsed_way.pronunciation.size());
const auto ref_length = std::min(MAX_STRING_LENGTH, parsed_way.ref.size());
// name_offsets already has an offset of a new name, take the offset index as the name id
// name_offsets has a sentinel element with the total name data size
// take the sentinels index as the name id of the new name data pack
// (name [name_id], destination [+1], pronunciation [+2], ref [+3])
name_id = external_memory.name_offsets.size() - 1;
std::copy(parsed_way.name.c_str(),
parsed_way.name.c_str() + name_length,
std::copy(parsed_way.name.begin(),
parsed_way.name.end(),
std::back_inserter(external_memory.name_char_data));
external_memory.name_offsets.push_back(external_memory.name_char_data.size());
std::copy(parsed_way.destinations.c_str(),
parsed_way.destinations.c_str() + destinations_length,
std::copy(parsed_way.destinations.begin(),
parsed_way.destinations.end(),
std::back_inserter(external_memory.name_char_data));
external_memory.name_offsets.push_back(external_memory.name_char_data.size());
std::copy(parsed_way.pronunciation.c_str(),
parsed_way.pronunciation.c_str() + pronunciation_length,
std::copy(parsed_way.pronunciation.begin(),
parsed_way.pronunciation.end(),
std::back_inserter(external_memory.name_char_data));
external_memory.name_offsets.push_back(external_memory.name_char_data.size());
std::copy(parsed_way.ref.c_str(),
parsed_way.ref.c_str() + ref_length,
std::copy(parsed_way.ref.begin(),
parsed_way.ref.end(),
std::back_inserter(external_memory.name_char_data));
external_memory.name_offsets.push_back(external_memory.name_char_data.size());
+1 -1
View File
@@ -574,7 +574,7 @@ TurnHandler::findForkCandidatesByGeometry(Intersection &intersection) const
//
//
// left left
// / \
// / \ 
// /____ right \ ______ right
// | |
// | |