Exclude separate warnings file.

This commit is contained in:
Lev Dragunov 2015-11-05 16:18:09 +03:00
parent df08217cf5
commit f437d6cacf
6 changed files with 9 additions and 79 deletions

View file

@ -32,7 +32,6 @@ SOURCES += \
tesselator.cpp \
unpack_mwm.cpp \
update_generator.cpp \
warnings_writer.cpp \
HEADERS += \
borders_generator.hpp \
@ -62,7 +61,6 @@ HEADERS += \
tesselator.hpp \
unpack_mwm.hpp \
update_generator.hpp \
warnings_writer.hpp \
ways_merger.hpp \
world_map_generator.hpp \

View file

@ -70,7 +70,6 @@ DEFINE_bool(generate_addresses_file, false, "Generate .addr file (for '--output'
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");
DEFINE_string(cross_warnings, "", "File path to store border intersection warnings");
DEFINE_string(osm_file_name, "", "Input osm area file");
DEFINE_string(osm_file_type, "xml", "Input osm area file type [xml, o5m]");
DEFINE_string(user_resource_path, "", "User defined resource path for classificator.txt and etc.");
@ -260,7 +259,7 @@ int main(int argc, char ** argv)
routing::BuildRoutingIndex(path, FLAGS_output, FLAGS_osrm_file_name);
if (!FLAGS_osrm_file_name.empty() && FLAGS_make_cross_section)
routing::BuildCrossRoutingIndex(path, FLAGS_output, FLAGS_osrm_file_name, FLAGS_cross_warnings);
routing::BuildCrossRoutingIndex(path, FLAGS_output, FLAGS_osrm_file_name);
return 0;
}

View file

@ -1,9 +1,8 @@
#include "generator/routing_generator.hpp"
#include "borders_generator.hpp"
#include "borders_loader.hpp"
#include "gen_mwm_info.hpp"
#include "warnings_writer.hpp"
#include "generator/borders_generator.hpp"
#include "generator/borders_loader.hpp"
#include "generator/gen_mwm_info.hpp"
#include "routing/osrm2feature_map.hpp"
#include "routing/osrm_data_facade.hpp"
@ -82,7 +81,7 @@ bool CheckBBoxCrossingBorder(m2::RegionD const & border, osrm::NodeData const &
void FindCrossNodes(osrm::NodeDataVectorT const & nodeData, gen::OsmID2FeatureID const & osm2ft,
borders::CountriesContainerT const & m_countries, string const & countryName,
string const & warningsFile, routing::CrossRoutingContextWriter & crossContext)
routing::CrossRoutingContextWriter & crossContext)
{
vector<m2::RegionD> regionBorders;
m_countries.ForEach([&](borders::CountryPolygons const & c)
@ -94,7 +93,6 @@ void FindCrossNodes(osrm::NodeDataVectorT const & nodeData, gen::OsmID2FeatureID
});
});
WarningsWriter warnings(warningsFile);
for (TWrittenNodeId nodeId = 0; nodeId < nodeData.size(); ++nodeId)
{
auto const & data = nodeData[nodeId];
@ -155,19 +153,15 @@ void FindCrossNodes(osrm::NodeDataVectorT const & nodeData, gen::OsmID2FeatureID
if (!mwmName.empty())
crossContext.AddOutgoingNode(nodeId, mwmName, wgsIntersection);
else
{
LOG(LINFO, ("Unknowing outgoing edge", endSeg.lat2, endSeg.lon2, startSeg.lat1, startSeg.lon1));
warnings.AddPoint({endSeg.lat2, endSeg.lon2}, PointType::EUnconnectedExit);
}
}
}
if (intersectionCount > 1)
warnings.AddPoint(wgsIntersection, PointType::EDoubleCross);
LOG(LINFO, ("Double border intersection", wgsIntersection));
}
}
}
}
warnings.Write();
}
void CalculateCrossAdjacency(string const & mwmRoutingPath, routing::CrossRoutingContextWriter & crossContext)
@ -217,7 +211,7 @@ void WriteCrossSection(routing::CrossRoutingContextWriter const & crossContext,
}
void BuildCrossRoutingIndex(string const & baseDir, string const & countryName,
string const & osrmFile, string const & warningsFile)
string const & osrmFile)
{
LOG(LINFO, ("Cross mwm routing section builder"));
@ -238,7 +232,7 @@ void BuildCrossRoutingIndex(string const & baseDir, string const & countryName,
LOG(LINFO, ("Finding cross nodes..."));
routing::CrossRoutingContextWriter crossContext;
FindCrossNodes(nodeData, osm2ft, m_countries, countryName, warningsFile, crossContext);
FindCrossNodes(nodeData, osm2ft, m_countries, countryName, crossContext);
string const mwmRoutingPath = localFile.GetPath(MapOptions::CarRouting);
CalculateCrossAdjacency(mwmRoutingPath, crossContext);

View file

@ -14,8 +14,7 @@ void BuildRoutingIndex(string const & baseDir, string const & countryName, strin
/// @param[in] baseDir Full path to .mwm files directory.
/// @param[in] countryName Country name same with .mwm and .border file name.
/// @param[in] osrmFile Full path to .osrm file (all prepared osrm files should be there).
/// @param[in] warningsFile File path to write border intersection warnings. Checks will not
/// perform if it's emplty.
void BuildCrossRoutingIndex(string const & baseDir, string const & countryName,
string const & osrmFile, string const & warningsFile);
string const & osrmFile);
}

View file

@ -1,27 +0,0 @@
#include "warnings_writer.hpp"
#include "coding/file_writer.hpp"
namespace routing
{
void WarningsWriter::Write()
{
if (m_fileName.empty())
return;
stringstream out;
out << "Lat;Lon;Type;\n";
for (auto const & point : m_points)
{
out << point.first.lat << ";" << point.first.lon << ";" << char(point.second) << ";" << std::endl;
}
FileWriter writer(m_fileName);
string const result = out.str();
writer.Write(result.data(), result.size());
}
void WarningsWriter::AddPoint(ms::LatLon const & point, PointType type)
{
if (!m_fileName.empty())
m_points.emplace_back(point, type);
}
} // namespace routing

View file

@ -1,33 +0,0 @@
#pragma once
#include "geometry/latlon.hpp"
#include "std/string.hpp"
#include "std/utility.hpp"
#include "std/vector.hpp"
/* This class is for debugging purposes.
* It writes points to a CSF formatted file.
* We will use this points to determine places where OSRM can't handle a road graph dividing by mwm
* borders.
*/
namespace routing
{
enum class PointType : char
{
EDoubleCross = '1',
EUnconnectedExit = '2'
};
class WarningsWriter
{
vector<pair<ms::LatLon, PointType>> m_points;
string const m_fileName;
public:
WarningsWriter(string const & fileName) : m_fileName(fileName) {}
void AddPoint(ms::LatLon const & point, PointType type);
void Write();
};
} // namespace routing