📄 configuration.cpp
字号:
drawn = remove_whitespace(drawn); line_drawprop_t ldp; ldp.rgb[0] = atof(r.c_str()); ldp.rgb[1] = atof(g.c_str()); ldp.rgb[2] = atof(b.c_str()); ldp.size = atof(size.c_str()); if (drawn == "true") lines_drawn[object_name_num_map[int_name]] = true; else lines_drawn[object_name_num_map[int_name]] = false; line_drawprops[object_name_num_map[int_name]] = ldp; } file.close(); return 0;}/** * Load the catalog file from the current config dir * @return -1 on failure, 0 on success */int Configuration::LoadCatalogFile(){ boost::filesystem::ifstream file; file.open(dir / "enc"); if (!file) { std::cerr << "Configuration::LoadCatalogFile():" << "Couldn't open file " << (dir / "enc").string() << std::endl; return -1; } std::string field; std::getline(file, field); field = remove_whitespace(field); catalog = field; file.close(); if (!is_catalog(field.c_str())) { std::cerr << "Configuration::LoadCatalogFile(): " << field << " is not a valid catalog file" << std::endl; return -1; } return 0;}/** * Generate a new configuration * @param catalog_file catalog file * @param confdir configuration directory * @return -1 on failure, 0 on success */int Configuration::GenerateConfiguration(boost::filesystem::path &catalog_file, boost::filesystem::path &confdir){ catalog = catalog_file; dir = confdir; boost::filesystem::path filename; try { if (boost::filesystem::exists(dir)) boost::filesystem::remove_all(dir); boost::filesystem::create_directory(dir); } catch (...) { std::cerr << "Configuration::GenerateConfiguration: Error creating" << " config dir at " << dir.string() << std::endl; return -1; } // create enc file filename = dir / "enc"; boost::filesystem::ofstream enc(filename); if (!enc.is_open()) { std::cerr << "Configuration::GenerateConfiguration:: " << "Error generating enc file" << std::endl; boost::filesystem::remove_all(dir); return -1; } else { enc << catalog_file.string() << std::endl; } enc.close(); // create the default areadrawprop file filename = dir / "areadrawprop"; boost::filesystem::ofstream areadrawprop(filename); if (!areadrawprop.is_open()) { std::cerr << "Configuration::GenerateConfiguration:: " << "Error generating areadrawprop file" << std::endl; boost::filesystem::remove_all(dir); return -1; } else { areadrawprop << "ACHARE .4 .2 .8 false" << std::endl; areadrawprop << "ACHBRT .4 .2 .8 false" << std::endl; areadrawprop << "ADMARE .4 .2 .8 false" << std::endl; areadrawprop << "AIRARE .4 .2 .8 false" << std::endl; areadrawprop << "BERTHS .4 .2 .8 false" << std::endl; areadrawprop << "BRIDGE .1 .1 .1 false" << std::endl; areadrawprop << "BUAARE .1 .1 .1 false" << std::endl; areadrawprop << "BUISGL .1 .1 .1 false" << std::endl; areadrawprop << "CANALS .1 .1 1 false" << std::endl; areadrawprop << "CAUSWY .3 .2 .4 false" << std::endl; areadrawprop << "CBLARE .4 .1 .2 false" << std::endl; areadrawprop << "CHKPNT .1 .5 .1 false" << std::endl; areadrawprop << "CONVYR .3 .2 .8 false" << std::endl; areadrawprop << "CONZNE .3 .2 .8 false" << std::endl; areadrawprop << "COSARE .3 .2 .8 false" << std::endl; areadrawprop << "CRANES .3 .2 .8 false" << std::endl; areadrawprop << "CTNARE .3 .2 .8 false" << std::endl; areadrawprop << "CTSARE .3 .2 .8 false" << std::endl; areadrawprop << "CUSZNE .3 .2 .8 false" << std::endl; areadrawprop << "DAMCON .9 .4 .8 false" << std::endl; areadrawprop << "DEPARE .5 .3 .9 false" << std::endl; areadrawprop << "DOCARE .5 .3 .9 false" << std::endl; areadrawprop << "DRGARE .5 .3 .9 false" << std::endl; areadrawprop << "DRYDOC .5 .3 .9 false" << std::endl; areadrawprop << "DMPGRD .5 .3 .9 false" << std::endl; areadrawprop << "DYKCON .3 .2 .5 false" << std::endl; areadrawprop << "DWRTPT .8 .5 .4 false" << std::endl; areadrawprop << "EXEZNE .1 .1 .3 false" << std::endl; areadrawprop << "FAIRWY .4 .3 .6 false" << std::endl; areadrawprop << "FERYRT .4 .3 .6 false" << std::endl; areadrawprop << "FLODOC .8 .7 .8 false" << std::endl; areadrawprop << "FORSTC .5 .3 .4 false" << std::endl; areadrawprop << "FRPARE .4 .4 .4 false" << std::endl; areadrawprop << "FSHFAC .1 .8 .5 false" << std::endl; areadrawprop << "FSHGRD .1 .8 .5 false" << std::endl; areadrawprop << "FSHZNE .1 .8 .5 false" << std::endl; areadrawprop << "GATCON .8 .4 .6 false" << std::endl; areadrawprop << "GRIDRN .8 .4 .6 false" << std::endl; areadrawprop << "HRBARE .8 .4 .6 false" << std::endl; areadrawprop << "HRBFAC .8 .4 .6 false" << std::endl; areadrawprop << "HULKES .8 .4 .6 false" << std::endl; areadrawprop << "ICEARE .8 .4 .6 false" << std::endl; areadrawprop << "ICNARE .8 .4 .6 false" << std::endl; areadrawprop << "ISTZNE .8 .4 .6 false" << std::endl; areadrawprop << "LAKARE .8 .4 .6 false" << std::endl; areadrawprop << "LNDARE 0 .1 0 false" << std::endl; areadrawprop << "LNDMRK .4 .3 .6 false" << std::endl; areadrawprop << "LNDRGN .4 .3 .6 false" << std::endl; areadrawprop << "LOCMAG .3 .9 .5 false" << std::endl; areadrawprop << "LOGPON .3 .9 .5 false" << std::endl; areadrawprop << "MAGVAR .7 .5 .7 false" << std::endl; areadrawprop << "MARCUL .4 .3 .4 false" << std::endl; areadrawprop << "MIPARE .4 .3 .4 false" << std::endl; areadrawprop << "MORFAC .5 .7 .6 false" << std::endl; areadrawprop << "OBSTRN .3 .3 .3 false" << std::endl; areadrawprop << "OFSPLF .3 .3 .3 false" << std::endl; areadrawprop << "OSPARE .3 .3 .3 false" << std::endl; areadrawprop << "PILBOP .3 0 0 false" << std::endl; areadrawprop << "PIPARE .3 0 0 false" << std::endl; areadrawprop << "PONTON .3 .2 .2 false" << std::endl; areadrawprop << "PRCARE .3 .2 .2 false" << std::endl; areadrawprop << "PRDARE .3 .2 .2 false" << std::endl; areadrawprop << "PYLONS .3 .2 .2 false" << std::endl; areadrawprop << "RADRNG .23 .23 .43 false" << std::endl; areadrawprop << "RAPIDS .23 .76 .54 false" << std::endl; areadrawprop << "RCTLPT .14 .16 .27 false" << std::endl; areadrawprop << "RECTRC .57 .68 .24 false" << std::endl; areadrawprop << "RESARE .57 .68 .24 false" << std::endl; areadrawprop << "RIVERS 0 0 1 false" << std::endl; areadrawprop << "ROADWY .32 .54 .77 false" << std::endl; areadrawprop << "RUNWAY .3 .4 .1 false" << std::endl; areadrawprop << "SBDARE .43 .12 .56 false" << std::endl; areadrawprop << "SEAARE .43 .12 .56 false" << std::endl; areadrawprop << "SILTNK .43 .12 .56 false" << std::endl; areadrawprop << "SLCONS .35 .67 .34 false" << std::endl; areadrawprop << "SLOGRD .3 .3 0 false" << std::endl; areadrawprop << "SMCFAC .3 .3 0 false" << std::endl; areadrawprop << "SNDWAV .34 .66 .44 false" << std::endl; areadrawprop << "SPLARE .12 .32 .43 false" << std::endl; areadrawprop << "SUBTLN .12 .32 .43 false" << std::endl; areadrawprop << "SWPARE .12 .32 .43 false" << std::endl; areadrawprop << "TESARE .21 .32 .43 false" << std::endl; areadrawprop << "TIDEWY .21 .32 .43 false" << std::endl; areadrawprop << "TSEZNE .12 .54 1 false" << std::endl; areadrawprop << "TSSCRS .12 .54 1 false" << std::endl; areadrawprop << "TSSLPT .12 .54 1 false" << std::endl; areadrawprop << "TSSRON .12 .54 1 false" << std::endl; areadrawprop << "TUNNEL 0 0 0 false" << std::endl; areadrawprop << "TWRTPT 0 0 0 false" << std::endl; areadrawprop << "UNSARE 0 0 0 false" << std::endl; areadrawprop << "VEGATN 0 .5 0 false" << std::endl; areadrawprop << "WATTUR .7 .6 .1 false" << std::endl; areadrawprop << "WEDKLP .7 .6 .1 false" << std::endl; areadrawprop << "WRECKS .7 .6 .1 false" << std::endl; areadrawprop << "M_ACCY .1 .5 .7 false" << std::endl; areadrawprop << "M_COVR .1 .5 .7 false" << std::endl; areadrawprop << "M_CSCL .1 .5 .7 false" << std::endl; areadrawprop << "M_HOPA .1 .5 .7 false" << std::endl; areadrawprop << "M_NPUB .1 .5 .7 false" << std::endl; areadrawprop << "M_NSYS .1 .5 .7 false" << std::endl; areadrawprop << "M_QUAL .1 .5 .7 false" << std::endl; areadrawprop << "M_SDAT .1 .5 .7 false" << std::endl; areadrawprop << "M_SREL .1 .5 .7 false" << std::endl; areadrawprop << "M_VDAT .1 .5 .7 false" << std::endl; areadrawprop << "T_HMON .1 .5 .7 false" << std::endl; areadrawprop << "T_NHMN .1 .5 .7 false" << std::endl; areadrawprop << "T_TIMS .1 .5 .7 false" << std::endl; areadrawprop << "TS_FEB .1 .5 .7 false" << std::endl; areadrawprop << "TS_PAD .1 .5 .7 false" << std::endl; areadrawprop << "TS_PNH .1 .5 .7 false" << std::endl; areadrawprop << "TS_PRH .1 .5 .7 false" << std::endl; areadrawprop << "TS_TIS .1 .5 .7 false" << std::endl; } areadrawprop.close(); // create the default linedrawprop file filename = dir / "linedrawprop"; boost::filesystem::ofstream linedrawprop(filename); if (!linedrawprop.is_open()) { std::cerr << "Configuration::GenerateConfiguration:: " << "Error generating linedrawprop file" << std::endl; boost::filesystem::remove_all(dir); return -1; } else { linedrawprop << "BERTHS .4 .2 .8 1 true" << std::endl; linedrawprop << "BRIDGE .1 .1 .1 1 true" << std::endl; linedrawprop << "CANALS .1 .1 1 1 true" << std::endl; linedrawprop << "CAUSWY .3 .2 .4 1 true" << std::endl; linedrawprop << "CBLOHD .4 .1 .2 1 true" << std::endl; linedrawprop << "CBLSUB .3 .2 .1 1 true" << std::endl; linedrawprop << "COALNE .1 .5 .1 1 true" << std::endl; linedrawprop << "CONVYR .3 .2 .8 1 true" << std::endl; linedrawprop << "DAMCON .9 .4 .8 1 true" << std::endl; linedrawprop << "DEPARE .5 .3 .9 1 true" << std::endl; linedrawprop << "DEPCNT .1 .1 .3 1 true" << std::endl; linedrawprop << "DYKCON .3 .2 .5 1 true" << std::endl; linedrawprop << "DWRTCL .8 .5 .4 1 true" << std::endl; linedrawprop << "FERYRT .4 .3 .6 1 true" << std::endl; linedrawprop << "FLODOC .8 .7 .8 1 true" << std::endl; linedrawprop << "FNCLNE .4 .4 .4 1 true" << std::endl; linedrawprop << "FORSTC .5 .3 .4 1 true" << std::endl; linedrawprop << "FSHFAC .1 .8 .5 1 true" << std::endl; linedrawprop << "GATCON .8 .4 .6 1 true" << std::endl; linedrawprop << "LNDARE 0 .1 0 1 true" << std::endl; linedrawprop << "LNDELV 0 .3 .2 1 true" << std::endl; linedrawprop << "LNDMRK .4 .3 .6 1 true" << std::endl; linedrawprop << "LOCMAG .3 .9 .5 1 true" << std::endl; linedrawprop << "MAGVAR .7 .5 .7 1 true" << std::endl; linedrawprop << "MARCUL .4 .3 .4 1 true" << std::endl; linedrawprop << "MORFAC .5 .7 .6 1 true" << std::endl; linedrawprop << "NAVLNE .8 .8 .8 1 true" << std::endl; linedrawprop << "OBSTRN .3 .3 .3 1 true" << std::endl; linedrawprop << "OILBAR .2 .4 .3 1 true" << std::endl; linedrawprop << "PIPOHD .3 0 0 1 true" << std::endl; linedrawprop << "PIPSOL .4 0 .5 1 true" << std::endl; linedrawprop << "PONTON .3 .2 .2 1 true" << std::endl; linedrawprop << "RADLNE .23 .23 .43 1 true" << std::endl; linedrawprop << "RAILWY .65 .65 54 1 true" << std::endl; linedrawprop << "RAPIDS .23 .76 .54 1 true" << std::endl; linedrawprop << "RCRTCL .14 .16 .27 1 true" << std::endl; linedrawprop << "RDOCAL .14 .16 .27 1 true" << std::endl; linedrawprop << "RECTRC .57 .68 .24 1 true" << std::endl; linedrawprop << "RIVERS 0 0 1 1 true" << std::endl; linedrawprop << "ROADWY .32 .54 .77 1 true" << std::endl; linedrawprop << "RUNWAY .3 .4 .1 1 true" << std::endl; linedrawprop << "SBDARE .43 .12 .56 1 true" << std::endl;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -