Add binary drawing rules generation from text rules file.

This commit is contained in:
vng 2011-11-24 23:49:10 +03:00 committed by Alex Zolotarev
parent f28bb0b490
commit aeab46c84f
3 changed files with 18 additions and 7 deletions

View file

@ -22,6 +22,9 @@
#define PACKED_POLYGONS_FILE "packed_polygons.bin"
#define PACKED_POLYGONS_INFO_TAG "info"
#define DRAWING_RULES_TXT_FILE "drules_proto.txt"
#define DRAWING_RULES_BIN_FILE "drules_proto.bin"
/// How many langs we're supporting on indexing stage
#define MAX_SUPPORTED_LANGUAGES 64

View file

@ -9,6 +9,7 @@
#include "../unpack_mwm.hpp"
#include "../generate_info.hpp"
#include "../../indexer/drawing_rules.hpp"
#include "../../indexer/classificator_loader.hpp"
#include "../../indexer/data_header.hpp"
#include "../../indexer/features_vector.hpp"
@ -94,6 +95,15 @@ int main(int argc, char ** argv)
// Make a classificator
if (FLAGS_generate_classif)
{
drule::RulesHolder & rules = drule::rules();
string buffer;
ModelReaderPtr(pl.GetReader(DRAWING_RULES_TXT_FILE)).ReadAsString(buffer);
rules.LoadFromTextProto(buffer);
ofstream s((path + DRAWING_RULES_BIN_FILE).c_str(), ios::out | ios::binary);
rules.SaveToBinaryProto(buffer, s);
}
// Generating intermediate files

View file

@ -2,7 +2,9 @@
#include "classificator.hpp"
#include "drawing_rules.hpp"
#include "../../platform/platform.hpp"
#include "../defines.hpp"
#include "../platform/platform.hpp"
#include "../coding/reader_streambuf.hpp"
@ -67,7 +69,7 @@ namespace classificator
try
{
// Load from protobuffer binary file.
ReaderStreamBuf buffer(p.GetReader("drules_proto.bin"));
ReaderStreamBuf buffer(p.GetReader(DRAWING_RULES_BIN_FILE));
istream s(&buffer);
rules.LoadFromBinaryProto(s);
@ -78,13 +80,9 @@ namespace classificator
{
// Load from protobuffer text file.
string buffer;
ModelReaderPtr(p.GetReader("drules_proto.txt")).ReadAsString(buffer);
ModelReaderPtr(p.GetReader(DRAWING_RULES_TXT_FILE)).ReadAsString(buffer);
rules.LoadFromTextProto(buffer);
// Uncomment this to save actual drawing rules to binary proto format.
//ofstream s(p.WritablePathForFile("drules_proto.bin").c_str(), ios::out | ios::binary);
//rules.SaveToBinaryProto(buffer, s);
}
catch (Reader::OpenException const &)
{