From e367587b92521e47ef80e11f0c1488507b5ac4c4 Mon Sep 17 00:00:00 2001 From: vng Date: Mon, 15 Aug 2011 17:13:19 +0300 Subject: [PATCH] Add additional types mapping (index <-> type) in classificator. --- data/types.txt | 700 ++++++++++++++++++ .../generator_tests/feature_bucketer_test.cpp | 9 +- generator/generator_tool/generator_tool.cpp | 5 +- indexer/classificator.cpp | 8 +- indexer/classificator.hpp | 9 + indexer/classificator_loader.cpp | 15 +- indexer/classificator_loader.hpp | 5 +- indexer/feature_visibility.cpp | 2 +- indexer/indexer.pro | 2 + indexer/indexer_tests/index_builder_test.cpp | 3 +- indexer/types_mapping.cpp | 40 + indexer/types_mapping.hpp | 49 ++ map/feature_vec_model.cpp | 3 +- search/search_tests/categories_test.cpp | 3 +- 14 files changed, 839 insertions(+), 14 deletions(-) create mode 100644 data/types.txt create mode 100644 indexer/types_mapping.cpp create mode 100644 indexer/types_mapping.hpp diff --git a/data/types.txt b/data/types.txt new file mode 100644 index 0000000000..26d4035850 --- /dev/null +++ b/data/types.txt @@ -0,0 +1,700 @@ +building| +highway|residential| +highway|service| +waterway|stream| +highway|unclassified| +natural|water| +highway|footway| +highway|track| +highway|tertiary| +power|tower| +landuse|forest| +landuse|grass| +highway|secondary| +natural|wood| +landuse|residential| +highway|path| +highway|bus_stop| +natural|tree| +place|locality| +natural|coastline| +place|village| +highway|residential|oneway| +waterway|river| +addr:interpolation|even| +addr:interpolation|odd| +amenity|parking| +highway|primary| +railway|rail| +highway|service|parking_aisle| +place|hamlet| +highway|road| +highway|track|grade2| +natural|wetland| +highway|track|grade3| +boundary|administrative|8| +amenity|school| +highway|cycleway| +landuse|farm| +amenity|place_of_worship| +highway|track|grade1| +highway|secondary|oneway| +highway|service|driveway| +man_made|survey_point| +highway|motorway_link|oneway| +waterway|stream|intermittent| +highway|track|grade4| +highway|tertiary|oneway| +landuse|farmland| +barrier|fence| +highway|primary|oneway| +power|pole| +waterway|riverbank| +highway|path|bicycle| +landuse|meadow| +highway|living_street| +highway|unclassified|oneway| +natural|peak| +highway|motorway|oneway| +highway|steps| +waterway|ditch| +amenity|restaurant| +landuse|reservoir| +highway|track|grade5| +amenity|bench| +highway|service|oneway| +highway|trunk| +amenity|fuel| +leisure|park| +leisure|pitch| +highway|pedestrian| +natural|scrub| +highway|motorway|bridge| +highway|trunk|oneway| +railway|level_crossing| +landuse|industrial| +barrier|wall| +amenity|post_box| +place|town| +power|line| +landuse|farmyard| +highway|residential|bridge| +railway|rail|bridge| +boundary|administrative|10| +boundary|administrative|6| +highway|secondary|bridge| +highway|tertiary|bridge| +barrier|bollard| +leisure|playground| +waterway|drain| +waterway|canal| +highway|trunk_link|oneway| +highway|unclassified|bridge| +landuse|forest|deciduous| +place|island| +highway|primary|bridge| +highway|primary_link|oneway| +amenity|fast_food| +highway|footway|bridge| +amenity|bank| +barrier|hedge| +amenity|pub| +leisure|swimming_pool| +natural|land| +tourism|hotel| +landuse|cemetery| +sport|soccer| +boundary|administrative|4| +amenity|cafe| +amenity|recycling| +leisure|garden| +landuse|commercial| +railway|station| +highway|path|hiking| +amenity|hospital| +waterway|stream|ephemeral| +highway|trunk|bridge| +amenity|post_office| +landuse|quarry| +amenity|pharmacy| +man_made|pier| +highway|motorway_junction| +amenity|telephone| +waterway|stream|tunnel| +tourism|information|guidepost| +amenity|parking|fee| +amenity|kindergarten| +power|generator|wind| +place|suburb| +landuse|allotments| +landuse|forest|coniferous| +landuse|forest|mixed| +natural|wood|mixed| +sport|tennis| +landuse|vineyard| +aeroway|taxiway| +aeroway|aerodrome| +highway|secondary|junction| +amenity|fire_station| +landuse|retail| +leisure|nature_reserve| +leisure|pitch|tennis| +tourism|information| +highway|motorway_link|bridge| +railway|abandoned| +amenity|parking|private| +boundary|administrative|7| +tourism|attraction| +highway|tertiary|junction| +highway|track|private| +railway|tram| +amenity|toilets| +highway|residential|junction| +highway|footway|permissive| +highway|primary|junction| +landuse|construction| +tourism|viewpoint| +amenity|atm| +highway|pedestrian|area| +tourism|picnic_site| +shop|bakery| +highway|construction| +highway|cycleway|bridge| +leisure|sports_centre| +highway|path|mountain_hiking| +tourism|camp_site| +highway|bridleway| +natural|heath| +landuse|basin| +amenity|library| +natural|wood|coniferous| +landuse|recreation_ground| +landuse|village_green| +amenity|drinking_water| +amenity|university| +highway|secondary_link|oneway| +power|sub_station| +railway|tram_stop| +place|city| +amenity|shelter| +natural|beach| +highway|footway|tunnel| +shop|hairdresser| +amenity|hunting_stand| +boundary|administrative|9| +amenity|fountain| +highway|primary_link| +amenity|bar| +landuse|garages| +boundary|administrative|2| +leisure|common| +highway|track|bridge| +highway|path|bridge| +piste:type|nordic| +highway|motorway| +railway|crossing| +boundary|national_park| +natural|wood|deciduous| +waterway|dam| +highway|motorway_link| +leisure|golf_course| +highway|service|bridge| +power|minor_line| +natural|marsh| +leisure|stadium| +amenity|doctors| +railway|disused| +aeroway|runway| +railway|halt| +addr:interpolation|all| +railway|rail|tunnel| +man_made|wastewater_plant| +highway|trunk|motorroad| +place|county| +highway|footway|private| +landuse|conservation| +highway|unclassified|junction| +power|station| +sport|swimming| +leisure|track| +highway|trunk_link| +barrier|retaining_wall| +amenity|college| +sport|baseball| +highway|service|area| +highway|residential|area| +amenity|bus_station| +highway|track|permissive| +waterway|drain|tunnel| +landuse|cemetery|christian| +highway|cycleway|tunnel| +amenity|parking|permissive| +boundary|administrative|5| +highway|unclassified|tunnel| +highway|track|destination| +highway|trunk|junction| +highway|residential|tunnel| +aeroway|helipad| +highway|path|permissive| +place|islet| +sport|basketball| +amenity|cinema| +amenity|theatre| +highway|secondary_link| +railway|spur| +aerialway|station| +landuse|brownfield| +aeroway|apron| +natural|glacier| +amenity|grave_yard| +waterway|canal|tunnel| +piste:type|downhill|easy| +waterway|ditch|tunnel| +landuse|wood| +piste:type|downhill|intermediate| +railway|subway_entrance| +highway|trunk_link|motorroad| +man_made|pipeline| +route|ferry| +highway|trunk_link|bridge| +landuse|military| +highway|service|tunnel| +railway|light_rail| +place|region| +railway|narrow_gauge| +railway|subway| +natural|cave_entrance| +highway|tertiary|tunnel| +landuse|landfill| +amenity|bicycle_rental| +highway|track|oneway| +highway|tertiary_link|oneway| +landuse|greenfield| +tourism|alpine_hut| +highway|footway|area| +tourism|hostel| +waterway|river|tunnel| +boundary|administrative|county| +highway|road|bridge| +boundary|administrative|3| +man_made|pipeline|water| +boundary|administrative| +highway|road|oneway| +highway|path|destination| +sport|athletics| +landuse|railway| +leisure|slipway| +tourism|caravan_site| +place|state| +highway|path|private| +railway|subway|tunnel| +barrier|city_wall| +place|farm| +boundary|administrative|11| +waterway|weir| +highway|secondary|tunnel| +railway|abandoned|bridge| +man_made|lighthouse| +highway|path|demanding_mountain_hiking| +highway|primary|motorroad| +amenity|restaurant|hotel| +power|generator| +highway|pedestrian|bridge| +man_made|pipeline|overground| +amenity|parking|destination| +highway|unsurfaced| +highway|raceway| +highway|primary|tunnel| +highway|primary_link|bridge| +landuse|conservation|private| +sport|equestrian| +tourism|information|office| +highway|footway|hiking| +aeroway|gate| +railway|preserved| +highway|path|horse| +landuse|field| +highway|tertiary_link| +leisure|water_park| +natural|wetland|bog| +man_made|windmill| +military|bunker| +aerialway|chair_lift| +amenity|grave_yard|christian| +highway|trunk|tunnel| +highway|steps|tunnel| +amenity|car_sharing| +sport|football| +highway|steps|bridge| +highway|track|tunnel| +highway|pedestrian|tunnel| +power|generator|hydro| +sport|cricket| +sport|bowls| +highway|path|tunnel| +man_made|breakwater| +amenity|parking|permissive|fee| +railway|disused|bridge| +tourism|zoo| +sport|gymnastics| +highway|trunk_link|junction| +railway|subway|bridge| +railway|light_rail|bridge| +aeroway|terminal| +railway|tram|bridge| +piste:type|downhill|advanced| +sport|shooting| +place|country| +highway|path|alpine_hiking| +highway|footway|destination| +sport|scuba_diving| +highway|cycleway|permissive| +highway|unclassified|area| +natural|volcano| +amenity|parking|underground|fee| +amenity|parking|underground| +man_made|pipeline|gas| +amenity|parking|multi-storey| +leisure|recreation_ground|private| +highway|footway|mountain_hiking| +highway|service|driveway|bridge| +amenity|parking|multi-storey|fee| +leisure|track|area| +highway|byway| +piste:type|downhill|novice| +railway|narrow_gauge|bridge| +noexit|motorcar| +highway|service|parking_aisle|tunnel| +highway|bridleway|permissive| +railway|construction| +highway|primary_link|junction| +landuse|greenhouse_horticulture| +highway|primary_link|motorroad| +amenity|bureau_de_change| +power|generator|photovoltaic| +highway|motorway_link|junction| +highway|bridleway|bridge| +highway|service|driveway|tunnel| +highway|track|cutting| +landuse|basin|retention| +railway|narrow_gauge|tunnel| +railway|dismantled| +waterway|dock| +natural|forest| +highway|service|driveway|area| +man_made|pipeline|heat| +place|city|capital| +aerialway|cable_car| +piste:type|downhill| +sport|american_football| +highway|cycleway|destination| +man_made|cairn| +railway|preserved|bridge| +highway|path|demanding_alpine_hiking| +landuse|basin|infiltration| +highway|secondary_link|bridge| +railway|tram|tunnel| +highway|footway|cutting| +railway|abandoned|tunnel| +highway|living_street|area| +piste:type|sled| +aerialway|chair_lift|4| +leisure|dog_park| +aerialway|gondola| +historic|museum| +highway|living_street|bridge| +highway|service|cutting| +railway|monorail| +highway|road|junction| +man_made|pipeline|oil| +leisure|park|private| +highway|secondary|motorroad| +noexit|motor_vehicle| +highway|service|parking_aisle|bridge| +highway|motorway|tunnel| +railway|light_rail|tunnel| +highway|service|parking_aisle|area| +highway|residential|construction| +highway|motorway|construction| +highway|path|cutting| +landuse|scrub| +highway|road|tunnel| +sport|archery| +railway|construction|bridge| +highway|track|grade2|area| +highway|ford| +highway|path|area| +railway|siding| +highway|track|area| +highway|minor| +railway|funicular| +amenity|parking|public|fee| +historic|battlefield| +highway|primary|construction| +sport|australian_football| +railway|disused|tunnel| +highway|secondary_link|junction| +highway|cycleway|private| +highway|steps|cutting| +piste:lift|t-bar| +highway|trunk|construction| +amenity|parking|public| +highway|path|difficult_alpine_hiking| +earthquake:damage|spontaneous_camp| +highway|cycleway|cutting| +railway|yard| +highway|trunk|cutting| +natural|meadow| +highway|motorway|cutting| +railway|razed| +highway|footway|demanding_mountain_hiking| +aerialway|chair_lift|6| +landuse|basin|detention| +landuse|orchard| +highway|track|grade1|area| +highway|living_street|tunnel| +highway|secondary|construction| +highway|living_street|junction| +railway|construction|tunnel| +sport|handball| +boundary|administrative|city| +piste:type|downhill|freeride| +amenity|restaurant|vegetarian| +communication|line|submarine| +piste:type|downhill|expert| +landuse|salt_pond| +landuse|reservoir|water_storage| +railway|monorail|bridge| +highway|steps|area| +railway|proposed| +highway|tertiary|construction| +landuse|wood|deciduous| +natural|grass| +highway|road|area| +highway|tertiary|area| +piste:lift|platter| +man_made|pipeline|natural_gas| +highway|unclassified|disused| +railway|preserved|tunnel| +noexit|vehicle| +highway|disused| +highway|unclassified|construction| +highway|service|disused| +highway|service|construction| +highway|cycleway|disused| +leisure|park|permissive| +highway|bridleway|tunnel| +highway|motorway_link|tunnel| +highway|residential|disused| +highway|cycleway|construction| +highway|bridleway|private| +highway|tertiary_link|bridge| +highway|footway|construction| +amenity|parking|park_and_ride| +highway|track|dyke| +highway|track|grade3|area| +landuse|wood|mixed| +waterway|lock| +highway|path|dyke| +highway|motorway|junction| +highway|motorway_link|construction| +highway|trunk_link|tunnel| +highway|footpath| +highway|path|disused| +highway|tertiary|motorroad| +leisure|green| +landuse|reservoir|sewage| +railway|spur|bridge| +highway|track|disused| +highway|tertiary_link|junction| +highway|track|grade3|destination| +sport|curling| +landuse|reservoir|evaporator| +landuse|wood|coniferous| +natural|scrub|deciduous| +highway|footway|disused| +leisure|playground|tennis| +highway|secondary|area| +sport|diving| +highway|track|grade3|private| +boundary|administrative|suburb| +natural|quarry| +railway|monorail|tunnel| +railway|funicular|bridge| +highway|trunk_link|construction| +highway|footway|dyke| +highway|primary_link|tunnel| +highway|footway|alpine_hiking| +natural|scrub|mixed| +highway|byway|bridge| +man_made|pipeline|hot_water| +leisure|landscape_reserve| +leisure|playing_fields| +highway|secondary_link|motorroad| +boundary|administrative|state| +highway|cycleway|dyke| +highway|cycleway|area| +railway|funicular|tunnel| +barrier|cycle_barrier| +highway|unsurfaced|bridge| +amenity|speed_trap| +highway|track|grade4|area| +highway|primary|area| +power|line|underground| +amenity|restaurant|vegan| +highway|track|construction| +highway|minor|oneway| +highway|bridleway|cutting| +waterway|lock_gate| +railway|proposed|tunnel| +highway|primary|disused| +highway|unsurfaced|private| +highway|path|construction| +highway|footway|demanding_alpine_hiking| +railway|proposed|bridge| +highway|track|grade4|destination| +landuse|runway| +natural|farm| +highway|unsurfaced|oneway| +highway|motorway_link|disused| +highway|crossing|uncontrolled| +highway|track|junction| +natural|lake| +man_made|pipeline|sewage| +highway|primary_link|construction| +landuse|reservoir|tailings| +highway|secondary|disused| +highway|track|grade5|destination| +natural|basin| +aerialway|chair_lift|5| +natural|reservoir| +highway|steps|construction| +highway|motorway|area| +piste:lift|rope_tow| +natural|pond| +natural|industrial| +highway|secondary_link|tunnel| +highway|pedestrian|junction| +highway|track|grade5|private| +highway|track|grade5|area| +natural|forest|deciduous| +highway|living_street|construction| +highway|track|racetrack| +highway|tertiary|disused| +highway|steps|disused| +aerialway|mixed_lift| +railway|planned| +highway|footway|cycleway| +power|line|submarine| +highway|track|grade3|permissive| +highway|track|grade4|private| +highway|byway|permissive| +natural|railway| +highway|service|dyke| +railway|incline| +boundary|administrative|region| +highway|pedestrian|construction| +highway|path|t1| +landuse|raceway| +place|continent| +natural|farmland| +highway|footpath|private| +boundary|administrative|nation| +railway|dismantled|bridge| +natural|landfill| +highway|byway|tunnel| +piste:lift|magic_carpet| +natural|scrub|coniferous| +highway|unsurfaced|permissive| +highway|bridleway|destination| +highway|motorway|disused| +landuse|runway|disused| +highway|unsurfaced|destination| +natural|brownfield| +natural|village_green| +highway|track|embankment| +highway|footpath|bridge| +piste:lift|j-bar| +landuse|scrub|deciduous| +highway|bridleway|area| +natural|military| +highway|byway|private| +natural|forest|mixed| +highway|raceway|disused| +railway|siding|bridge| +highway|footway|difficult_alpine_hiking| +man_made|pipeline|oil|overground| +highway|primary_link|area| +highway|primary_link|disused| +highway|track|grade5|permissive| +landuse|reservoir|cooling| +aeroway|airport| +highway|tertiary_link|tunnel| +man_made|piste:halfpipe| +highway|footpath|permissive| +highway|tertiary|cycleway| +highway|trunk|area| +highway|secondary_link|construction| +landuse|street| +leisure|park|destination| +highway|footway|t2| +landuse|raceway|disused| +highway|motorway_link|area| +natural|recreation_ground| +highway|minor|bridge| +highway|secondary|cycleway| +highway|track|dike| +natural|forest|coniferous| +highway|footway|embankment| +railway|spur|tunnel| +highway|path|t5| +highway|path|t3| +highway|trunk|disused| +highway|trunk_link|area| +railway|incline|tunnel| +boundary|administrative|municipality| +highway|path|t2| +highway|byway|destination| +natural|construction| +communication|line| +highway|tertiary_link|motorroad| +railway|dismantled|tunnel| +leisure|recreation_ground|permissive| +railway|yard|bridge| +landuse|raceway|dismantled| +railway|planned|tunnel| +highway|residential|turning_circle| +highway|bridleway|disused| +highway|service|cycleway| +highway|pedestrian|disused| +highway|unsurfaced|area| +highway|minor|tunnel| +highway|minor|area| +highway|track|grade4|permissive| +highway|crossing|zebra| +landuse|runway|dismantled| +highway|bridleway|construction| +railway|planned|bridge| +highway|service|embankment| +highway|crossing|island| +highway|unclassified|cycleway| +highway|residential|cycleway| +natural|commercial| +highway|path|embankment| +natural|vineyard| +highway|cycleway|dike| +man_made|pipeline|water|overground| +highway|footpath|area| +highway|road|turning_circle| +boundary|administrative|country| +highway|service|levee| +natural|orchard| +natural|retail| +communication|line|underground| +natural|cemetery| +highway|track|levee| +highway|path|dike| +highway|tertiary_link|area| +highway|unsurfaced|tunnel| +highway|secondary_link|area| +natural|allotments| diff --git a/generator/generator_tests/feature_bucketer_test.cpp b/generator/generator_tests/feature_bucketer_test.cpp index 39f22e8b01..6e3f48a466 100644 --- a/generator/generator_tests/feature_bucketer_test.cpp +++ b/generator/generator_tests/feature_bucketer_test.cpp @@ -47,11 +47,14 @@ namespace UNIT_TEST(FeatureBucketerSmokeTest) { + Platform & pl = GetPlatform(); + // classificator is needed because inside bucketer we're use it in WorldMapGenerator // @TODO clean up or remove cell bucketer and replace with world countries bucketer - classificator::Read(GetPlatform().GetReader("drawing_rules.bin"), - GetPlatform().GetReader("classificator.txt"), - GetPlatform().GetReader("visibility.txt")); + classificator::Read(pl.GetReader("drawing_rules.bin"), + pl.GetReader("classificator.txt"), + pl.GetReader("visibility.txt"), + pl.GetReader("types.txt")); map > out, expectedOut; FeatureBucketer bucketer(1, &out); diff --git a/generator/generator_tool/generator_tool.cpp b/generator/generator_tool/generator_tool.cpp index 2256516b4d..e71801237d 100644 --- a/generator/generator_tool/generator_tool.cpp +++ b/generator/generator_tool/generator_tool.cpp @@ -119,7 +119,8 @@ int main(int argc, char ** argv) { classificator::Read(pl.GetReader("drawing_rules.bin"), pl.GetReader("classificator.txt"), - pl.GetReader("visibility.txt")); + pl.GetReader("visibility.txt"), + pl.GetReader("types.txt")); classificator::PrepareForFeatureGeneration(); } @@ -220,7 +221,7 @@ int main(int argc, char ** argv) if (FLAGS_dump_types) { - feature::DumpNames(path + FLAGS_output + ".mwm"); + //feature::DumpNames(path + FLAGS_output + ".mwm"); feature::DumpTypes(path + FLAGS_output + ".mwm"); } diff --git a/indexer/classificator.cpp b/indexer/classificator.cpp index 736d46e3b0..303aec852c 100644 --- a/indexer/classificator.cpp +++ b/indexer/classificator.cpp @@ -485,7 +485,7 @@ uint32_t Classificator::GetTypeByPath(vector const & path) while (i < path.size()) { ClassifObjectPtr ptr = p->BinaryFind(path[i]); - ASSERT ( ptr, ("Invalid path in Classificator::GetTypeByPath") ); + ASSERT ( ptr, ("Invalid path in Classificator::GetTypeByPath", path) ); ftype::PushValue(type, ptr.GetIndex()); @@ -495,3 +495,9 @@ uint32_t Classificator::GetTypeByPath(vector const & path) return type; } + +void Classificator::ReadTypesMapping(string const & buffer) +{ + m_i2t.Load(buffer); + m_t2i.Load(buffer); +} diff --git a/indexer/classificator.hpp b/indexer/classificator.hpp index cabec15a86..006005a97a 100644 --- a/indexer/classificator.hpp +++ b/indexer/classificator.hpp @@ -1,5 +1,6 @@ #pragma once #include "drawing_rule_def.hpp" +#include "types_mapping.hpp" #include "../base/base.hpp" @@ -195,6 +196,9 @@ class Classificator { ClassifObject m_root; + Index2Type m_i2t; + Type2Index m_t2i; + static ClassifObject * AddV(ClassifObject * parent, string const & key, string const & value); public: @@ -210,6 +214,8 @@ public: void ReadVisibility(string const & buffer); void PrintVisibility(char const * fPath); + void ReadTypesMapping(string const & buffer); + void SortClassificator(); //@} @@ -217,6 +223,9 @@ public: /// path = ["natural", "caostline"]. uint32_t GetTypeByPath(vector const & path); + uint32_t TypeForIndex(uint32_t t) const { return m_t2i.GetIndex(t); } + uint32_t IndexForType(uint32_t i) const { return m_i2t.GetType(i); } + // Iterate for possible objects types //template void ForEachType(ToDo toDo) //{ diff --git a/indexer/classificator_loader.cpp b/indexer/classificator_loader.cpp index 23a1b74a7c..8d1995b816 100644 --- a/indexer/classificator_loader.cpp +++ b/indexer/classificator_loader.cpp @@ -10,7 +10,10 @@ namespace classificator { - void Read(file_t const & rules, file_t const & classificator, file_t const & visibility) + void Read(file_t const & rules, + file_t const & classificator, + file_t const & visibility, + file_t const & types) { LOG(LINFO, ("Reading drawing rules")); ReaderPtrStream rulesS(rules); @@ -18,13 +21,19 @@ namespace classificator string buffer; + Classificator & c = classif(); + LOG(LINFO, ("Reading classificator")); classificator.ReadAsString(buffer); - classif().ReadClassificator(buffer); + c.ReadClassificator(buffer); LOG(LINFO, ("Reading visibility")); visibility.ReadAsString(buffer); - classif().ReadVisibility(buffer); + c.ReadVisibility(buffer); + + LOG(LINFO, ("Reading types mapping")); + types.ReadAsString(buffer); + c.ReadTypesMapping(buffer); LOG(LINFO, ("Reading of classificator done")); } diff --git a/indexer/classificator_loader.hpp b/indexer/classificator_loader.hpp index 933904fa77..989ecae8e7 100644 --- a/indexer/classificator_loader.hpp +++ b/indexer/classificator_loader.hpp @@ -8,6 +8,9 @@ namespace classificator { typedef ReaderPtr file_t; - void Read(file_t const & rules, file_t const & classificator, file_t const & visibility); + void Read(file_t const & rules, + file_t const & classificator, + file_t const & visibility, + file_t const & types); void ReadVisibility(string const & fPath); } diff --git a/indexer/feature_visibility.cpp b/indexer/feature_visibility.cpp index a33209b5f2..d5a51b76c6 100644 --- a/indexer/feature_visibility.cpp +++ b/indexer/feature_visibility.cpp @@ -86,7 +86,7 @@ string Classificator::GetFullObjectName(uint32_t type) const { ++i; p = p->GetObject(v); - s = s + p->GetName() + '-'; + s = s + p->GetName() + '|'; } return s; diff --git a/indexer/indexer.pro b/indexer/indexer.pro index 5afb275fb7..b1a7b4d53b 100644 --- a/indexer/indexer.pro +++ b/indexer/indexer.pro @@ -30,6 +30,7 @@ SOURCES += \ tesselator.cpp \ feature_data.cpp \ feature_rect.cpp \ + types_mapping.cpp HEADERS += \ feature.hpp \ @@ -64,3 +65,4 @@ HEADERS += \ tesselator_decl.hpp \ feature_data.hpp \ feature_rect.hpp \ + types_mapping.hpp diff --git a/indexer/indexer_tests/index_builder_test.cpp b/indexer/indexer_tests/index_builder_test.cpp index 54221c6136..96f86cf48b 100644 --- a/indexer/indexer_tests/index_builder_test.cpp +++ b/indexer/indexer_tests/index_builder_test.cpp @@ -19,7 +19,8 @@ UNIT_TEST(BuildIndexTest) Platform & p = GetPlatform(); classificator::Read(p.GetReader("drawing_rules.bin"), p.GetReader("classificator.txt"), - p.GetReader("visibility.txt")); + p.GetReader("visibility.txt"), + p.GetReader("types.txt")); FilesContainerR originalContainer(p.GetReader("minsk-pass" DATA_FILE_EXTENSION)); diff --git a/indexer/types_mapping.cpp b/indexer/types_mapping.cpp new file mode 100644 index 0000000000..d8f04c8c97 --- /dev/null +++ b/indexer/types_mapping.cpp @@ -0,0 +1,40 @@ +#include "types_mapping.hpp" +#include "classificator.hpp" + +#include "../base/string_utils.hpp" +#include "../base/stl_add.hpp" + + +void BaseTypeMapper::Load(string const & buffer) +{ + istringstream ss(buffer); + Classificator & c = classif(); + + string v; + vector path; + + uint32_t ind = 0; + while (true) + { + ss >> v; + + if (ss.eof()) + break; + + path.clear(); + strings::Tokenize(v, "|", MakeBackInsertFunctor(path)); + + Add(ind++, c.GetTypeByPath(path)); + } +} + +void Index2Type::Add(uint32_t ind, uint32_t type) +{ + ASSERT_EQUAL ( ind, m_types.size(), () ); + m_types.push_back(type); +} + +void Type2Index::Add(uint32_t ind, uint32_t type) +{ + VERIFY ( m_map.insert(make_pair(type, ind)).second, (type, ind) ); +} diff --git a/indexer/types_mapping.hpp b/indexer/types_mapping.hpp new file mode 100644 index 0000000000..57605c4278 --- /dev/null +++ b/indexer/types_mapping.hpp @@ -0,0 +1,49 @@ +#pragma once +#include "../base/assert.hpp" + +#include "../std/vector.hpp" +#include "../std/map.hpp" + + +class BaseTypeMapper +{ +protected: + virtual void Add(uint32_t ind, uint32_t type) = 0; + +public: + void Load(string const & buffer); +}; + +class Index2Type : public BaseTypeMapper +{ + vector m_types; + +protected: + virtual void Add(uint32_t ind, uint32_t type); + +public: + uint32_t GetType(uint32_t ind) const + { + ASSERT_LESS ( ind, m_types.size(), () ); + return m_types[ind]; + } +}; + +class Type2Index : public BaseTypeMapper +{ + typedef map MapT; + MapT m_map; + +protected: + virtual void Add(uint32_t ind, uint32_t type); + +public: + uint32_t GetIndex(uint32_t t) const + { + MapT::const_iterator i = m_map.find(t); + ASSERT ( i != m_map.end(), () ); + return i->second; + } +}; + +void PrintTypesDefault(string const & fPath); diff --git a/map/feature_vec_model.cpp b/map/feature_vec_model.cpp index 132e28aeed..9c71235446 100644 --- a/map/feature_vec_model.cpp +++ b/map/feature_vec_model.cpp @@ -25,7 +25,8 @@ void FeaturesFetcher::InitClassificator() { classificator::Read(p.GetReader("drawing_rules.bin"), p.GetReader("classificator.txt"), - p.GetReader("visibility.txt")); + p.GetReader("visibility.txt"), + p.GetReader("types.txt")); } catch (FileAbsentException const & e) { diff --git a/search/search_tests/categories_test.cpp b/search/search_tests/categories_test.cpp index 1aaccd40e3..7ec8391924 100644 --- a/search/search_tests/categories_test.cpp +++ b/search/search_tests/categories_test.cpp @@ -72,7 +72,8 @@ UNIT_TEST(LoadCategories) Platform & p = GetPlatform(); classificator::Read(p.GetReader("drawing_rules.bin"), p.GetReader("classificator.txt"), - p.GetReader("visibility.txt")); + p.GetReader("visibility.txt"), + p.GetReader("types.txt")); search::CategoriesHolder h; string buffer = TEST_STRING;