• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TypeConfig类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中TypeConfig的典型用法代码示例。如果您正苦于以下问题:C++ TypeConfig类的具体用法?C++ TypeConfig怎么用?C++ TypeConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TypeConfig类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
  }
开发者ID:bolidehi,项目名称:libosmscout,代码行数:25,代码来源:Preprocess.cpp


示例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();
  }
开发者ID:LamaUrbain,项目名称:libosmscout,代码行数:30,代码来源:RawNode.cpp


示例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();
  }
开发者ID:jojva,项目名称:libosmscout,代码行数:26,代码来源:Way.cpp


示例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();
  }
开发者ID:jojva,项目名称:libosmscout,代码行数:49,代码来源:Area.cpp


示例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));
    }
  }
开发者ID:Framstag,项目名称:libosmscout,代码行数:29,代码来源:PreprocessPBF.cpp


示例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();
  }
开发者ID:jojva,项目名称:libosmscout,代码行数:25,代码来源:Way.cpp


示例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));
    }
  }
开发者ID:Framstag,项目名称:libosmscout,代码行数:34,代码来源:PreprocessPBF.cpp


示例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));
    }
  }
开发者ID:Framstag,项目名称:libosmscout,代码行数:53,代码来源:PreprocessPBF.cpp


示例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);
      }
    }
  }
开发者ID:mstar0125,项目名称:libosmscout,代码行数:12,代码来源:GenOptimizeAreasLowZoom.cpp


示例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;
  }
开发者ID:bolidehi,项目名称:libosmscout,代码行数:40,代码来源:Preprocess.cpp


示例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);
      }
    }
  }
开发者ID:Framstag,项目名称:libosmscout,代码行数:15,代码来源:RoutingProfile.cpp


示例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));
    }
  }
开发者ID:Framstag,项目名称:libosmscout,代码行数:46,代码来源:PreprocessPBF.cpp


示例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();
  }
开发者ID:LamaUrbain,项目名称:libosmscout,代码行数:19,代码来源:RawNode.cpp


示例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();
  }
开发者ID:hjanetzek,项目名称:libosmscout-exp,代码行数:24,代码来源:Node.cpp


示例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;

//.........这里部分代码省略.........
开发者ID:mstar0125,项目名称:libosmscout,代码行数:101,代码来源:GenOptimizeAreasLowZoom.cpp


示例16: ProcessWay

  void Preprocess::ProcessWay(const TypeConfig& typeConfig,
                              const OSMId& id,
                              std::vector<OSMId>& nodes,
                              const std::map<TagId,std::string>& tagMap)
  {
    TypeId                                      areaType=typeIgnore;
    TypeId                                      wayType=typeIgnore;
    int                                         isArea=0; // 0==unknown, 1==true, -1==false
    std::map<TagId,std::string>::const_iterator areaTag;
    std::map<TagId,std::string>::const_iterator naturalTag;
    RawWay                                      way;
    bool                                        isCoastline=false;

    if (id<lastWayId) {
      waySortingError=true;
    }

    way.SetId(id);

    areaTag=tagMap.find(typeConfig.tagArea);

    if (areaTag==tagMap.end()) {
      isArea=0;
    }
    else if (areaTag->second=="no" ||
             areaTag->second=="false" ||
             areaTag->second=="0") {
      isArea=-1;
    }
    else {
      isArea=1;
    }

    naturalTag=tagMap.find(typeConfig.tagNatural);

    if (naturalTag!=tagMap.end() &&
        naturalTag->second=="coastline") {
      isCoastline=true;
    }

    typeConfig.GetWayAreaTypeId(tagMap,wayType,areaType);
    typeConfig.ResolveTags(tagMap,tags);

    if (isArea==1 &&
        areaType==typeIgnore) {
      isArea=0;
    }
    else if (isArea==-1 &&
             wayType==typeIgnore) {
      isArea=0;
    }

    if (isArea==0) {
      if (wayType!=typeIgnore &&
          areaType==typeIgnore) {
        isArea=-1;
      }
      else if (wayType==typeIgnore &&
               areaType!=typeIgnore) {
        isArea=1;
      }
      else if (wayType!=typeIgnore &&
               areaType!=typeIgnore) {
        if (nodes.size()>3 &&
            nodes.front()==nodes.back()) {
          if (typeConfig.GetTypeInfo(wayType).GetPinWay()) {
            isArea=-1;
          }
          else {
            isArea=1;
          }
        }
        else {
          isArea=-1;
        }
      }
    }

    switch (isArea) {
    case 1:
      way.SetType(areaType,true);

      if (nodes.size()>3 &&
          nodes.front()==nodes.back()) {
        nodes.pop_back();
      }

      areaCount++;
      break;
    case -1:
      way.SetType(wayType,false);
      wayCount++;
      break;
    default:
      if (nodes.size()>3 &&
          nodes.front()==nodes.back()) {
        way.SetType(typeIgnore,
                    true);

        nodes.pop_back();
//.........这里部分代码省略.........
开发者ID:bolidehi,项目名称:libosmscout,代码行数:101,代码来源:Preprocess.cpp


示例17: Import

  bool AreaWayIndexGenerator::Import(const ImportParameter& parameter,
                                     Progress& progress,
                                     const TypeConfig& typeConfig)
  {
    FileScanner           wayScanner;
    FileWriter            writer;
    std::set<TypeId>      remainingWayTypes;
    std::vector<TypeData> wayTypeData;
    size_t                level;
    size_t                maxLevel=0;

    wayTypeData.resize(typeConfig.GetTypes().size());

    if (!wayScanner.Open(AppendFileToDir(parameter.GetDestinationDirectory(),
                                         "ways.dat"),
                         FileScanner::Sequential,
                         parameter.GetWayDataMemoryMaped())) {
      progress.Error("Cannot open 'ways.dat'");
      return false;
    }

    //
    // Scanning distribution
    //

    progress.SetAction("Scanning level distribution of way types");

    for (size_t i=0; i<typeConfig.GetTypes().size(); i++) {
      if (typeConfig.GetTypeInfo(i).CanBeWay() &&
          !typeConfig.GetTypeInfo(i).GetIgnore()) {
        remainingWayTypes.insert(i);
      }
    }

    level=parameter.GetAreaWayMinMag();
    while (!remainingWayTypes.empty()) {
      uint32_t                   wayCount=0;
      std::set<TypeId>           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.GetTypes().size());

      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(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.find(way.GetType())==currentWayTypes.end()) {
          continue;
        }

        double minLon;
        double maxLon;
        double minLat;
        double maxLat;

        way.GetBoundingBox(minLon,maxLon,minLat,maxLat);

        //
        // Calculate minimum and maximum tile ids that are covered
        // by the way
        // Renormated coordinate space (everything is >=0)
        //
        uint32_t minxc=(uint32_t)floor((minLon+180.0)/cellWidth);
        uint32_t maxxc=(uint32_t)floor((maxLon+180.0)/cellWidth);
        uint32_t minyc=(uint32_t)floor((minLat+90.0)/cellHeight);
        uint32_t maxyc=(uint32_t)floor((maxLat+90.0)/cellHeight);

        for (uint32_t y=minyc; y<=maxyc; y++) {
          for (uint32_t x=minxc; x<=maxxc; x++) {
            cellFillCount[way.GetType()][Pixel(x,y)]++;
          }
        }
      }

      // Check if cell fill for current type is in defined limits
      for (size_t i=0; i<typeConfig.GetTypes().size(); i++) {
        if (currentWayTypes.find(i)!=currentWayTypes.end()) {
          CalculateStatistics(level,wayTypeData[i],cellFillCount[i]);

          if (!FitsIndexCriteria(parameter,
//.........这里部分代码省略.........
开发者ID:fingon,项目名称:osmscout,代码行数:101,代码来源:GenAreaWayIndex.cpp


示例18: GetIndexCell

  bool AreaAreaIndex::GetIndexCell(const TypeConfig& typeConfig,
                                   uint32_t level,
                                   FileOffset offset,
                                   IndexCache::CacheRef& cacheRef) const
  {
    if (!indexCache.GetEntry(offset,cacheRef)) {
      IndexCache::CacheEntry cacheEntry(offset);

      cacheRef=indexCache.SetEntry(cacheEntry);

      if (!scanner.IsOpen()) {
        if (!scanner.Open(datafilename,FileScanner::LowMemRandom,true)) {
          log.Error() << "Error while opening '" << scanner.GetFilename() << "' for reading!";
          return false;
        }
      }

      scanner.SetPos(offset);

      // Read offsets of children if not in the bottom level

      if (level<maxLevel) {
        for (size_t c=0; c<4; c++) {
          if (!scanner.ReadNumber(cacheRef->value.children[c])) {
            log.Error() << "Cannot read index data at offset " << offset << " in file '" << scanner.GetFilename() << "'";
            return false;
          }
        }
      }
      else {
        for (size_t c=0; c<4; c++) {
          cacheRef->value.children[c]=0;
        }
      }

      // Now read the way offsets by type in this index entry

      uint32_t offsetCount;

      // Areas

      if (!scanner.ReadNumber(offsetCount)) {
        log.Error() << "Cannot read index data for level " << level << " at offset " << offset << " in file '" << scanner.GetFilename() << "'";
        return false;
      }

      cacheRef->value.areas.resize(offsetCount);

      FileOffset prevOffset=0;

      for (size_t c=0; c<offsetCount; c++) {
        if (!scanner.ReadTypeId(cacheRef->value.areas[c].type,
                                typeConfig.GetAreaTypeIdBytes())) {
          log.Error() << "Cannot read index data for level " << level << " at offset " << offset << " in file '" << scanner.GetFilename() << "'";
          return false;
        }

        if (!scanner.ReadNumber(cacheRef->value.areas[c].offset)) {
          log.Error() << "Cannot read index data for level " << level << " at offset " << offset << " in file '" << scanner.GetFilename() << "'";
          return false;
        }

        cacheRef->value.areas[c].offset+=prevOffset;

        prevOffset=cacheRef->value.areas[c].offset;
      }
    }

    return true;
  }
开发者ID:AQbernhard,项目名称:OSMScout-ubuntu,代码行数:70,代码来源:AreaAreaIndex.cpp


示例19: 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;
//.........这里部分代码省略.........
开发者ID:fingon,项目名称:osmscout,代码行数:101,代码来源:GenAreaNodeIndex.cpp


示例20: ReadOptimized

  bool Area::ReadOptimized(const TypeConfig& typeConfig,
                           FileScanner& scanner)
  {
    if (!scanner.GetPos(fileOffset)) {
      return false;
    }

    TypeId             ringType;
    bool               multipleRings;
    uint32_t           ringCount=1;
    FeatureValueBuffer featureValueBuffer;

    scanner.ReadTypeId(ringType,
                       typeConfig.GetAreaTypeIdBytes());

    TypeInfoRef type=typeConfig.GetAreaTypeInfo(ringType);

    featureValueBuffer.SetType(type);

    if (!featureValueBuffer.Read(scanner,
                                 multipleRings)) {
      return false;
    }

    if (multipleRings) {
      if (!scanner.ReadNumber(ringCount)) {
        return false;
      }

      ringCount++;
    }

    rings.resize(ringCount);

    rings[0].featureValueBuffer=featureValueBuffer;

    if (ringCount>1) {
      rings[0].ring=masterRingId;
    }
    else {
      rings[0].ring=outerRingId;
    }

    if (!scanner.Read(rings[0].nodes)) {
      return false;
    }

    for (size_t i=1; i<ringCount; i++) {
      scanner.ReadTypeId(ringType,
                         typeConfig.GetAreaTypeIdBytes());

      type=typeConfig.GetAreaTypeInfo(ringType);

      rings[i].SetType(type);

      if (rings[i].featureValueBuffer.GetType()->GetAreaId()!=typeIgnore) {
        if (!rings[i].featureValueBuffer.Read(scanner)) {
          return false;
        }
      }

      scanner.Read(rings[i].ring);

      if (!scanner.Read(rings[i].nodes)) {
        return false;
      }
    }

    return !scanner.HasError();
  }
开发者ID:jojva,项目名称:libosmscout,代码行数:70,代码来源:Area.cpp



注:本文中的TypeConfig类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TypeConstraint类代码示例发布时间:2022-05-31
下一篇:
C++ TypeClass类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap