本文整理汇总了C++中ImportParameter::GetAreaNodeMinMag方法的典型用法代码示例。如果您正苦于以下问题:C++ ImportParameter::GetAreaNodeMinMag方法的具体用法?C++ ImportParameter::GetAreaNodeMinMag怎么用?C++ ImportParameter::GetAreaNodeMinMag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImportParameter
的用法示例。
在下文中一共展示了ImportParameter::GetAreaNodeMinMag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Import
bool AreaNodeIndexGenerator::Import(const ImportParameter& parameter,
Progress& progress,
const TypeConfig& typeConfig)
{
FileScanner nodeScanner;
FileWriter writer;
std::set<TypeId> remainingNodeTypes; //! Set of types we still must process
std::vector<TypeData> nodeTypeData;
size_t level;
size_t maxLevel=0;
nodeTypeData.resize(typeConfig.GetTypes().size());
if (!nodeScanner.Open(AppendFileToDir(parameter.GetDestinationDirectory(),
"nodes.dat"),
FileScanner::Sequential,
true)) {
progress.Error("Cannot open 'nodes.dat'");
return false;
}
//
// Scanning distribution
//
progress.SetAction("Scanning level distribution of node types");
// Initially we must process all types that represents nodes and that should
// not be ignored
for (size_t i=0; i<typeConfig.GetTypes().size(); i++) {
if (typeConfig.GetTypeInfo(i).CanBeNode() &&
!typeConfig.GetTypeInfo(i).GetIgnore()) {
remainingNodeTypes.insert(i);
}
}
level=parameter.GetAreaNodeMinMag();
while (!remainingNodeTypes.empty()) {
uint32_t nodeCount=0;
std::set<TypeId> currentNodeTypes(remainingNodeTypes);
double cellWidth=360.0/pow(2.0,(int)level);
double cellHeight=180.0/pow(2.0,(int)level);
std::vector<std::map<Pixel,size_t> > cellFillCount;
cellFillCount.resize(typeConfig.GetTypes().size());
progress.Info("Scanning Level "+NumberToString(level)+" ("+NumberToString(remainingNodeTypes.size())+" types still to process)");
nodeScanner.GotoBegin();
if (!nodeScanner.Read(nodeCount)) {
progress.Error("Error while reading number of data entries in file");
return false;
}
for (uint32_t n=1; n<=nodeCount; n++) {
progress.SetProgress(n,nodeCount);
FileOffset offset;
Node node;
nodeScanner.GetPos(offset);
if (!node.Read(nodeScanner)) {
progress.Error(std::string("Error while reading data entry ")+
NumberToString(n)+" of "+
NumberToString(nodeCount)+
" in file '"+
nodeScanner.GetFilename()+"'");
return false;
}
// If we still need to handle this type,
// count number of entries per type and tile cell
if (currentNodeTypes.find(node.GetType())!=currentNodeTypes.end()) {
uint32_t xc=(uint32_t)floor((node.GetLon()+180.0)/cellWidth);
uint32_t yc=(uint32_t)floor((node.GetLat()+90.0)/cellHeight);
cellFillCount[node.GetType()][Pixel(xc,yc)]++;
}
}
// Check statistics for each type
// If statistics are within goal limits, use this level
// for this type (else try again with the next higher level)
for (size_t i=0; i<typeConfig.GetTypes().size(); i++) {
if (currentNodeTypes.find(i)!=currentNodeTypes.end()) {
size_t entryCount=0;
size_t max=0;
nodeTypeData[i].indexLevel=(uint32_t)level;
nodeTypeData[i].indexCells=cellFillCount[i].size();
nodeTypeData[i].indexEntries=0;
if (!cellFillCount[i].empty()) {
nodeTypeData[i].cellXStart=cellFillCount[i].begin()->first.x;
nodeTypeData[i].cellYStart=cellFillCount[i].begin()->first.y;
nodeTypeData[i].cellXEnd=nodeTypeData[i].cellXStart;
nodeTypeData[i].cellYEnd=nodeTypeData[i].cellYStart;
//.........这里部分代码省略.........