implement geometry uncompressing using STL
This commit is contained in:
parent
4bb5270f25
commit
6d8465a04d
@ -71,8 +71,8 @@ private:
|
|||||||
ShM<char, false>::vector m_names_char_list;
|
ShM<char, false>::vector m_names_char_list;
|
||||||
ShM<unsigned, false>::vector m_name_begin_indices;
|
ShM<unsigned, false>::vector m_name_begin_indices;
|
||||||
ShM<bool, false>::vector m_egde_is_compressed;
|
ShM<bool, false>::vector m_egde_is_compressed;
|
||||||
ShM<unsigned, false>::vector m_compressed_geometry_indices;
|
ShM<unsigned, false>::vector m_geometry_indices;
|
||||||
ShM<unsigned, false>::vector m_compressed_geometries;
|
ShM<unsigned, false>::vector m_geometry_list;
|
||||||
|
|
||||||
boost::shared_ptr<
|
boost::shared_ptr<
|
||||||
StaticRTree<
|
StaticRTree<
|
||||||
@ -189,9 +189,8 @@ private:
|
|||||||
edges_input_stream.close();
|
edges_input_stream.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadGeometries(
|
void LoadGeometries(const boost::filesystem::path & geometry_file)
|
||||||
const boost::filesystem::path & geometry_file
|
{
|
||||||
) {
|
|
||||||
std::ifstream geometry_stream(
|
std::ifstream geometry_stream(
|
||||||
geometry_file.c_str(),
|
geometry_file.c_str(),
|
||||||
std::ios::binary
|
std::ios::binary
|
||||||
@ -203,9 +202,9 @@ private:
|
|||||||
(char *)&number_of_indices,
|
(char *)&number_of_indices,
|
||||||
sizeof(unsigned)
|
sizeof(unsigned)
|
||||||
);
|
);
|
||||||
m_compressed_geometry_indices.resize(number_of_indices);
|
m_geometry_indices.resize(number_of_indices);
|
||||||
geometry_stream.read(
|
geometry_stream.read(
|
||||||
(char *)&(m_compressed_geometry_indices[0]),
|
(char *)&(m_geometry_indices[0]),
|
||||||
number_of_indices*sizeof(unsigned)
|
number_of_indices*sizeof(unsigned)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -214,17 +213,14 @@ private:
|
|||||||
sizeof(unsigned)
|
sizeof(unsigned)
|
||||||
);
|
);
|
||||||
|
|
||||||
BOOST_ASSERT( m_compressed_geometry_indices.back() == number_of_compressed_geometries );
|
BOOST_ASSERT( m_geometry_indices.back() == number_of_compressed_geometries );
|
||||||
m_compressed_geometries.resize( number_of_compressed_geometries );
|
m_geometry_list.resize( number_of_compressed_geometries );
|
||||||
|
|
||||||
geometry_stream.read(
|
geometry_stream.read(
|
||||||
(char *)&(m_compressed_geometries[0]),
|
(char *)&(m_geometry_list[0]),
|
||||||
number_of_compressed_geometries*sizeof(unsigned)
|
number_of_compressed_geometries*sizeof(unsigned)
|
||||||
);
|
);
|
||||||
geometry_stream.close();
|
geometry_stream.close();
|
||||||
|
|
||||||
SimpleLogger().Write() << "number_of_indices: " << number_of_indices;
|
|
||||||
SimpleLogger().Write() << "number_of_compressed_geometries: " << number_of_compressed_geometries;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadRTree(
|
void LoadRTree(
|
||||||
@ -290,6 +286,9 @@ public:
|
|||||||
if( server_paths.find("fileindex") == server_paths.end() ) {
|
if( server_paths.find("fileindex") == server_paths.end() ) {
|
||||||
throw OSRMException("no leaf index file given in ini file");
|
throw OSRMException("no leaf index file given in ini file");
|
||||||
}
|
}
|
||||||
|
if( server_paths.find("geometries") == server_paths.end() ) {
|
||||||
|
throw OSRMException("no geometries file given in ini file");
|
||||||
|
}
|
||||||
if( server_paths.find("nodesdata") == server_paths.end() ) {
|
if( server_paths.find("nodesdata") == server_paths.end() ) {
|
||||||
throw OSRMException("no nodes file given in ini file");
|
throw OSRMException("no nodes file given in ini file");
|
||||||
}
|
}
|
||||||
@ -478,23 +477,16 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual void GetUncompressedGeometry(
|
virtual void GetUncompressedGeometry(
|
||||||
const unsigned node, std::vector<unsigned> & result_nodes
|
const unsigned id, std::vector<unsigned> & result_nodes
|
||||||
) const {
|
) const {
|
||||||
// const NodeID node = m_via_node_list.at(id);
|
const unsigned begin = m_geometry_indices.at(id);
|
||||||
// SimpleLogger().Write() << "translated " << id << " to " << node;
|
const unsigned end = m_geometry_indices.at(id+1);
|
||||||
// SimpleLogger().Write() << "getting geometry from compression bucket " << node << "/" << m_compressed_geometry_indices.size();
|
|
||||||
unsigned begin = m_compressed_geometry_indices.at(node);
|
|
||||||
unsigned end = m_compressed_geometry_indices.at(node+1);
|
|
||||||
// SimpleLogger().Write() << "bucket " << node << " has range [" << begin << "," << end-1 << "]";
|
|
||||||
//TODO: use vector.insert(.)
|
|
||||||
for(unsigned geometry_index = begin; geometry_index < end; ++geometry_index) {
|
|
||||||
unsigned coordinate_id = m_compressed_geometries[geometry_index];
|
|
||||||
// uncomment to use compressed geometry
|
|
||||||
result_nodes.push_back( coordinate_id );
|
|
||||||
// SimpleLogger().Write() << "coordinate " << coordinate_id << " at " << m_coordinate_list->at(coordinate_id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
result_nodes.clear();
|
||||||
|
result_nodes.insert(result_nodes.begin(),
|
||||||
|
m_geometry_list.begin() + begin,
|
||||||
|
m_geometry_list.begin() + end);
|
||||||
|
}
|
||||||
|
|
||||||
std::string GetTimestamp() const {
|
std::string GetTimestamp() const {
|
||||||
return m_timestamp;
|
return m_timestamp;
|
||||||
|
Loading…
Reference in New Issue
Block a user