本文整理汇总了C++中TypeConfig类的典型用法代码示例。如果您正苦于以下问题:C++ TypeConfig类的具体用法?C++ TypeConfig怎么用?C++ TypeConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TypeConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessRelation
void Preprocess::ProcessRelation(const TypeConfig& typeConfig,
const OSMId& id,
const std::vector<RawRelation::Member>& members,
const std::map<TagId,std::string>& tagMap)
{
RawRelation relation;
TypeId type;
if (id<lastRelationId) {
relationSortingError=true;
}
relation.SetId(id);
relation.members=members;
typeConfig.GetRelationTypeId(tagMap,type);
typeConfig.ResolveTags(tagMap,relation.tags);
relation.SetType(type);
relation.Write(relationWriter);
relationCount++;
lastRelationId=id;
}
示例2: Read
bool RawNode::Read(const TypeConfig& typeConfig,
FileScanner& scanner)
{
if (!scanner.ReadNumber(id)) {
return false;
}
TypeId typeId;
if (!scanner.ReadTypeId(typeId,
typeConfig.GetNodeTypeIdBytes())) {
return false;
}
TypeInfoRef type=typeConfig.GetNodeTypeInfo(typeId);
featureValueBuffer.SetType(type);
if (!type->GetIgnore()) {
if (!featureValueBuffer.Read(scanner)) {
return false;
}
}
if (!scanner.ReadCoord(coords)) {
return false;
}
return !scanner.HasError();
}
示例3: ReadOptimized
bool Way::ReadOptimized(const TypeConfig& typeConfig,
FileScanner& scanner)
{
if (!scanner.GetPos(fileOffset)) {
return false;
}
TypeId typeId;
scanner.ReadTypeId(typeId,
typeConfig.GetWayTypeIdBytes());
TypeInfoRef type=typeConfig.GetWayTypeInfo(typeId);
featureValueBuffer.SetType(type);
if (!featureValueBuffer.Read(scanner)) {
return false;
}
if (!scanner.Read(nodes)) {
return false;
}
return !scanner.HasError();
}
示例4: WriteOptimized
bool Area::WriteOptimized(const TypeConfig& typeConfig,
FileWriter& writer) const
{
std::vector<Ring>::const_iterator ring=rings.begin();
bool multipleRings=rings.size()>1;
// Outer ring
writer.WriteTypeId(ring->GetType()->GetAreaId(),
typeConfig.GetAreaTypeIdBytes());
if (!ring->featureValueBuffer.Write(writer,
multipleRings)) {
return false;
}
if (multipleRings) {
writer.WriteNumber((uint32_t)(rings.size()-1));
}
if (!writer.Write(ring->nodes)) {
return false;
}
++ring;
// Potential additional rings
while (ring!=rings.end()) {
writer.WriteTypeId(ring->GetType()->GetAreaId(),
typeConfig.GetAreaTypeIdBytes());
if (ring->GetType()->GetAreaId()!=typeIgnore) {
if (!ring->featureValueBuffer.Write(writer)) {
return false;
}
}
writer.Write(ring->ring);
if (!writer.Write(ring->nodes)) {
return false;
}
++ring;
}
return !writer.HasError();
}
示例5: ReadNodes
void PreprocessPBF::ReadNodes(const TypeConfig& typeConfig,
const PBF::PrimitiveBlock& block,
const PBF::PrimitiveGroup& group,
PreprocessorCallback::RawBlockData& data)
{
data.nodeData.reserve(data.nodeData.size()+group.nodes_size());
for (int n=0; n<group.nodes_size(); n++) {
PreprocessorCallback::RawNodeData nodeData;
const PBF::Node &inputNode=group.nodes(n);
nodeData.id=inputNode.id();
nodeData.coord.Set((inputNode.lat()*block.granularity()+block.lat_offset())/NANO,
(inputNode.lon()*block.granularity()+block.lon_offset())/NANO);
tagMap.clear();
for (int t=0; t<inputNode.keys_size(); t++) {
TagId id=typeConfig.GetTagId(block.stringtable().s(inputNode.keys(t)));
if (id!=tagIgnore) {
nodeData.tags[id]=block.stringtable().s(inputNode.vals(t));
}
}
data.nodeData.push_back(std::move(nodeData));
}
}
示例6: Write
bool Way::Write(const TypeConfig& typeConfig,
FileWriter& writer) const
{
assert(!nodes.empty());
writer.WriteTypeId(featureValueBuffer.GetType()->GetWayId(),
typeConfig.GetWayTypeIdBytes());
if (!featureValueBuffer.Write(writer)) {
return false;
}
if (!writer.Write(nodes)) {
return false;
}
if (featureValueBuffer.GetType()->CanRoute() ||
featureValueBuffer.GetType()->GetOptimizeLowZoom()) {
if (!WriteIds(writer)) {
return false;
}
}
return !writer.HasError();
}
示例7: ReadWays
void PreprocessPBF::ReadWays(const TypeConfig& typeConfig,
const PBF::PrimitiveBlock& block,
const PBF::PrimitiveGroup& group,
PreprocessorCallback::RawBlockData& data)
{
data.wayData.reserve(data.wayData.size()+group.ways_size());
for (int w=0; w<group.ways_size(); w++) {
PreprocessorCallback::RawWayData wayData;
const PBF::Way &inputWay=group.ways(w);
wayData.id=inputWay.id();
for (int t=0; t<inputWay.keys_size(); t++) {
TagId id=typeConfig.GetTagId(block.stringtable().s(inputWay.keys(t)));
if (id!=tagIgnore) {
wayData.tags[id]=block.stringtable().s(inputWay.vals(t));
}
}
wayData.nodes.reserve(inputWay.refs_size());
OSMId ref=0;
for (int r=0; r<inputWay.refs_size(); r++) {
ref+=inputWay.refs(r);
wayData.nodes.push_back(ref);
}
data.wayData.push_back(std::move(wayData));
}
}
示例8: ReadRelations
void PreprocessPBF::ReadRelations(const TypeConfig& typeConfig,
const PBF::PrimitiveBlock& block,
const PBF::PrimitiveGroup& group,
PreprocessorCallback::RawBlockData& data)
{
data.relationData.reserve(data.relationData.size()+group.relations_size());
for (int r=0; r<group.relations_size(); r++) {
PreprocessorCallback::RawRelationData relationData;
const PBF::Relation &inputRelation=group.relations(r);
relationData.id=inputRelation.id();
members.clear();
for (int t=0; t<inputRelation.keys_size(); t++) {
TagId id=typeConfig.GetTagId(block.stringtable().s(inputRelation.keys(t)));
if (id!=tagIgnore) {
relationData.tags[id]=block.stringtable().s(inputRelation.vals(t));
}
}
relationData.members.reserve(inputRelation.types_size());
Id ref=0;
for (int m=0; m<inputRelation.types_size(); m++) {
RawRelation::Member member;
switch (inputRelation.types(m)) {
case PBF::Relation::NODE:
member.type=RawRelation::memberNode;
break;
case PBF::Relation::WAY:
member.type=RawRelation::memberWay;
break;
case PBF::Relation::RELATION:
member.type=RawRelation::memberRelation;
break;
}
ref+=inputRelation.memids(m);
member.id=ref;
member.role=block.stringtable().s(inputRelation.roles_sid(m));
relationData.members.push_back(member);
}
data.relationData.push_back(std::move(relationData));
}
}
示例9: GetAreaTypesToOptimize
void OptimizeAreasLowZoomGenerator::GetAreaTypesToOptimize(const TypeConfig& typeConfig,
TypeInfoSet& types)
{
types.Clear();
for (auto &type : typeConfig.GetAreaTypes()) {
if (!type->GetIgnore() &&
type->GetOptimizeLowZoom()) {
types.Set(type);
}
}
}
示例10: ProcessNode
void Preprocess::ProcessNode(const TypeConfig& typeConfig,
const OSMId& id,
const double& lon,
const double& lat,
const std::map<TagId,std::string>& tagMap)
{
RawNode node;
TypeId type=typeIgnore;
FileOffset nodeOffset;
if (id<lastNodeId) {
nodeSortingError=true;
}
typeConfig.GetNodeTypeId(tagMap,type);
if (type!=typeIgnore) {
typeConfig.ResolveTags(tagMap,tags);
nodeWriter.GetPos(nodeOffset);
node.SetId(id);
node.SetType(type);
node.SetCoords(lon,lat);
node.SetTags(tags);
node.Write(nodeWriter);
nodeCount++;
}
else {
nodeOffset=0;
}
StoreCoord(id,
lat,
lon);
lastNodeId=id;
}
示例11: ParametrizeForFoot
void AbstractRoutingProfile::ParametrizeForFoot(const TypeConfig& typeConfig,
double maxSpeed)
{
speeds.clear();
SetVehicle(vehicleFoot);
SetVehicleMaxSpeed(maxSpeed);
for (const auto &type : typeConfig.GetTypes()) {
if (!type->GetIgnore() &&
type->CanRouteFoot()) {
AddType(type,maxSpeed);
}
}
}
示例12: ReadDenseNodes
void PreprocessPBF::ReadDenseNodes(const TypeConfig& typeConfig,
const PBF::PrimitiveBlock& block,
const PBF::PrimitiveGroup& group,
PreprocessorCallback::RawBlockData& data)
{
const PBF::DenseNodes& dense=group.dense();
Id dId=0;
double dLat=0;
double dLon=0;
int t=0;
data.nodeData.reserve(data.nodeData.size()+dense.id_size());
for (int d=0; d<dense.id_size();d++) {
PreprocessorCallback::RawNodeData nodeData;
dId+=dense.id(d);
dLat+=dense.lat(d);
dLon+=dense.lon(d);
nodeData.id=dId;
nodeData.coord.Set((dLat*block.granularity()+block.lat_offset())/NANO,
(dLon*block.granularity()+block.lon_offset())/NANO);
while (true) {
if (t>=dense.keys_vals_size()) {
break;
}
if (dense.keys_vals(t)==0) {
t++;
break;
}
TagId id=typeConfig.GetTagId(block.stringtable().s(dense.keys_vals(t)));
if (id!=tagIgnore) {
nodeData.tags[id]=block.stringtable().s(dense.keys_vals(t+1));
}
t+=2;
}
data.nodeData.push_back(std::move(nodeData));
}
}
示例13: Write
bool RawNode::Write(const TypeConfig& typeConfig,
FileWriter& writer) const
{
writer.WriteNumber(id);
writer.WriteTypeId(featureValueBuffer.GetType()->GetNodeId(),
typeConfig.GetNodeTypeIdBytes());
if (!featureValueBuffer.GetType()->GetIgnore()) {
if (!featureValueBuffer.Write(writer)) {
return false;
}
}
writer.WriteCoord(coords);
return !writer.HasError();
}
示例14: Read
bool Node::Read(const TypeConfig& typeConfig,
FileScanner& scanner)
{
if (!scanner.GetPos(fileOffset)) {
return false;
}
uint32_t tmpType;
scanner.ReadNumber(tmpType);
TypeInfoRef type=typeConfig.GetTypeInfo((TypeId)tmpType);
featureValueBuffer.SetType(type);
if (!featureValueBuffer.Read(scanner)) {
return false;
}
scanner.ReadCoord(coords);
return !scanner.HasError();
}
示例15: HandleAreas
bool OptimizeAreasLowZoomGenerator::HandleAreas(const ImportParameter& parameter,
Progress& progress,
const TypeConfig& typeConfig,
FileWriter& writer,
const TypeInfoSet& types,
std::list<TypeData>& typesData)
{
FileScanner scanner;
// Everything smaller than 2mm should get dropped. Width, height and DPI come from the Nexus 4
double dpi=320.0;
double pixel=2.0/* mm */ * dpi / 25.4 /* inch */;
progress.Info("Minimum visible size in pixel: "+NumberToString((unsigned long)pixel));
try {
scanner.Open(AppendFileToDir(parameter.GetDestinationDirectory(),
AreaDataFile::AREAS_DAT),
FileScanner::Sequential,
parameter.GetWayDataMemoryMaped());
TypeInfoSet typesToProcess(types);
std::vector<std::list<AreaRef> > allAreas(typeConfig.GetTypeCount());
while (true) {
//
// Load type data
//
TypeInfoSet loadedTypes;
if (!GetAreas(typeConfig,
parameter,
progress,
scanner,
typesToProcess,
allAreas,
loadedTypes)) {
return false;
}
typesToProcess.Remove(loadedTypes);
for (const auto& type : loadedTypes) {
progress.SetAction("Optimizing type "+ type->GetName());
for (uint32_t level=parameter.GetOptimizationMinMag();
level<=parameter.GetOptimizationMaxMag();
level++) {
Magnification magnification; // Magnification, we optimize for
std::list<AreaRef> optimizedAreas;
magnification.SetLevel(level);
OptimizeAreas(allAreas[type->GetIndex()],
optimizedAreas,
1280,768,
dpi,
pixel,
magnification,
parameter.GetOptimizationWayMethod());
if (optimizedAreas.empty()) {
progress.Debug("Empty optimization result for level "+NumberToString(level)+", no index generated");
TypeData typeData;
typeData.type=type;
typeData.optLevel=level;
typesData.push_back(typeData);
continue;
}
progress.Info("Optimized from "+NumberToString(allAreas[type->GetIndex()].size())+" to "+NumberToString(optimizedAreas.size())+" areas");
/*
size_t optAreas=optimizedAreas.size();
size_t optRoles=0;
size_t optNodes=0;
for (std::list<AreaRef>::const_iterator a=optimizedAreas.begin();
a!=optimizedAreas.end();
++a) {
AreaRef area=*a;
optRoles+=area->rings.size();
for (size_t r=0; r<area->rings.size(); r++) {
optNodes+=area->rings[r].nodes.size();
}
}*/
/*
std::cout << "Areas: " << origAreas << " => " << optAreas << std::endl;
std::cout << "Roles: " << origRoles << " => " << optRoles << std::endl;
std::cout << "Nodes: " << origNodes << " => " << optNodes << std::endl;*/
TypeData typeData;
//.........这里部分代码省略.........