[Cmap-cvs] mp2mp mp_parser.cpp,1.5,1.6 mp_parser.h,1.4,1.5 object.cpp,1.4,1.5
Status: Beta
Brought to you by:
dyp
From: Denis P. <dy...@us...> - 2005-06-12 08:22:20
|
Update of /cvsroot/cmap/mp2mp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12166 Modified Files: mp_parser.cpp mp_parser.h object.cpp Log Message: Support DirIndicator and City Index: object.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/object.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- object.cpp 25 Apr 2005 13:29:55 -0000 1.4 +++ object.cpp 12 Jun 2005 08:22:11 -0000 1.5 @@ -7,7 +7,8 @@ const Rgn *rgn = (const Rgn *)obj; o.index = false; - o.city = 0; + o.city = (rgn->city == True); + o.direction = (rgn->direction == True); o.garminType = rgn->type; o.layerMin = 0; Index: mp_parser.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp_parser.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- mp_parser.cpp 24 Apr 2005 19:59:43 -0000 1.5 +++ mp_parser.cpp 12 Jun 2005 08:22:11 -0000 1.6 @@ -1,7 +1,7 @@ #include "mp_parser.h" #include "pexcept.h" -Map::Map() { +Map::Map() : preprocess(Unknown), POIIndex(Unknown) { } void Map::printHeader(FILE *f) { @@ -18,7 +18,8 @@ break; } - fprintf(f, "Preprocess=%s\n", preprocess ? "T" : "F"); + if (preprocess != Unknown) + fprintf(f, "Preprocess=%s\n", preprocess == True ? "T" : "F"); fprintf(f, "CodePage=%d\n", codePage); fprintf(f, "LblCoding=%d\n", lblCoding); fprintf(f, "TreSize=%d\n", treSize); @@ -27,7 +28,8 @@ else fprintf(f, "TreMargin=%.5f\n", treMargin); fprintf(f, "RgnLimit=%d\n", rgnLimit); - fprintf(f, "POIIndex=%s\n", POIIndex ? "Y" : "N"); + if (POIIndex != Unknown) + fprintf(f, "POIIndex=%s\n", POIIndex == True ? "Y" : "N"); fprintf(f, "Levels=%d\n", levels.size()); size_t i; for (i = 0; i < levels.size(); i++) @@ -51,7 +53,7 @@ fprintf(f, "; %s=%s\n", name.c_str(), value.c_str()); } -Rgn::Rgn() : kind(kind::Point), type(0), endLevel(0) { +Rgn::Rgn() : kind(kind::Point), type(0), endLevel(0), direction(Unknown), city(Unknown) { } void Rgn::print(FILE *f, const ObjectProp &op, bool is6Digit) { @@ -76,6 +78,10 @@ fprintf(f, "EndLevel=%d\n", op.layerMax); if (op.label.length() > 0) fprintf(f, "Label=%s\n", op.label.c_str()); + if (op.direction) + fprintf(f, "DirIndicator=1\n"); + if (op.city) + fprintf(f, "City=Y\n"); if (kind != op.kind) { if (kind == kind::Point || op.kind != kind::Point) @@ -182,15 +188,27 @@ t.commentChar(';'); } -bool MPParser::parseBool(const std::string &sval) { +BoolType MPParser::parseBool() { + if (t.nextToken() == TT_NUMBER) + return (t.nval != 0) ? True : False; + if (t.ttype != TT_WORD) + throw ParserException("Boolean expected", t.lineno()); + return parseBool(t.sval); +} + +BoolType MPParser::parseBool(const std::string &sval) { if (sval == "T") - return true; + return True; if (sval == "F") - return false; + return False; if (sval == "Y") - return true; + return True; if (sval == "N") - return false; + return False; + if (sval == "y") + return True; + if (sval == "n") + return False; else throw ParserException("Unknown boolean value", t.lineno()); } @@ -397,9 +415,13 @@ rgn.label = t.sval; } else if (varName == "endlevel") rgn.endLevel = parseInt(); - else if (varName == "type") { + else if (varName == "type") rgn.type = parseInt(); - } else if (varName.substr(0, 4) == "data") { + else if (varName == "dirindicator") + rgn.direction = parseBool(); + else if (varName == "city") + rgn.city = parseBool(); + else if (varName.substr(0, 4) == "data") { Element e(parseInt(varName.substr(4))); parseElement(e); rgn.elements.push_back(e); Index: mp_parser.h =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp_parser.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- mp_parser.h 24 Apr 2005 19:59:43 -0000 1.4 +++ mp_parser.h 12 Jun 2005 08:22:11 -0000 1.5 @@ -33,6 +33,12 @@ void print(FILE *f); }; +enum BoolType { + Unknown, + False, + True +}; + class Rgn { public: /* @@ -51,6 +57,8 @@ std::string label; std::list<Attr> attrs; std::list<Element> elements; + BoolType direction; + BoolType city; void print(FILE *f, bool is6Digit); void print(FILE *f, const ObjectProp &op, bool is6Digit); @@ -75,13 +83,13 @@ std::string name; std::string typeSet; enum ElevationType elevation; - bool preprocess; + BoolType preprocess; int codePage; int lblCoding; int treSize; float treMargin; int rgnLimit; - bool POIIndex; + BoolType POIIndex; // void print(FILE *f); void printHeader(FILE *f); @@ -106,7 +114,8 @@ Map map; private: - bool parseBool(const std::string &sval); + BoolType parseBool(); + BoolType parseBool(const std::string &sval); int parseInt(); int parseInt(const std::string &sval); float parseFloat(const std::string &sval); |