From de14dff9fd3c6a309590c4f8ab0fb643e8cbb1d4 Mon Sep 17 00:00:00 2001 From: Ilya Zverev Date: Thu, 12 Mar 2015 18:30:17 +0300 Subject: [PATCH] Remove generating borders from osm and producing poly --- generator/borders_generator.hpp | 2 -- generator/borders_loader.cpp | 31 ------------------- generator/borders_loader.hpp | 3 -- generator/generator_tests/osm_parser_test.cpp | 25 --------------- generator/generator_tool/generator_tool.cpp | 25 --------------- 5 files changed, 86 deletions(-) diff --git a/generator/borders_generator.hpp b/generator/borders_generator.hpp index cf69d8beb5..297973dcb3 100644 --- a/generator/borders_generator.hpp +++ b/generator/borders_generator.hpp @@ -8,8 +8,6 @@ namespace osm { - void GenerateBordersFromOsm(string const & tagAndOptValue, string const & osmFile, - string const & outFile); /// @return false if borderFile can't be opened bool LoadBorders(string const & borderFile, vector & outBorders); } diff --git a/generator/borders_loader.cpp b/generator/borders_loader.cpp index 0960c058e9..4d4c213024 100644 --- a/generator/borders_loader.cpp +++ b/generator/borders_loader.cpp @@ -172,35 +172,4 @@ void GeneratePackedBorders(string const & baseDir) generator.WritePolygonsInfo(); } -void ExportOSMPolylines(string const & outDir, CountriesContainerT const & countries) -{ - countries.ForEach( [&] (CountryPolygons const & cp) - { - // .poly file format described here: http://wiki.openstreetmap.org/wiki/Osmosis/Polygon_Filter_File_Format - ostringstream stream; - stream << cp.m_name << endl; - - size_t regionNumber = 0; - cp.m_regions.ForEach( [&] (Region const & r) - { - stream << ++regionNumber << endl; - - r.ForEachPoint( [&] (m2::PointD const & pt) - { - stream << '\t' << std::scientific << MercatorBounds::XToLon(pt.x) << '\t' << MercatorBounds::YToLat(pt.y) << endl; - } ); - - stream << "END" << endl; - - } ); - - stream << "END" << endl; - - FileWriter w(outDir + "/" + cp.m_name + ".poly"); - string const contents = stream.str(); - w.Write(contents.data(), contents.size()); - - } ); -} - } // namespace borders diff --git a/generator/borders_loader.hpp b/generator/borders_loader.hpp index 962db8efe5..bd94520d5d 100644 --- a/generator/borders_loader.hpp +++ b/generator/borders_loader.hpp @@ -35,7 +35,4 @@ namespace borders bool LoadCountriesList(string const & baseDir, CountriesContainerT & countries); void GeneratePackedBorders(string const & baseDir); - - /// Converts our borders into OSM .poly file format - void ExportOSMPolylines(string const & outDir, CountriesContainerT const & countries); } diff --git a/generator/generator_tests/osm_parser_test.cpp b/generator/generator_tests/osm_parser_test.cpp index 28f04670e7..0bd29e072b 100644 --- a/generator/generator_tests/osm_parser_test.cpp +++ b/generator/generator_tests/osm_parser_test.cpp @@ -180,28 +180,3 @@ UNIT_TEST(OsmRawData_SmokeTest) relations = osmData.RelationsByTag(OsmTag("boundary", "administrative")); TEST_EQUAL(relations.size(), 2, ()); } - -UNIT_TEST(BordersGenerator) -{ - string const inputFile("BordersTestInputFile"); - string const outputFile("BordersTestOutputFile"); - - { // create input file - FileWriter f(inputFile); - f.Write(gOsmXml, ARRAY_SIZE(gOsmXml) - 1); // -1 to skip last zero - } - - GenerateBordersFromOsm("ISO3166-1", inputFile, outputFile); - vector borders; - LoadBorders(outputFile, borders); - TEST_EQUAL(borders.size(), 2, ()); - - GenerateBordersFromOsm("admin_level=4", inputFile, outputFile); - borders.clear(); - LoadBorders(outputFile, borders); - TEST_EQUAL(borders.size(), 1, ()); - - - FileWriter::DeleteFileX(inputFile); - FileWriter::DeleteFileX(outputFile); -} diff --git a/generator/generator_tool/generator_tool.cpp b/generator/generator_tool/generator_tool.cpp index 18f1bd264d..0e1b33f7c4 100644 --- a/generator/generator_tool/generator_tool.cpp +++ b/generator/generator_tool/generator_tool.cpp @@ -50,9 +50,6 @@ DEFINE_string(output, "", "File name for process (without 'mwm' ext)."); DEFINE_string(intermediate_data_path, "", "Path to stored nodes, ways, relations."); DEFINE_bool(generate_world, false, "Generate separate world file"); DEFINE_bool(split_by_polygons, false, "Use countries borders to split planet by regions and countries"); -DEFINE_string(generate_borders, "", - "Create binary country .borders file for osm xml file given in 'output' parameter," - "specify tag name and optional value: ISO3166-1 or admin_level=4"); DEFINE_bool(dump_types, false, "Prints all types combinations and their total count"); DEFINE_bool(dump_prefixes, false, "Prints statistics on feature's' name prefixes"); DEFINE_bool(dump_search_tokens, false, "Print statistics on search tokens."); @@ -62,7 +59,6 @@ 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_string(export_poly_path, "", "Output dir for osm .poly files created from .borders (countires are read from polygons.lst)"); DEFINE_string(osrm_file_name, "", "Input osrm file to generate routing info"); DEFINE_string(osm_file_name, "", "Input osm area file"); DEFINE_string(osm_file_type, "xml", "Input osm area file type [xml, o5m]"); @@ -217,20 +213,6 @@ int main(int argc, char ** argv) update::UpdateCountries(path); } - if (!FLAGS_generate_borders.empty()) - { - if (!FLAGS_output.empty()) - { - osm::GenerateBordersFromOsm(FLAGS_generate_borders, - path + FLAGS_output + ".osm", - path + FLAGS_output + BORDERS_EXTENSION); - } - else - { - LOG(LINFO, ("Please specify osm country borders file in 'output' command line parameter.")); - } - } - string const datFile = path + FLAGS_output + DATA_FILE_EXTENSION; if (FLAGS_calc_statistics) @@ -266,13 +248,6 @@ int main(int argc, char ** argv) if (FLAGS_check_mwm) check_model::ReadFeatures(datFile); - if (!FLAGS_export_poly_path.empty()) - { - borders::CountriesContainerT countries; - borders::LoadCountriesList(path, countries); - borders::ExportOSMPolylines(FLAGS_export_poly_path, countries); - } - if (!FLAGS_osrm_file_name.empty()) routing::BuildRoutingIndex(path, FLAGS_output, FLAGS_osrm_file_name);