Beispiel #1
0
  OptimizeAreasLowZoomRef Database::GetOptimizeAreasLowZoom() const
  {
    std::lock_guard<std::mutex> guard(optimizeAreasMutex);

    if (!IsOpen()) {
      return NULL;
    }

    if (!optimizeAreasLowZoom) {
      optimizeAreasLowZoom=std::make_shared<OptimizeAreasLowZoom>();

      StopClock timer;

      if (!optimizeAreasLowZoom->Open(typeConfig,
                                      path)) {
        log.Error() << "Cannot load optimize areas low zoom index!";
        optimizeAreasLowZoom=NULL;

        return NULL;
      }


      timer.Stop();

      log.Debug() << "Opening OptimizeAreasLowZoom: " << timer.ResultString();
    }

    return optimizeAreasLowZoom;
  }
Beispiel #2
0
  WaterIndexRef Database::GetWaterIndex() const
  {
    std::lock_guard<std::mutex> guard(waterIndexMutex);

    if (!IsOpen()) {
      return NULL;
    }

    if (!waterIndex) {
      waterIndex=std::make_shared<WaterIndex>();

      StopClock timer;

      if (!waterIndex->Open(path)) {
        log.Error() << "Cannot load water index!";
        waterIndex=NULL;

        return NULL;
      }

      timer.Stop();

      log.Debug() << "Opening WaterIndex: " << timer.ResultString();
    }

    return waterIndex;
  }
Beispiel #3
0
  LocationIndexRef Database::GetLocationIndex() const
  {
    std::lock_guard<std::mutex> guard(locationIndexMutex);

    if (!IsOpen()) {
      return NULL;
    }

    if (!locationIndex) {
      locationIndex=std::make_shared<LocationIndex>();

      StopClock timer;

      if (!locationIndex->Load(path)) {
        log.Error() << "Cannot load location index!";
        locationIndex=NULL;

        return NULL;
      }

      timer.Stop();

      log.Debug() << "Opening LocationIndex: " << timer.ResultString();
    }

    return locationIndex;
  }
Beispiel #4
0
  AreaWayIndexRef Database::GetAreaWayIndex() const
  {
    std::lock_guard<std::mutex> guard(areaWayIndexMutex);

    if (!IsOpen()) {
      return NULL;
    }

    if (!areaWayIndex) {
      areaWayIndex=std::make_shared<AreaWayIndex>();

      StopClock timer;

      if (!areaWayIndex->Open(typeConfig,
                              path)) {
        log.Error() << "Cannot load area way index!";
        areaWayIndex=NULL;

        return NULL;
      }

      timer.Stop();

      log.Debug() << "Opening AreaWayIndex: " << timer.ResultString();
    }

    return areaWayIndex;
  }
Beispiel #5
0
  AreaAreaIndexRef Database::GetAreaAreaIndex() const
  {
    std::lock_guard<std::mutex> guard(areaAreaIndexMutex);

    if (!IsOpen()) {
      return NULL;
    }

    if (!areaAreaIndex) {
      areaAreaIndex=std::make_shared<AreaAreaIndex>(parameter.GetAreaAreaIndexCacheSize());

      StopClock timer;

      if (!areaAreaIndex->Open(path)) {
        log.Error() << "Cannot load area area index!";
        areaAreaIndex=NULL;

        return NULL;
      }

      timer.Stop();

      log.Debug() << "Opening AreaAreaIndex: " << timer.ResultString();
    }

    return areaAreaIndex;
  }
Beispiel #6
0
  WayDataFileRef Database::GetWayDataFile() const
  {
    std::lock_guard<std::mutex> guard(wayDataFileMutex);

    if (!IsOpen()) {
      return NULL;
    }

    if (!wayDataFile) {
      wayDataFile=std::make_shared<WayDataFile>();
    }

    if (!wayDataFile->IsOpen()) {
      StopClock timer;

      if (!wayDataFile->Open(typeConfig,
                             path,
                             FileScanner::LowMemRandom,
                             true)) {
        log.Error() << "Cannot open 'ways.dat'!";
        return NULL;
      }

      timer.Stop();

      log.Debug() << "Opening WayDataFile: " << timer.ResultString();
    }

    return wayDataFile;
  }
Beispiel #7
0
  static bool ExecuteModules(std::list<ImportModule*>& modules,
                            const ImportParameter& parameter,
                            Progress& progress,
                            const TypeConfigRef& typeConfig)
  {
    StopClock overAllTimer;
    size_t    currentStep=1;

    for (const auto& module : modules) {
      if (currentStep>=parameter.GetStartStep() &&
          currentStep<=parameter.GetEndStep()) {
        StopClock timer;
        bool      success;

        progress.SetStep(std::string("Step #")+
                         NumberToString(currentStep)+
                         " - "+
                         module->GetDescription());

        success=module->Import(typeConfig,
                               parameter,
                               progress);

        timer.Stop();

        progress.Info(std::string("=> ")+timer.ResultString()+" second(s)");

        if (!success) {
          progress.Error(std::string("Error while executing step '")+module->GetDescription()+"'!");
          return false;
        }
      }

      currentStep++;
    }

    overAllTimer.Stop();
    progress.Info(std::string("=> ")+overAllTimer.ResultString()+" second(s)");

    return true;
  }
Beispiel #8
0
  bool Database::GetWaysByOffset(const std::set<FileOffset>& offsets,
                                 std::unordered_map<FileOffset,WayRef>& dataMap) const
  {
    WayDataFileRef wayDataFile=GetWayDataFile();

    if (!wayDataFile) {
      return false;
    }

    StopClock time;

    bool result=wayDataFile->GetByOffset(offsets,dataMap);

    if (time.GetMilliseconds()>100) {
      log.Warn() << "Retrieving ways by offset took " << time.ResultString();
    }

    return result;
  }
Beispiel #9
0
  bool Database::GetWayByOffset(const FileOffset& offset,
                                WayRef& way) const
  {
    WayDataFileRef wayDataFile=GetWayDataFile();

    if (!wayDataFile) {
      return false;
    }

    StopClock time;

    bool result=wayDataFile->GetByOffset(offset,way);

    if (time.GetMilliseconds()>100) {
      log.Warn() << "Retrieving ways by offset took " << time.ResultString();
    }

    return result;
  }
Beispiel #10
0
  bool Database::GetAreasByOffset(const std::list<FileOffset>& offsets,
                                  std::vector<AreaRef>& areas) const
  {
    AreaDataFileRef areaDataFile=GetAreaDataFile();

    if (!areaDataFile) {
      return false;
    }

    StopClock time;

    bool result=areaDataFile->GetByOffset(offsets,areas);

    if (time.GetMilliseconds()>100) {
      log.Warn() << "Retrieving areas by offset took " << time.ResultString();
    }

    return result;
  }
Beispiel #11
0
  bool Database::GetAreaByOffset(const FileOffset& offset,
                                 AreaRef& area) const
  {
    AreaDataFileRef areaDataFile=GetAreaDataFile();

    if (!areaDataFile) {
      return false;
    }

    StopClock time;

    bool result=areaDataFile->GetByOffset(offset,area);

    time.Stop();

    if (time.GetMilliseconds()>100) {
      log.Warn() << "Retrieving areas by offset took " << time.ResultString();
    }

    return result;
  }
Beispiel #12
0
  bool Database::GetNodesByOffset(const std::list<FileOffset>& offsets,
                                  std::vector<NodeRef>& nodes) const
  {
    NodeDataFileRef nodeDataFile=GetNodeDataFile();

    if (!nodeDataFile) {
      return false;
    }

    StopClock time;

    bool result=nodeDataFile->GetByOffset(offsets,nodes);

    time.Stop();

    if (time.GetMilliseconds()>100) {
      log.Warn() << "Retrieving nodes by offset took " << time.ResultString();
    }

    return result;
  }
Beispiel #13
0
  bool Database::GetNodeByOffset(const FileOffset& offset,
                                 NodeRef& node) const
  {
    NodeDataFileRef nodeDataFile=GetNodeDataFile();

    if (!nodeDataFile) {
      return false;
    }

    StopClock time;

    bool result=nodeDataFile->GetByOffset(offset,node);

    time.Stop();

    if (time.GetMilliseconds()>100) {
      log.Warn() << "Retrieving nodes by offset took " << time.ResultString();
    }

    return result;
  }