예제 #1
0
std::vector<Lane> read_lane(const char *filename)
{
  int max_id;
  Tbl tbl = read_csv(filename, &max_id);
  size_t i, n = tbl.size();
  std::vector<Lane> ret(max_id + 1, {-1});
  for (i=0; i<n; i++) {
    int id = std::stoi(tbl[i][0]);
    ret[id].lnid = id;
    ret[id].did = std::stoi(tbl[i][1]);
    ret[id].blid = std::stoi(tbl[i][2]);
    ret[id].flid = std::stoi(tbl[i][3]);
    ret[id].bnid = std::stoi(tbl[i][4]);
    ret[id].fnid = std::stoi(tbl[i][5]);
    ret[id].jct = std::stoi(tbl[i][6]);
    ret[id].blid2 = std::stoi(tbl[i][7]);
    ret[id].blid3 = std::stoi(tbl[i][8]);
    ret[id].blid4 = std::stoi(tbl[i][9]);
    ret[id].flid2 = std::stoi(tbl[i][10]);
    ret[id].flid3 = std::stoi(tbl[i][11]);
    ret[id].flid4 = std::stoi(tbl[i][12]);
    ret[id].clossid = std::stoi(tbl[i][13]);
    ret[id].span = std::stod(tbl[i][14]);
    ret[id].lcnt = std::stoi(tbl[i][15]);
    ret[id].lno = std::stoi(tbl[i][16]);
  }
  return ret;
}
예제 #2
0
bool _compare(const /*std::set<std::uint8_t>*/Sample& sample, Tbl& test)
{
    if (sample.size() != test.size())
        return false;
    for (auto a : sample)
        if (test.find(a) == test.end())
        {
            std::cout << "Not found: 0x" << std::setbase(16) << std::setw(2) << std::setfill('0') << /*(unsigned)*/a << std::endl;
            return false;
        }
    return true;
}
예제 #3
0
std::vector<Node> read_node(const char *filename)
{
  int max_id;
  Tbl tbl = read_csv(filename, &max_id);
  size_t i, n = tbl.size();
  std::vector<Node> ret(max_id + 1, {-1});
  for (i=0; i<n; i++) {
    int id = std::stoi(tbl[i][0]);
    ret[id].nid = id;
    ret[id].pid = std::stoi(tbl[i][1]);
  }
  return ret;
}
예제 #4
0
std::vector<RoadEdge> read_roadedge(const char* filename)
{
  int max_id;
  Tbl tbl = read_csv(filename, &max_id);
  size_t i, n = tbl.size();
  std::vector<RoadEdge> ret(max_id + 1, {-1});
  for (i=0; i<n; i++) {
    int id = std::stoi(tbl[i][0]);
    ret[id].id = id;
    ret[id].lid = std::stoi(tbl[i][1]);
    ret[id].linkid = std::stoi(tbl[i][2]);
  }
  return ret;
}
예제 #5
0
std::vector<AreaClass> read_areaclass(const char *filename)
{
  int max_id;
  Tbl tbl = read_csv(filename, &max_id);
  size_t i, n = tbl.size();
  std::vector<AreaClass> ret(max_id + 1, {-1});
  for (i=0; i<n; i++) {
    int id = std::stoi(tbl[i][0]);
    ret[id].aid = id;
    ret[id].slid = std::stoi(tbl[i][1]);
    ret[id].elid = std::stoi(tbl[i][2]);
  }
  return ret;
}
예제 #6
0
std::vector<PoleClass> read_poleclass(const char *filename)
{
  int max_id;
  Tbl tbl = read_csv(filename, &max_id);
  size_t i, n = tbl.size();
  std::vector<PoleClass> ret(max_id + 1, {-1});
  for (i=0; i<n; i++) {
    int id = std::stoi(tbl[i][0]);
    ret[id].plid = id;
    ret[id].vid = std::stoi(tbl[i][1]);
    ret[id].length = std::stod(tbl[i][2]);
    ret[id].dim = std::stod(tbl[i][3]);
  }
  return ret;
}
예제 #7
0
std::vector<VectorClass> read_vectorclass(const char *filename)
{
  int max_id;
  Tbl tbl = read_csv(filename, &max_id);
  size_t i, n = tbl.size();
  std::vector<VectorClass> ret(max_id + 1, {-1});
  for (i=0; i<n; i++) {
    int id = std::stoi(tbl[i][0]);
    ret[id].vid = id;
    ret[id].pid = std::stoi(tbl[i][1]);
    ret[id].hang = std::stod(tbl[i][2]);
    ret[id].vang = std::stod(tbl[i][3]);
  }
  return ret;
}
예제 #8
0
std::vector<GuardRail> read_guardrail(const char* filename)
{
  int max_id;
  Tbl tbl = read_csv(filename, &max_id);
  size_t i, n = tbl.size();
  std::vector<GuardRail> ret(max_id + 1, {-1});
  for (i=0; i<n; i++) {
    int id = std::stoi(tbl[i][0]);
    ret[id].id = id;
    ret[id].aid = std::stoi(tbl[i][1]);
    ret[id].type = std::stoi(tbl[i][2]);
    ret[id].linkid = std::stoi(tbl[i][3]);
  }
  return ret;
}
예제 #9
0
std::vector<StreetLight> read_streetlight(const char *filename)
{
  int max_id;
  Tbl tbl = read_csv(filename, &max_id);
  size_t i, n = tbl.size();
  std::vector<StreetLight> ret(max_id + 1, {-1});
  for (i=0; i<n; i++) {
    int id = std::stoi(tbl[i][0]);
    ret[id].id = id;
    ret[id].lid = std::stoi(tbl[i][1]);
    ret[id].plid = std::stoi(tbl[i][2]);
    ret[id].linkid = std::stoi(tbl[i][3]);
  }
  return ret;
}
예제 #10
0
std::vector<RoadMark> read_roadmark(const char* filename)
{
  int max_id;
  Tbl tbl = read_csv(filename, &max_id);
  size_t i, n = tbl.size();
  std::vector<RoadMark> ret(max_id + 1, {-1});
  for (i=0; i<n; i++) {
    int id = std::stoi(tbl[i][0]);
    ret[id].id = id;
    ret[id].aid = std::stoi(tbl[i][1]);
    ret[id].type = std::stoi(tbl[i][2]); // Don't use wide character
    ret[id].linkid = std::stoi(tbl[i][3]);
  }
  return ret;
}
예제 #11
0
std::vector<LineClass> read_lineclass(const char *filename)
{
  int max_id;
  Tbl tbl = read_csv(filename, &max_id);
  size_t i, n = tbl.size();
  std::vector<LineClass> ret(max_id + 1, {-1});
  for (i=0; i<n; i++) {
    int id = std::stoi(tbl[i][0]);
    ret[id].lid = id;
    ret[id].bpid = std::stoi(tbl[i][1]);
    ret[id].fpid = std::stoi(tbl[i][2]);
    ret[id].blid = std::stoi(tbl[i][3]);
    ret[id].flid = std::stoi(tbl[i][4]);
  }
  return ret;
}
예제 #12
0
std::vector<PcdFileRange> read_pcdfilerange(const char* filename, double margin)
{
  Tbl tbl = read_csv(filename);
  size_t i, n = tbl.size();
  std::vector<PcdFileRange> ret(n);
  for (i=0; i<n; i++) {
    ret[i].name = tbl[i][0];
    ret[i].x_min = std::stod(tbl[i][1]) - margin;
    ret[i].y_min = std::stod(tbl[i][2]) - margin;
    ret[i].z_min = std::stod(tbl[i][3]) - margin;
    ret[i].x_max = std::stod(tbl[i][4]) + margin;
    ret[i].y_max = std::stod(tbl[i][5]) + margin;
    ret[i].z_max = std::stod(tbl[i][6]) + margin;
  }
  return ret;
}
예제 #13
0
std::vector<WhiteLine> read_whiteline(const char* filename)
{
  int max_id;
  Tbl tbl = read_csv(filename, &max_id);
  size_t i, n = tbl.size();
  std::vector<WhiteLine> ret(max_id + 1, {-1});
  for (i=0; i<n; i++) {
    int id = std::stoi(tbl[i][0]);
    ret[id].id = id;
    ret[id].lid = std::stoi(tbl[i][1]);
    ret[id].width = std::stod(tbl[i][2]);
    ret[id].color = tbl[i][3].c_str()[0];
    ret[id].type = std::stoi(tbl[i][4]);
    ret[id].linkid = std::stoi(tbl[i][5]);
  }
  return ret;
}
예제 #14
0
std::vector<BoxClass> read_boxclass(const char *filename)
{
  int max_id;
  Tbl tbl = read_csv(filename, &max_id);
  size_t i, n = tbl.size();
  std::vector<BoxClass> ret(max_id + 1, {-1});
  for (i=0; i<n; i++) {
    int id = std::stoi(tbl[i][0]);
    ret[id].bid = id;
    ret[id].pid1 = std::stoi(tbl[i][1]);
    ret[id].pid2 = std::stoi(tbl[i][2]);
    ret[id].pid3 = std::stoi(tbl[i][3]);
    ret[id].pid4 = std::stoi(tbl[i][4]);
    ret[id].height = std::stod(tbl[i][5]);
  }
  return ret;
}
예제 #15
0
std::vector<Curb> read_curb(const char* filename)
{
  int max_id;
  Tbl tbl = read_csv(filename, &max_id);
  size_t i, n = tbl.size();
  std::vector<Curb> ret(max_id + 1, {-1});
  for (i=0; i<n; i++) {
    int id = std::stoi(tbl[i][0]);
    ret[id].id = id;
    ret[id].lid = std::stoi(tbl[i][1]);
    ret[id].height = std::stod(tbl[i][2]);
    ret[id].width = std::stod(tbl[i][3]);
    ret[id].dir = std::stoi(tbl[i][4]);
    ret[id].linkid = std::stoi(tbl[i][5]);
  }
  return ret;
}
예제 #16
0
std::set<std::string> _randomize_array(Tbl& tbl, F && f)
{
    std::set<std::string> result;
    while (tbl.size() < tbl.capacity())
    {
        std::string s;
        auto l = (std::rand() % (Tbl::chunk_limit_c-1))+1;
        while (l--)
            s+=(static_cast<char>(std::rand() % ('_' - '0')) + '0');
        
        if (tbl.insert(s.begin(), s.end()) != tbl.end())
        {
            result.insert(s);
            f();
        }
    }
    return result;
}
예제 #17
0
Tbl read_csv(const char* filename)
{
  std::ifstream ifs(filename);
  std::string line;

  Tbl tbl;

  while (std::getline(ifs, line)) {
    std::istringstream ss(line);

    std::vector<std::string> columns;
    std::string column;
    while (std::getline(ss, column, ',')) {
      columns.push_back(column);
    }
    tbl.push_back(columns);
  }
  return tbl;
}
예제 #18
0
std::vector<PointClass> read_pointclass(const char *filename)
{
  int max_id;
  Tbl tbl = read_csv(filename, &max_id);
  size_t i, n = tbl.size();
  std::vector<PointClass> ret(max_id + 1, {-1});
  for (i=0; i<n; i++) {
    int id = std::stoi(tbl[i][0]);
    ret[id].pid = id;
    ret[id].b = std::stod(tbl[i][1]);
    ret[id].l = std::stod(tbl[i][2]);
    ret[id].h = std::stod(tbl[i][3]);
    ret[id].bx = std::stod(tbl[i][4]);
    ret[id].ly = std::stod(tbl[i][5]);
    ret[id].ref = std::stoi(tbl[i][6]);
    ret[id].mcode1 = std::stoi(tbl[i][7]);
    ret[id].mcode2 = std::stoi(tbl[i][8]);
    ret[id].mcode3 = std::stoi(tbl[i][9]);
  }
  return ret;
}
예제 #19
0
std::vector<DTLane> read_dtlane(const char *filename)
{
  int max_id;
  Tbl tbl = read_csv(filename, &max_id);
  size_t i, n = tbl.size();
  std::vector<DTLane> ret(max_id + 1, {-1});
  for (i=0; i<n; i++) {
    int id = std::stoi(tbl[i][0]);
    ret[id].did = id;
    ret[id].dist = std::stod(tbl[i][1]);
    ret[id].pid = std::stoi(tbl[i][2]);
    ret[id].dir = std::stod(tbl[i][3]);
    ret[id].apara = std::stod(tbl[i][4]);
    ret[id].r = std::stod(tbl[i][5]);
    ret[id].slope = std::stod(tbl[i][6]);
    ret[id].cant = std::stod(tbl[i][7]);
    ret[id].lw = std::stod(tbl[i][8]);
    ret[id].rw = std::stod(tbl[i][9]);
  }
  return ret;
}
예제 #20
0
Tbl read_csv(const char* filename, int* max_id)
{
  std::ifstream ifs(filename);
  std::string line;
  std::getline(ifs, line); // Remove first line

  Tbl tbl;

  *max_id = -1;
  while (std::getline(ifs, line)) {
    std::istringstream ss(line);

    std::vector<std::string> columns;
    std::string column;
    while (std::getline(ss, column, ',')) {
      columns.push_back(column);
    }
    tbl.push_back(columns);

    int id = std::stoi(columns[0]);
    if (id > *max_id) *max_id = id;
  }
  return tbl;
}