当前位置: 首页>>代码示例>>C++>>正文


C++ Statistics::Measure方法代码示例

本文整理汇总了C++中Statistics::Measure方法的典型用法代码示例。如果您正苦于以下问题:C++ Statistics::Measure方法的具体用法?C++ Statistics::Measure怎么用?C++ Statistics::Measure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Statistics的用法示例。


在下文中一共展示了Statistics::Measure方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, char* argv[])
{
  if (argc!=2) {
    std::cerr << "CoordinateEncoding <map directory>" << std::endl;
    return 1;
  }

  std::list<Encoder*>   encoders;
  Statistics            statistics;

  encoders.push_back(new TrivialEncoder());
  encoders.push_back(new MinimumVLQDeltaEncoder());
  encoders.push_back(new VLQDeltaEncoder());
  encoders.push_back(new StaticOptimizedDeltaEncoder());

  std::string mapDirectory=argv[1];
  std::string areaDatFilename=osmscout::AppendFileToDir(mapDirectory,"areas.dat");
  std::string wayDatFilename=osmscout::AppendFileToDir(mapDirectory,"ways.dat");

  osmscout::TypeConfig  typeConfig;
  osmscout::FileScanner scanner;
  uint32_t              dataCount;

  std::cout << "Reading type config from map directory '" << mapDirectory << "'..." << std::endl;

  if (!typeConfig.LoadFromDataFile(mapDirectory)) {
    std::cerr << "Cannot open type config" << std::endl;
    return 1;
  }

  /*
  std::cout << "Reading '" << areaDatFilename << "'..." << std::endl;

  if (!scanner.Open(areaDatFilename,osmscout::FileScanner::Sequential,true)) {
    std::cerr << "Cannot open '" << scanner.GetFilename() << "'" << std::endl;
    return 1;
  }

  if (!scanner.Read(dataCount)) {
    std::cerr << "Cannot read number of entries in file" << std::endl;
  }

  std::cout << dataCount << " entries..." << std::endl;

  for (size_t i=1; i<=dataCount; i++) {
    osmscout::Area area;

    if (!area.Read(typeConfig,scanner)) {
      std::cerr << "Cannot read data set #" << i << "'from file " << scanner.GetFilename() << "'" << std::endl;
      return 1;
    }

    for (const auto& ring : area.rings) {
      statistics.Measure(ring.nodes);

      for (auto& encoder : encoders) {
        encoder->Encode(area.GetFileOffset(),ring.nodes);
      }
    }
  }

  scanner.Close();*/

  std::cout << "Reading " << wayDatFilename << "..." << std::endl;

  try {
    scanner.Open(wayDatFilename,osmscout::FileScanner::Sequential,true);

    scanner.Read(dataCount);

    std::cout << dataCount << " entries..." << std::endl;

    for (size_t i=1; i<=dataCount; i++) {
      osmscout::Way way;

      way.Read(typeConfig,scanner);

      for (size_t n =0; n<way.nodes.size(); n++) {
        std::cout << way.GetCoord(n).GetDisplayText() << " ";
      }
      std::cout << std::endl;

      statistics.Measure(way.nodes);

      for (auto& encoder : encoders) {
        encoder->Encode(way.GetFileOffset(),way.nodes);
      }
    }

    scanner.Close();
  }
  catch (osmscout::IOException& e) {
    std::cerr << e.GetDescription() << std::endl;
    return 1;
  }

  std::cout << "---" << std::endl;

  for (auto& encoder : encoders) {
    std::cout << "Encoder: " << encoder->name << " " << encoder->bytesNeeded << std::endl;
//.........这里部分代码省略.........
开发者ID:Dushistov,项目名称:libosmscout,代码行数:101,代码来源:CoordinateEncoding.cpp


注:本文中的Statistics::Measure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。