本文整理汇总了C++中TypeInfoSet类的典型用法代码示例。如果您正苦于以下问题:C++ TypeInfoSet类的具体用法?C++ TypeInfoSet怎么用?C++ TypeInfoSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TypeInfoSet类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: subset
void DataTileCache::ResolveAreasFromParent(Tile& tile,
const Tile& parentTile,
const GeoBox& boundingBox,
const TypeInfoSet& areaTypes)
{
if (areaTypes.Intersects(parentTile.GetAreaData().GetTypes())) {
TypeInfoSet subset(areaTypes);
subset.Intersection(parentTile.GetAreaData().GetTypes());
std::vector<AreaRef> data;
data.reserve(parentTile.GetAreaData().GetDataSize());
parentTile.GetAreaData().CopyData([&](const AreaRef& area) {
if (areaTypes.IsSet(area->GetType())) {
GeoBox areaBoundingBox;
area->GetBoundingBox(areaBoundingBox);
if (areaBoundingBox.Intersects(boundingBox)) {
data.push_back(area);
}
}
});
tile.GetAreaData().SetPrefillData(subset,
data);
}
}
开发者ID:Framstag,项目名称:libosmscout,代码行数:30,代码来源:DataTileCache.cpp
示例2: GetAreas
bool OptimizeAreasLowZoomGenerator::GetAreas(const TypeConfig& typeConfig,
const ImportParameter& parameter,
Progress& progress,
FileScanner& scanner,
const TypeInfoSet& types,
std::vector<std::list<AreaRef> >& areas,
TypeInfoSet& loadedTypes)
{
uint32_t areaCount=0;
size_t collectedAreasCount=0;
loadedTypes=types;
progress.SetAction("Collecting area data to optimize");
scanner.GotoBegin();
scanner.Read(areaCount);
for (uint32_t a=1; a<=areaCount; a++) {
AreaRef area=std::make_shared<Area>();
progress.SetProgress(a,areaCount);
area->Read(typeConfig,
scanner);
if (loadedTypes.IsSet(area->GetType())) {
areas[area->GetType()->GetIndex()].push_back(area);
collectedAreasCount++;
while (collectedAreasCount>parameter.GetOptimizationMaxWayCount() &&
loadedTypes.Size()>1) {
TypeInfoRef victimType;
for (auto &type : loadedTypes) {
if (areas[type->GetIndex()].size()>0 &&
(!victimType ||
areas[type->GetIndex()].size()<areas[victimType->GetIndex()].size())) {
victimType=type;
}
}
assert(victimType);
collectedAreasCount-=areas[victimType->GetIndex()].size();
areas[victimType->GetIndex()].clear();
loadedTypes.Remove(victimType);
}
}
}
progress.Info("Collected "+NumberToString(collectedAreasCount)+" areas for "+NumberToString(loadedTypes.Size())+" types");
return !scanner.HasError();
}
开发者ID:mstar0125,项目名称:libosmscout,代码行数:57,代码来源:GenOptimizeAreasLowZoom.cpp
示例3: GetAreaTypesToOptimize
void OptimizeAreasLowZoomGenerator::GetAreaTypesToOptimize(const TypeConfig& typeConfig,
TypeInfoSet& types)
{
types.Clear();
for (auto &type : typeConfig.GetAreaTypes()) {
if (!type->GetIgnore() &&
type->GetOptimizeLowZoom()) {
types.Set(type);
}
}
}
开发者ID:mstar0125,项目名称:libosmscout,代码行数:12,代码来源:GenOptimizeAreasLowZoom.cpp
示例4: dispatch
void Dispatcher::
dispatch (SyntaxTree::NodePtr const& n)
{
LevelMap levels;
unsigned long max = compute_levels (n->type_info (), 0, levels);
//cerr << "starting dispatch process for "
// << n->type_info ().type_id () << " with "
// << max << " levels" << endl;
for (unsigned long l = 0; l < max + 1; l++)
{
TypeInfoSet dispatched;
for (LevelMap::const_iterator i = levels.begin ();
i != levels.end ();
i++)
{
if (i->second == l)
{
TraversalMap::const_iterator v =
traversal_map_.find (i->first.type_id ());
if (v != traversal_map_.end () && !(v->second.suppressed))
{
//cerr << "dispatching traverser for "
// << n->type_info ().type_id () << " as "
// << i->first.type_id () << endl;
v->second.traverser->traverse (n);
flatten_tree (i->first, dispatched);
}
}
}
// Remove traversed types from level map.
for (TypeInfoSet::const_iterator i = dispatched.begin ();
i != dispatched.end ();
i++)
{
levels.erase (*i);
}
}
}
开发者ID:jwillemsen,项目名称:XSC,代码行数:45,代码来源:Traversal.cpp
示例5: flatten_tree
void
flatten_tree (TypeInfo const& ti, TypeInfoSet& set)
{
set.insert (ti);
for (TypeInfo::BaseIterator i = ti.begin_base ();
i != ti.end_base ();
i++)
{
flatten_tree (i->type_info (), set);
}
}
开发者ID:jwillemsen,项目名称:XSC,代码行数:12,代码来源:Traversal.cpp
示例6: dispatch
void Dispatcher::
dispatch (SyntaxTree::Node* n)
{
LevelMap levels;
unsigned long max = compute_levels (n->type_info (), 0, levels);
for (unsigned long l = 0; l < max + 1; l++)
{
TypeInfoSet dispatched;
for (LevelMap::const_iterator i = levels.begin ();
i != levels.end ();
i++)
{
if (i->second == l)
{
TraversalMap::const_iterator v =
traversal_map_.find (i->first.type_id ());
if (v != traversal_map_.end ())
{
v->second->traverse (n);
flatten_tree (i->first, dispatched);
}
}
}
// Remove traversed types from level map.
for (TypeInfoSet::const_iterator i = dispatched.begin ();
i != dispatched.end ();
i++)
{
levels.erase (*i);
}
}
}
开发者ID:EnasAlikhashashashneh,项目名称:OASIS,代码行数:37,代码来源:Traversal.cpp
示例7: ScanAreaNodeIds
/**
* Scans all areas. If an areas is of one of the given merge types, index all node ids
* into the given NodeUseMap for all outer rings of the given area.
*/
bool MergeAreasGenerator::ScanAreaNodeIds(Progress& progress,
const TypeConfig& typeConfig,
FileScanner& scanner,
const TypeInfoSet& mergeTypes,
std::unordered_set<Id>& nodeUseMap)
{
uint32_t areaCount=0;
progress.SetAction("Scanning for nodes joining areas from '"+scanner.GetFilename()+"'");
scanner.GotoBegin();
scanner.Read(areaCount);
uint8_t type;
Id id;
Area data;
std::unordered_set<Id> usedOnceSet;
for (uint32_t current=1; current<=areaCount; current++) {
progress.SetProgress(current,areaCount);
scanner.Read(type);
scanner.Read(id);
data.ReadImport(typeConfig,
scanner);
if (!mergeTypes.IsSet(data.GetType())) {
continue;
}
// We insert every node id only once per area, because we want to
// find nodes that are shared by *different* areas.
std::unordered_set<Id> nodeIds;
for (const auto& ring: data.rings) {
if (!ring.IsOuterRing()) {
continue;
}
for (const auto node : ring.nodes) {
Id id=node.GetId();
if (nodeIds.find(id)==nodeIds.end()) {
auto entry=usedOnceSet.find(id);
if (entry!=usedOnceSet.end()) {
nodeUseMap.insert(id);
}
else {
usedOnceSet.insert(id);
}
nodeIds.insert(id);
}
}
}
}
return true;
}
开发者ID:Dushistov,项目名称:libosmscout,代码行数:67,代码来源:GenMergeAreas.cpp
示例8: while
bool MergeAreasGenerator::Import(const TypeConfigRef& typeConfig,
const ImportParameter& parameter,
Progress& progress)
{
TypeInfoSet mergeTypes;
FileScanner scanner;
FileWriter writer;
uint32_t areasWritten=0;
for (const auto& type : typeConfig->GetTypes()) {
if (type->CanBeArea() &&
type->GetMergeAreas()) {
mergeTypes.Set(type);
}
}
std::unordered_set<Id> nodeUseMap;
try {
scanner.Open(AppendFileToDir(parameter.GetDestinationDirectory(),
MergeAreaDataGenerator::AREAS_TMP),
FileScanner::Sequential,
parameter.GetRawWayDataMemoryMaped());
if (!ScanAreaNodeIds(progress,
*typeConfig,
scanner,
mergeTypes,
nodeUseMap)) {
return false;
}
uint32_t nodeCount=nodeUseMap.size();
progress.Info("Found "+NumberToString(nodeCount)+" nodes as possible connection points for areas");
/* ------ */
writer.Open(AppendFileToDir(parameter.GetDestinationDirectory(),
AREAS2_TMP));
writer.Write(areasWritten);
while (true) {
TypeInfoSet loadedTypes;
std::vector<AreaMergeData> mergeJob(typeConfig->GetTypeCount());
//
// Load type data
//
progress.SetAction("Collecting area data by type");
if (!GetAreas(parameter,
progress,
*typeConfig,
mergeTypes,
loadedTypes,
nodeUseMap,
scanner,
writer,
mergeJob,
areasWritten)) {
return false;
}
// Merge
progress.SetAction("Merging areas");
for (const auto& type : loadedTypes) {
if (!mergeJob[type->GetIndex()].areas.empty()) {
progress.Info("Merging areas of type "+type->GetName());
MergeAreas(progress,
nodeUseMap,
mergeJob[type->GetIndex()]);
progress.Info("Reduced areas of '"+type->GetName()+"' from "+NumberToString(mergeJob[type->GetIndex()].areaCount)+" to "+NumberToString(mergeJob[type->GetIndex()].areaCount-mergeJob[type->GetIndex()].mergedAway.size()));
mergeJob[type->GetIndex()].areas.clear();
}
}
// Store back merge result
if (!loadedTypes.Empty()) {
if (!WriteMergeResult(progress,
*typeConfig,
scanner,
writer,
loadedTypes,
mergeJob,
areasWritten)) {
return false;
}
mergeTypes.Remove(loadedTypes);
}
if (mergeTypes.Empty()) {
//.........这里部分代码省略.........
开发者ID:Dushistov,项目名称:libosmscout,代码行数:101,代码来源:GenMergeAreas.cpp
示例9: WriteMergeResult
bool MergeAreasGenerator::WriteMergeResult(Progress& progress,
const TypeConfig& typeConfig,
FileScanner& scanner,
FileWriter& writer,
const TypeInfoSet& loadedTypes,
std::vector<AreaMergeData>& mergeJob,
uint32_t& areasWritten)
{
uint32_t areaCount=0;
std::unordered_map<FileOffset,AreaRef> merges;
std::unordered_set<FileOffset> ignores;
for (const auto& type : loadedTypes) {
for (const auto& area : mergeJob[type->GetIndex()].merges) {
merges[area->GetFileOffset()]=area;
}
ignores.insert(mergeJob[type->GetIndex()].mergedAway.begin(),
mergeJob[type->GetIndex()].mergedAway.end());
}
scanner.GotoBegin();
scanner.Read(areaCount);
for (uint32_t a=1; a<=areaCount; a++) {
uint8_t type;
Id id;
AreaRef area=std::make_shared<Area>();
progress.SetProgress(a,areaCount);
scanner.Read(type);
scanner.Read(id);
area->ReadImport(typeConfig,
scanner);
if (loadedTypes.IsSet(area->GetType())) {
if (ignores.find(area->GetFileOffset())!=ignores.end()) {
continue;
}
writer.Write(type);
writer.Write(id);
const auto& merge=merges.find(area->GetFileOffset()) ;
if (merge!=merges.end()) {
area=merge->second;
}
area->WriteImport(typeConfig,
writer);
areasWritten++;
}
}
return true;
}
开发者ID:Dushistov,项目名称:libosmscout,代码行数:61,代码来源:GenMergeAreas.cpp
示例10: GetAreas
/**
* Load areas which has a one for the types given by types. If at leats one node
* in one of the outer rings of the areas is marked in nodeUseMap as "used at least twice",
* index it into the areas map.
*
* If the number of indexed areas is bigger than parameter.GetRawWayBlockSize() types are
* dropped form areas until the number is again below the lmit.
*/
bool MergeAreasGenerator::GetAreas(const ImportParameter& parameter,
Progress& progress,
const TypeConfig& typeConfig,
const TypeInfoSet& candidateTypes,
TypeInfoSet& loadedTypes,
const std::unordered_set<Id>& nodeUseMap,
FileScanner& scanner,
FileWriter& writer,
std::vector<AreaMergeData>& mergeJob,
uint32_t& areasWritten)
{
bool firstCall=areasWritten==0; // We are called for the first time
uint32_t areaCount=0;
size_t collectedAreasCount=0;
size_t typesWithAreas=0;
for (auto& data : mergeJob) {
data.areaCount=0;
}
loadedTypes=candidateTypes;
scanner.GotoBegin();
scanner.Read(areaCount);
for (uint32_t a=1; a<=areaCount; a++) {
uint8_t type;
Id id;
AreaRef area=std::make_shared<Area>();
progress.SetProgress(a,areaCount);
scanner.Read(type);
scanner.Read(id);
area->ReadImport(typeConfig,
scanner);
mergeJob[area->GetType()->GetIndex()].areaCount++;
// This is an area of a type that does not get merged,
// we directly store it in the target file.
if (!loadedTypes.IsSet(area->GetType())) {
if (firstCall) {
writer.Write(type);
writer.Write(id);
area->WriteImport(typeConfig,
writer);
areasWritten++;
}
continue;
}
bool isMergeCandidate=false;
for (const auto& ring: area->rings) {
if (!ring.IsOuterRing()) {
continue;
}
for (const auto node : ring.nodes) {
if (nodeUseMap.find(node.GetId())!=nodeUseMap.end()) {
isMergeCandidate=true;
break;
}
}
if (isMergeCandidate) {
break;
}
}
if (!isMergeCandidate) {
continue;
}
if (mergeJob[area->GetType()->GetIndex()].areas.empty()) {
typesWithAreas++;
}
mergeJob[area->GetType()->GetIndex()].areas.push_back(area);
collectedAreasCount++;
while (collectedAreasCount>parameter.GetRawWayBlockSize() &&
typesWithAreas>1) {
TypeInfoRef victimType;
//.........这里部分代码省略.........
开发者ID:Dushistov,项目名称:libosmscout,代码行数:101,代码来源:GenMergeAreas.cpp
示例11: while
bool AreaWayIndexGenerator::CalculateDistribution(const TypeConfigRef& typeConfig,
const ImportParameter& parameter,
Progress& progress,
std::vector<TypeData>& wayTypeData,
size_t& maxLevel) const
{
FileScanner wayScanner;
TypeInfoSet remainingWayTypes;
size_t level;
maxLevel=0;
wayTypeData.resize(typeConfig->GetTypeCount());
if (!wayScanner.Open(AppendFileToDir(parameter.GetDestinationDirectory(),
"ways.dat"),
FileScanner::Sequential,
parameter.GetWayDataMemoryMaped())) {
progress.Error("Cannot open 'ways.dat'");
return false;
}
remainingWayTypes.Set(typeConfig->GetWayTypes());
level=parameter.GetAreaWayMinMag();
while (!remainingWayTypes.Empty()) {
uint32_t wayCount=0;
TypeInfoSet currentWayTypes(remainingWayTypes);
double cellWidth=360.0/pow(2.0,(int)level);
double cellHeight=180.0/pow(2.0,(int)level);
std::vector<CoordCountMap> cellFillCount(typeConfig->GetTypeCount());
progress.Info("Scanning Level "+NumberToString(level)+" ("+NumberToString(remainingWayTypes.Size())+" types remaining)");
wayScanner.GotoBegin();
if (!wayScanner.Read(wayCount)) {
progress.Error("Error while reading number of data entries in file");
return false;
}
Way way;
for (uint32_t w=1; w<=wayCount; w++) {
progress.SetProgress(w,wayCount);
if (!way.Read(*typeConfig,
wayScanner)) {
progress.Error(std::string("Error while reading data entry ")+
NumberToString(w)+" of "+
NumberToString(wayCount)+
" in file '"+
wayScanner.GetFilename()+"'");
return false;
}
// Count number of entries per current type and coordinate
if (!currentWayTypes.IsSet(way.GetType())) {
continue;
}
GeoBox boundingBox;
way.GetBoundingBox(boundingBox);
//
// Calculate minimum and maximum tile ids that are covered
// by the way
// Renormalized coordinate space (everything is >=0)
//
uint32_t minxc=(uint32_t)floor((boundingBox.GetMinLon()+180.0)/cellWidth);
uint32_t maxxc=(uint32_t)floor((boundingBox.GetMaxLon()+180.0)/cellWidth);
uint32_t minyc=(uint32_t)floor((boundingBox.GetMinLat()+90.0)/cellHeight);
uint32_t maxyc=(uint32_t)floor((boundingBox.GetMaxLat()+90.0)/cellHeight);
for (uint32_t y=minyc; y<=maxyc; y++) {
for (uint32_t x=minxc; x<=maxxc; x++) {
cellFillCount[way.GetType()->GetIndex()][Pixel(x,y)]++;
}
}
}
// Check if cell fill for current type is in defined limits
for (auto &type : currentWayTypes) {
size_t i=type->GetIndex();
CalculateStatistics(level,
wayTypeData[i],
cellFillCount[i]);
if (!FitsIndexCriteria(parameter,
progress,
*typeConfig->GetTypeInfo(i),
wayTypeData[i],
cellFillCount[i])) {
currentWayTypes.Remove(type);
}
}
for (const auto &type : currentWayTypes) {
maxLevel=std::max(maxLevel,level);
//.........这里部分代码省略.........
开发者ID:AQbernhard,项目名称:OSMScout-ubuntu,代码行数:101,代码来源:GenAreaWayIndex.cpp
注:本文中的TypeInfoSet类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论