[generator] Fixed pathes.

This commit is contained in:
vng 2015-07-15 13:43:48 +03:00 committed by Alex Zolotarev
parent 792311a255
commit be4452d03a
6 changed files with 42 additions and 34 deletions

View file

@ -539,8 +539,8 @@ namespace feature
bool GenerateFinalFeatures(feature::GenerateInfo const & info, string const & name, int mapType)
{
string const srcFilePath = my::JoinFoldersToPath(info.m_tmpDir, name + DATA_FILE_EXTENSION_TMP);
string const datFilePath = my::JoinFoldersToPath(info.m_targetDir, name + DATA_FILE_EXTENSION);
string const srcFilePath = info.GetTmpFile(name);
string const datFilePath = info.GetTargetFile(name);
// stores cellIds for middle points
CalculateMidPoints midPoints;

View file

@ -1,5 +1,7 @@
#pragma once
#include "defines.hpp"
#include "std/string.hpp"
#include "std/vector.hpp"
@ -10,25 +12,39 @@ struct GenerateInfo
{
GenerateInfo()
: m_createWorld(false), m_splitByPolygons(false),
m_makeCoasts(false), m_emitCoasts(false)
m_makeCoasts(false), m_emitCoasts(false), m_genAddresses(false)
{
}
// directory for .mwm.tmp files
string GetTmpFile(string const & fileName, char const * ext = DATA_FILE_EXTENSION_TMP) const
{
return (m_tmpDir + fileName + ext);
}
string GetTargetFile(string const & fileName, char const * ext = DATA_FILE_EXTENSION) const
{
return (m_targetDir + fileName + ext);
}
string GetAddressesFile() const
{
return ((m_genAddresses && !m_fileName.empty()) ? GetTargetFile(m_fileName, ".addr") : string());
}
// Directory for .mwm.tmp files.
string m_tmpDir;
// directory for result .mwm files
// Directory for result .mwm files.
string m_targetDir;
// directory for all intermediate files
// Directory for all intermediate files.
string m_intermediateDir;
string m_datFileSuffix;
string m_addressFile;
// Current generated file name if --output option is defined.
string m_fileName;
vector<string> m_bucketNames;
bool m_createWorld;
bool m_splitByPolygons;
bool m_makeCoasts, m_emitCoasts;
bool m_genAddresses;
};
} // namespace feature

View file

@ -61,7 +61,7 @@ DEFINE_bool(generate_packed_borders, false, "Generate packed file with country p
DEFINE_bool(check_mwm, false, "Check map file to be correct.");
DEFINE_string(delete_section, "", "Delete specified section (defines.hpp) from container.");
DEFINE_bool(fail_on_coasts, false, "Stop and exit with '255' code if some coastlines are not merged.");
DEFINE_string(address_file_name, "", "Output file name for storing full addresses.");
DEFINE_bool(generate_addresses_file, false, "Generate .addr file (for '--output' option) with full addresses list.");
DEFINE_string(osrm_file_name, "", "Input osrm file to generate routing info");
DEFINE_bool(make_routing, false, "Make routing info based on osrm file");
DEFINE_bool(make_cross_section, false, "Make corss section in routing file for cross mwm routing");
@ -102,9 +102,10 @@ int main(int argc, char ** argv)
: my::AddSlashIfNeeded(FLAGS_intermediate_data_path);
genInfo.m_targetDir = genInfo.m_tmpDir = path;
/// @todo Probably, it's better to add separate option for .mwm.tmp files.
if (!FLAGS_intermediate_data_path.empty())
{
string tmpPath = my::JoinFoldersToPath({genInfo.m_intermediateDir, "tmp"}, string());
string const tmpPath = genInfo.m_intermediateDir + "tmp" + my::GetNativeSeparator();
if (pl.MkDir(tmpPath) != Platform::ERR_UNKNOWN)
genInfo.m_tmpDir = tmpPath;
}
@ -124,22 +125,16 @@ int main(int argc, char ** argv)
{
LOG(LINFO, ("Generating final data ..."));
genInfo.m_datFileSuffix = DATA_FILE_EXTENSION_TMP;
genInfo.m_splitByPolygons = FLAGS_split_by_polygons;
genInfo.m_createWorld = FLAGS_generate_world;
genInfo.m_makeCoasts = FLAGS_make_coasts;
genInfo.m_emitCoasts = FLAGS_emit_coasts;
if (!FLAGS_address_file_name.empty())
genInfo.m_addressFile = path + FLAGS_address_file_name;
genInfo.m_fileName = FLAGS_output;
genInfo.m_genAddresses = FLAGS_generate_addresses_file;
if (!GenerateFeatures(genInfo, FLAGS_node_storage, FLAGS_osm_file_type, FLAGS_osm_file_name))
return -1;
// without --spit_by_polygons, we have empty name country as result - assign it
if (genInfo.m_bucketNames.size() == 1 && genInfo.m_bucketNames[0].empty())
genInfo.m_bucketNames[0] = FLAGS_output;
if (FLAGS_generate_world)
{
genInfo.m_bucketNames.push_back(WORLD_FILE_NAME);

View file

@ -170,7 +170,6 @@ namespace data
namespace
{
class MainFeaturesEmitter
{
typedef WorldMapGenerator<feature::FeaturesCollector> WorldGenerator;
@ -226,8 +225,7 @@ namespace
m_types[i] = c.GetTypeByPath(vector<string>(arr[i], arr[i] + 2));
m_srcCoastsFile = info.m_intermediateDir + WORLD_COASTS_FILE_NAME + ".geom";
string srcCoastsFileDump = info.m_intermediateDir + WORLD_COASTS_FILE_NAME + ".rawdump";
string dstCoastsFile = info.m_tmpDir + WORLD_COASTS_FILE_NAME + info.m_datFileSuffix;
string const srcCoastsFileDump = info.m_intermediateDir + WORLD_COASTS_FILE_NAME + ".rawdump";
CHECK(!info.m_makeCoasts || !info.m_createWorld,
("We can't do make_coasts and generate_world at the same time"));
@ -238,7 +236,7 @@ namespace
if (info.m_emitCoasts)
{
m_coastsHolder.reset(new feature::FeaturesCollector(dstCoastsFile));
m_coastsHolder.reset(new feature::FeaturesCollector(info.GetTmpFile(WORLD_COASTS_FILE_NAME)));
}
}
else
@ -496,7 +494,7 @@ bool GenerateFeaturesImpl(feature::GenerateInfo & info, string const &osmFileTyp
SecondPassParser<MainFeaturesEmitter, HolderT> parser(
bucketer, holder,
info.m_makeCoasts ? classif().GetCoastType() : 0,
info.m_addressFile);
info.GetAddressesFile());
SourceReader reader(osmFileName);

View file

@ -2,6 +2,7 @@
#include "generator/borders_loader.hpp"
#include "generator/feature_builder.hpp"
#include "generator/generate_info.hpp"
#include "indexer/feature_visibility.hpp"
#include "indexer/cell_id.hpp"
@ -35,8 +36,7 @@ namespace feature
template <class FeatureOutT>
class Polygonizer
{
string m_prefix;
string m_suffix;
feature::GenerateInfo const & m_info;
vector<FeatureOutT*> m_Buckets;
vector<string> m_Names;
@ -49,9 +49,7 @@ namespace feature
#endif
public:
template <class TInfo>
explicit Polygonizer(TInfo const & info)
: m_prefix(info.m_tmpDir), m_suffix(info.m_datFileSuffix)
explicit Polygonizer(feature::GenerateInfo const & info) : m_info(info)
#if PARALLEL_POLYGONIZER
, m_ThreadPoolSemaphore(m_ThreadPool.maxThreadCount() * 8)
#endif
@ -69,7 +67,7 @@ namespace feature
{
// Insert fake country polygon equal to whole world to
// create only one output file which contains all features
m_countries.Add(borders::CountryPolygons(), MercatorBounds::FullRect());
m_countries.Add(borders::CountryPolygons(info.m_fileName), MercatorBounds::FullRect());
}
}
~Polygonizer()
@ -153,7 +151,7 @@ namespace feature
if (country->m_index == -1)
{
m_Names.push_back(country->m_name);
m_Buckets.push_back(new FeatureOutT(m_prefix + country->m_name + m_suffix));
m_Buckets.push_back(new FeatureOutT(m_info.GetTmpFile(country->m_name)));
country->m_index = m_Buckets.size()-1;
}

View file

@ -1,8 +1,10 @@
#pragma once
#include "generator/feature_merger.hpp"
#include "generator/generate_info.hpp"
#include "indexer/scales.hpp"
#include "base/logging.hpp"
#include "defines.hpp"
@ -19,11 +21,10 @@ class WorldMapGenerator
FeatureOutT m_output;
public:
template <class TInfo>
explicit EmitterImpl(TInfo const & info)
: m_output(info.m_tmpDir + WORLD_FILE_NAME + info.m_datFileSuffix)
explicit EmitterImpl(feature::GenerateInfo const & info)
: m_output(info.GetTmpFile(WORLD_FILE_NAME))
{
LOG(LINFO, ("Output World file:", info.m_tmpDir + WORLD_FILE_NAME + info.m_datFileSuffix));
LOG(LINFO, ("Output World file:", info.GetTmpFile(WORLD_FILE_NAME)));
}
/// This function is called after merging linear features.