Пример #1
0
  void AreaWayIndexGenerator::CalculateStatistics(size_t level,
                                                  TypeData& typeData,
                                                  const CoordCountMap& cellFillCount)
  {
    typeData.indexLevel=(uint32_t)level;
    typeData.indexCells=cellFillCount.size();
    typeData.indexEntries=0;

    // If we do not have any entries, we store it now
    if (cellFillCount.empty()) {
      return;
    }

    typeData.cellXStart=cellFillCount.begin()->first.x;
    typeData.cellYStart=cellFillCount.begin()->first.y;

    typeData.cellXEnd=typeData.cellXStart;
    typeData.cellYEnd=typeData.cellYStart;

    for (CoordCountMap::const_iterator cell=cellFillCount.begin();
         cell!=cellFillCount.end();
         ++cell) {
      typeData.indexEntries+=cell->second;

      typeData.cellXStart=std::min(typeData.cellXStart,cell->first.x);
      typeData.cellXEnd=std::max(typeData.cellXEnd,cell->first.x);

      typeData.cellYStart=std::min(typeData.cellYStart,cell->first.y);
      typeData.cellYEnd=std::max(typeData.cellYEnd,cell->first.y);
    }

    typeData.cellXCount=typeData.cellXEnd-typeData.cellXStart+1;
    typeData.cellYCount=typeData.cellYEnd-typeData.cellYStart+1;
  }
  /**
   * Calculate internal statistics that are the base for deciding if the given way type is
   * indexed at the given index level.
   * @param level
   * @param typeData
   * @param cellFillCount
   */
  void AreaWayIndexGenerator::CalculateStatistics(size_t level,
                                                  TypeData& typeData,
                                                  const CoordCountMap& cellFillCount) const
  {
    // Initialize/reset data structure
    typeData.indexLevel=(uint32_t)level;
    typeData.indexCells=cellFillCount.size();
    typeData.indexEntries=0;

    // If we do not have any entries, we are done ;-)
    if (cellFillCount.empty()) {
      return;
    }

    typeData.cellXStart=cellFillCount.begin()->first.x;
    typeData.cellYStart=cellFillCount.begin()->first.y;

    typeData.cellXEnd=typeData.cellXStart;
    typeData.cellYEnd=typeData.cellYStart;

    for (const auto& cell : cellFillCount) {
      typeData.indexEntries+=cell.second;

      typeData.cellXStart=std::min(typeData.cellXStart,cell.first.x);
      typeData.cellXEnd=std::max(typeData.cellXEnd,cell.first.x);

      typeData.cellYStart=std::min(typeData.cellYStart,cell.first.y);
      typeData.cellYEnd=std::max(typeData.cellYEnd,cell.first.y);
    }

    typeData.cellXCount=typeData.cellXEnd-typeData.cellXStart+1;
    typeData.cellYCount=typeData.cellYEnd-typeData.cellYStart+1;
  }