本文整理汇总了C++中ImportParameter::GetAreaAreaIndexMaxMag方法的典型用法代码示例。如果您正苦于以下问题:C++ ImportParameter::GetAreaAreaIndexMaxMag方法的具体用法?C++ ImportParameter::GetAreaAreaIndexMaxMag怎么用?C++ ImportParameter::GetAreaAreaIndexMaxMag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImportParameter
的用法示例。
在下文中一共展示了ImportParameter::GetAreaAreaIndexMaxMag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteIndexLevel
bool AreaAreaIndexGenerator::WriteIndexLevel(const ImportParameter& parameter,
FileWriter& writer,
int level,
std::map<Pixel,AreaLeaf>& leafs)
{
for (std::map<Pixel,AreaLeaf>::iterator leaf=leafs.begin();
leaf!=leafs.end();
++leaf) {
writer.GetPos(leaf->second.offset);
assert(!leaf->second.areas.empty() ||
leaf->second.children[0]!=0 ||
leaf->second.children[1]!=0 ||
leaf->second.children[2]!=0 ||
leaf->second.children[3]!=0);
if (level<(int)parameter.GetAreaAreaIndexMaxMag()) {
for (size_t c=0; c<4; c++) {
if (leaf->second.children[c]==0) {
writer.WriteNumber(0);
}
else {
writer.WriteNumber(leaf->second.children[c]);
}
}
}
FileOffset lastOffset;
// Areas
writer.WriteNumber((uint32_t)leaf->second.areas.size());
lastOffset=0;
for (std::list<Entry>::const_iterator entry=leaf->second.areas.begin();
entry!=leaf->second.areas.end();
entry++) {
writer.WriteNumber(entry->type);
// Since objects are inserted in file position order, we do not need
// to sort objects by file offset at this place
writer.WriteNumber(entry->offset-lastOffset);
lastOffset=entry->offset;
}
}
return !writer.HasError();
}
示例2: Import
bool AreaAreaIndexGenerator::Import(const TypeConfigRef& typeConfig,
const ImportParameter& parameter,
Progress& progress)
{
FileScanner scanner;
size_t areas=0; // Number of areas found
size_t areasConsumed=0; // Number of areas consumed
std::vector<double> cellWidth;
std::vector<double> cellHeight;
std::map<Pixel,AreaLeaf> leafs;
std::map<Pixel,AreaLeaf> newAreaLeafs;
cellWidth.resize(parameter.GetAreaAreaIndexMaxMag()+1);
cellHeight.resize(parameter.GetAreaAreaIndexMaxMag()+1);
for (size_t i=0; i<cellWidth.size(); i++) {
cellWidth[i]=360.0/pow(2.0,(int)i);
}
for (size_t i=0; i<cellHeight.size(); i++) {
cellHeight[i]=180.0/pow(2.0,(int)i);
}
//
// Writing index file
//
progress.SetAction("Generating 'areaarea.idx'");
FileWriter writer;
FileOffset topLevelOffset=0;
FileOffset topLevelOffsetOffset; // Offset of the toplevel entry
if (!writer.Open(AppendFileToDir(parameter.GetDestinationDirectory(),
"areaarea.idx"))) {
progress.Error("Cannot create 'areaarea.idx'");
return false;
}
if (!scanner.Open(AppendFileToDir(parameter.GetDestinationDirectory(),
"areas.dat"),
FileScanner::Sequential,
parameter.GetWayDataMemoryMaped())) {
progress.Error("Cannot open 'areas.dat'");
return false;
}
writer.WriteNumber((uint32_t)parameter.GetAreaAreaIndexMaxMag()); // MaxMag
if (!writer.GetPos(topLevelOffsetOffset)) {
progress.Error("Cannot read current file position");
return false;
}
if (!writer.WriteFileOffset(topLevelOffset)) {
progress.Error("Cannot write top level entry offset");
return false;
}
int l=parameter.GetAreaAreaIndexMaxMag();
while (l>=0) {
size_t areaLevelEntries=0;
progress.Info(std::string("Storing level ")+NumberToString(l)+"...");
newAreaLeafs.clear();
SetOffsetOfChildren(leafs,newAreaLeafs);
leafs=newAreaLeafs;
// Areas
if (areas==0 ||
(areas>0 && areas>areasConsumed)) {
uint32_t areaCount=0;
progress.Info(std::string("Scanning areas.dat for areas of index level ")+NumberToString(l)+"...");
if (!scanner.GotoBegin()) {
progress.Error("Cannot go to begin of way file");
}
if (!scanner.Read(areaCount)) {
progress.Error("Error while reading number of data entries in file");
return false;
}
areas=0;
for (uint32_t a=1; a<=areaCount; a++) {
progress.SetProgress(a,areaCount);
FileOffset offset;
Area area;
scanner.GetPos(offset);
if (!area.Read(typeConfig,
scanner)) {
//.........这里部分代码省略.........