Fix possible error when .notsorted file already exists during generation.

Update epsilon for lines-simplification: using Epsilon(level+1).
This commit is contained in:
vng 2011-01-04 21:19:58 +02:00 committed by Alex Zolotarev
parent 2673acf54a
commit 7ae8e4c5e2
4 changed files with 15 additions and 8 deletions

View file

@ -259,7 +259,7 @@ void FeatureBuilderGeomRef::SimplifyPoints(points_t const & in, points_t & out,
if (in.size() >= 2)
{
SimplifyNearOptimal<mn::DistanceToLineSquare<m2::PointD> >(50, in.begin(), in.end()-1,
my::sq(scales::GetEpsilonForLevel(level)), MakeBackInsertFunctor(out));
my::sq(scales::GetEpsilonForLevel(level + 1)), MakeBackInsertFunctor(out));
switch (out.size())
{

View file

@ -62,18 +62,18 @@ namespace
namespace feature
{
void SortDatFile(string const & datFilePath, bool removeOriginalFile)
bool SortDatFile(string const & datFilePath, bool removeOriginalFile)
{
// rename input file
Platform & platform = GetPlatform();
string tempDatFilePath(datFilePath);
tempDatFilePath += ".notsorted";
// file doesn't exist
FileWriter::DeleteFile(tempDatFilePath);
if (!platform.RenameFileX(datFilePath, tempDatFilePath))
{
LOG(LINFO, ("File ", datFilePath, " doesn't exist or sharing violation!"));
return;
LOG(LWARNING, ("File ", datFilePath, " doesn't exist or sharing violation!"));
return false;
}
// stores cellIds for middle points
@ -117,5 +117,7 @@ namespace feature
FileWriter::DeleteFile(datFilePath + GEOMETRY_FILE_TAG);
FileWriter::DeleteFile(datFilePath + TRIANGLE_FILE_TAG);
}
return true;
}
} // namespace feature

View file

@ -5,5 +5,5 @@
namespace feature
{
// sorts features in the given file by their mid points
void SortDatFile(string const & datFile, bool removeOriginalFile = true);
bool SortDatFile(string const & datFile, bool removeOriginalFile = true);
}

View file

@ -134,11 +134,16 @@ int main(int argc, char ** argv)
// Enumerate over all dat files that were created.
for (size_t i = 0; i < genInfo.bucketNames.size(); ++i)
{
string const datFile = genInfo.bucketNames[i];
string const & datFile = genInfo.bucketNames[i];
if (FLAGS_sort_features)
{
LOG(LINFO, ("Sorting features inside", datFile));
feature::SortDatFile(datFile);
if (!feature::SortDatFile(datFile))
{
// If error - move to next bucket without index generation
continue;
}
}
if (FLAGS_generate_index)