The SwappyItems Key-Values Store
Classes | Typedefs | Functions
CanalTP Namespace Reference

Classes

struct  Reference
 
struct  warn
 
struct  info
 
struct  fatal
 
struct  Parser
 

Typedefs

typedef std::map< std::string, std::string > Tags
 
typedef std::vector< ReferenceReferences
 

Functions

template<typename Visitor >
void read_osm_pbf (const std::string &filename, Visitor &visitor, bool wayOnly)
 
std::streampos fileSize (const char *filePath)
 
template<typename T >
Tags get_tags (const T &object, const OSMPBF::PrimitiveBlock &primblock)
 

Typedef Documentation

◆ References

typedef std::vector<Reference> CanalTP::References
Examples
osm2graph.cpp.

◆ Tags

typedef std::map<std::string, std::string> CanalTP::Tags
Examples
osm2graph.cpp.

Function Documentation

◆ fileSize()

std::streampos CanalTP::fileSize ( const char *  filePath)
98  {
99  std::streampos begin, end;
100  std::ifstream mfile(filePath, std::ios::binary);
101  begin = mfile.tellg();
102  mfile.seekg (0, std::ios::end);
103  end = mfile.tellg();
104  mfile.close();
105  return end-begin;
106 }

◆ get_tags()

template<typename T >
Tags CanalTP::get_tags ( const T &  object,
const OSMPBF::PrimitiveBlock &  primblock 
)
109  {
110  Tags result;
111  for(int i = 0; i < object.keys_size(); ++i){
112  uint64_t key = object.keys(i);
113  uint64_t val = object.vals(i);
114  std::string key_string = primblock.stringtable().s(key);
115  std::string val_string = primblock.stringtable().s(val);
116  result[key_string] = val_string;
117  }
118  return result;
119 }
std::map< std::string, std::string > Tags
Definition: osmpbfreader.hpp:51

◆ read_osm_pbf()

template<typename Visitor >
void CanalTP::read_osm_pbf ( const std::string &  filename,
Visitor &  visitor,
bool  wayOnly 
)

Read a pbf file and throw via callback (Visitor template got them) data

Parameters
filenamethe filename of the pbf file
visitorthe object, who has the callbacks
wayOnlyphrase the pbf and only act/throw data, if a way tag is readed
Examples
ReadPbfData.cpp, and osm2graph.cpp.
359  {
360  Parser<Visitor> p(filename, visitor, wayOnly);
361  p.parse();
362 }