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; }
bool Import(const ImportParameter& parameter, Progress& progress) { // TODO: verify parameter TypeConfigRef typeConfig(new TypeConfig()); std::list<ImportModule*> modules; if (parameter.GetAreaWayMinMag()<=parameter.GetOptimizationMaxMag()) { progress.Error("Area way index minimum magnification is <= than optimization max magnification"); } progress.SetStep("Loading type config"); if (!typeConfig->LoadFromOSTFile(parameter.GetTypefile())) { progress.Error("Cannot load type configuration!"); return false; } progress.Info("Number of types: "+NumberToString(typeConfig->GetTypes().size())); progress.Info("Number of node types: "+NumberToString(typeConfig->GetNodeTypes().size())+" "+NumberToString(typeConfig->GetNodeTypeIdBytes())+" byte(s)"); progress.Info("Number of way types: "+NumberToString(typeConfig->GetWayTypes().size())+" "+NumberToString(typeConfig->GetWayTypeIdBytes())+" byte(s)"); progress.Info("Number of area types: "+NumberToString(typeConfig->GetAreaTypes().size())+" "+NumberToString(typeConfig->GetAreaTypeIdBytes())+" byte(s)"); typeConfig->RegisterNameTag("name",0); typeConfig->RegisterNameTag("place_name",1); /* typeConfig->RegisterNameAltTag("name:ru",0); typeConfig->RegisterNameAltTag("place_name:ru",1); */ /* 1 */ modules.push_back(new TypeDataGenerator()); /* 2 */ modules.push_back(new Preprocess()); /* 3 */ modules.push_back(new RawNodeIndexGenerator(AppendFileToDir(parameter.GetDestinationDirectory(), "rawnodes.dat"), AppendFileToDir(parameter.GetDestinationDirectory(), "rawnode.idx"))); /* 4 */ modules.push_back(new RawWayIndexGenerator(AppendFileToDir(parameter.GetDestinationDirectory(), "rawways.dat"), AppendFileToDir(parameter.GetDestinationDirectory(), "rawway.idx"))); /* 5 */ modules.push_back(new RawRelationIndexGenerator(AppendFileToDir(parameter.GetDestinationDirectory(), "rawrels.dat"), AppendFileToDir(parameter.GetDestinationDirectory(), "rawrel.idx"))); /* 6 */ modules.push_back(new RelAreaDataGenerator()); /* 7 */ modules.push_back(new WayAreaDataGenerator()); /* 8 */ modules.push_back(new MergeAreaDataGenerator()); /* 9 */ modules.push_back(new MergeAreasGenerator()); /* 10 */ modules.push_back(new WayWayDataGenerator()); /* 11 */ modules.push_back(new OptimizeAreaWayIdsGenerator()); /* 12 */ modules.push_back(new NodeDataGenerator()); /* 13 */ modules.push_back(new SortNodeDataGenerator()); /* 14 */ modules.push_back(new SortWayDataGenerator()); /* 15 */ modules.push_back(new AreaNodeIndexGenerator()); /* 16 */ modules.push_back(new AreaWayIndexGenerator()); /* 17 */ modules.push_back(new AreaAreaIndexGenerator()); /* 18 */ modules.push_back(new WaterIndexGenerator()); /* 19 */ modules.push_back(new OptimizeAreasLowZoomGenerator()); /* 20 */ modules.push_back(new OptimizeWaysLowZoomGenerator()); /* 21 */ modules.push_back(new LocationIndexGenerator()); /* 22 */ modules.push_back(new RouteDataGenerator()); /* 23 */ modules.push_back(new NumericIndexGenerator<Id,Intersection>(std::string("Generating '")+RoutingService::FILENAME_INTERSECTIONS_IDX+"'", AppendFileToDir(parameter.GetDestinationDirectory(), RoutingService::FILENAME_INTERSECTIONS_DAT), AppendFileToDir(parameter.GetDestinationDirectory(), RoutingService::FILENAME_INTERSECTIONS_IDX))); #if defined(OSMSCOUT_IMPORT_HAVE_LIB_MARISA) /* 24 */ modules.push_back(new TextIndexGenerator()); #endif bool result=ExecuteModules(modules, parameter, progress, typeConfig); for (const auto& module : modules) { delete module; } return result; }