[Cmap-cvs] mp2mp .cvsignore,NONE,1.1 mpmerge.cpp,NONE,1.1 mpmerge.dsp,NONE,1.1 mpsplit.cpp,NONE,1.1
Status: Beta
Brought to you by:
dyp
From: Denis P. <dy...@us...> - 2005-04-24 20:00:26
|
Update of /cvsroot/cmap/mp2mp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10096 Modified Files: mp2mp.cpp mp2mp.dsp mp2mp.dsw mp_parser.cpp mp_parser.h object.cpp parserImpl.cpp Added Files: .cvsignore mpmerge.cpp mpmerge.dsp mpsplit.cpp mpsplit.dsp parserSplitImpl.cpp parserSplitImpl.h splitObject.cpp splitObject.h Log Message: Add mpsplit & mpmerge Correct kind= work. Make min_layer working. Index: mp2mp.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp2mp.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- mp2mp.cpp 23 Feb 2005 11:19:21 -0000 1.3 +++ mp2mp.cpp 24 Apr 2005 19:59:43 -0000 1.4 @@ -1,11 +1,9 @@ -// shp2mp.cpp : Defines the entry point for the console application. -// - #include <stdio.h> #include <math.h> #include <list> #include "tokenizer.h" #include "parserImpl.h" +#include "pexcept.h" #include "object.h" #include "mp_parser.h" @@ -78,7 +76,7 @@ for (std::list<Rgn>::iterator it = p.map.rgns.begin(); it != p.map.rgns.end(); it++) { Rgn &rgn = *it; if (handle(&rgn, op, 0)) - rgn.print(fo, op); + rgn.print(fo, op, true); } fclose(f); --- NEW FILE: mpmerge.dsp --- # Microsoft Developer Studio Project File - Name="mpmerge" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=mpmerge - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "mpmerge.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "mpmerge.mak" CFG="mpmerge - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "mpmerge - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "mpmerge - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "mpmerge - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /W3 /GX /O2 /I "eval" /I "." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x419 /d "NDEBUG" # ADD RSC /l 0x419 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "mpmerge - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "eval" /I "." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c # ADD BASE RSC /l 0x419 /d "_DEBUG" # ADD RSC /l 0x419 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "mpmerge - Win32 Release" # Name "mpmerge - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\eval\eval.cpp # End Source File # Begin Source File SOURCE=.\mp_parser.cpp # End Source File # Begin Source File SOURCE=.\mpmerge.cpp # End Source File # Begin Source File SOURCE=.\eval\pexcept.cpp # End Source File # Begin Source File SOURCE=.\eval\tokenizer.cpp # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\mp_parser.h # End Source File # Begin Source File SOURCE=.\eval\pexcept.h # End Source File # Begin Source File SOURCE=.\eval\tokenizer.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project --- NEW FILE: mpmerge.cpp --- #include <stdio.h> #include <math.h> #include <list> #include "tokenizer.h" #include "pexcept.h" #include "mp_parser.h" class Converter { public: Converter() { } void process(FILE *fo, const char *filename, bool copyHeader); }; void Converter::process(FILE *fo, const char *filename, bool copyHeader) { fprintf(stderr, "Processing: %s\n", filename); FILE *f = fopen(filename, "rt"); if (f == NULL) { fprintf(stderr, "File not found: %s\n", filename); exit(1); } Tokenizer t(f); MPParser p(t); try { while (p.parseObject()) ; } catch (ParserException &) { fprintf(stderr, "Error in file: '%s'\n", filename); t.printToken(); fclose(f); throw; } if (copyHeader) p.map.printHeader(fo); for (std::list<Rgn>::iterator it = p.map.rgns.begin(); it != p.map.rgns.end(); it++) { Rgn &rgn = *it; rgn.print(fo); } fclose(f); } static void printUsage(const char *name) { fprintf(stderr, "Usage: %s -o <outfile> <file1> ...\n", name); } int main(int argc, char* argv[]) { int firstArg = 1; const char *outFileName; if (argc >= 2 && strcmp(argv[firstArg], "-o") == 0) { if (argc < firstArg + 2) { printUsage(argv[0]); return 1; } outFileName = argv[firstArg + 1]; firstArg += 2; } else { printUsage(argv[0]); return 1; } if (argc < firstArg + 1) { printUsage(argv[0]); return 1; } Converter c; FILE *f = fopen(outFileName, "wt"); if (f == NULL) { fprintf(stderr, "Error opening file: %s\n", outFileName); return 1; } try { for (int i = firstArg; i < argc; i++) c.process(f, argv[i], i == firstArg); } catch (ParserException &x) { fprintf(stderr, "%d: %s\n", x.lineno(), x.what()); } fclose(f); return 0; } --- NEW FILE: .cvsignore --- *.plg *.opt *.ncb Debug Release Index: mp_parser.h =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp_parser.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- mp_parser.h 23 Feb 2005 11:19:22 -0000 1.3 +++ mp_parser.h 24 Apr 2005 19:59:43 -0000 1.4 @@ -4,14 +4,15 @@ #include <string> #include <list> #include "tokenizer.h" -#include "parser.h" +#include "pexcept.h" +#include "object.h" class point_t { public: double x; double y; - void print(FILE *f); + void print(FILE *f, bool is6Digits); }; class Element { @@ -20,7 +21,8 @@ int level; std::list<point_t> points; - void print(FILE *f); + void print(FILE *f, bool is6Digit); + void print(FILE *f, const ObjectProp &op, bool is6Digit); }; class Attr { @@ -33,22 +35,31 @@ class Rgn { public: +/* enum RgnType { POI, Polyline, Polygon }; +*/ Rgn(); - enum RgnType rgnType; + Kind kind; int type; int endLevel; std::string label; std::list<Attr> attrs; std::list<Element> elements; - void print(FILE *f, const ObjectProp &op); + void print(FILE *f, bool is6Digit); + void print(FILE *f, const ObjectProp &op, bool is6Digit); +}; + +class Level { +public: + int number; + int zoom; }; class Map { @@ -74,8 +85,15 @@ // void print(FILE *f); void printHeader(FILE *f); + bool is6Digit() { + for (size_t i = 0; i < levels.size(); i++) + if (levels[i].number > 24) + return true; + return false; + } std::list<Rgn> rgns; + std::vector<Level> levels; }; class MPParser { --- NEW FILE: splitObject.cpp --- #include "splitObject.h" SplitObj *firstSplitObj = NULL; void addSplitObj(SplitObj *obj) { obj->next = firstSplitObj; firstSplitObj = obj; } Index: parserImpl.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/parserImpl.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- parserImpl.cpp 23 Feb 2005 11:19:22 -0000 1.3 +++ parserImpl.cpp 24 Apr 2005 19:59:43 -0000 1.4 @@ -1,5 +1,6 @@ #include "parserImpl.h" #include "object.h" +#include "pexcept.h" #include "mp_parser.h" class AttrVar : public StringRVar { Index: object.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/object.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- object.cpp 14 Nov 2004 15:00:57 -0000 1.2 +++ object.cpp 24 Apr 2005 19:59:43 -0000 1.3 @@ -6,24 +6,17 @@ void ObjectConfImpl::init(const void *obj, ObjectProp &o) { const Rgn *rgn = (const Rgn *)obj; + memset(&o, 0, sizeof(o)); + o.index = false; o.city = 0; o.garminType = rgn->type; + o.layerMin = 0; o.layerMax = rgn->endLevel; o.label = rgn->label; - switch (rgn->rgnType) { - case Rgn::POI: - o.kind = kind::Point; - break; - case Rgn::Polyline: - o.kind = kind::Line; - break; - case Rgn::Polygon: - o.kind = kind::Polygon; - break; - } + o.kind = rgn->kind; } void add(ObjectConfImpl *obj) { --- NEW FILE: splitObject.h --- #ifndef __SPLITOBJECT_H__ #define __SPLITOBJECT_H__ #include <string> class SplitObj { public: SplitObj(const std::string &_code) : code(_code), next(NULL) { } std::string code; std::string file; SplitObj *next; }; extern SplitObj *firstSplitObj; void addSplitObj(SplitObj *obj); #endif --- NEW FILE: mpsplit.cpp --- #include <direct.h> #include <stdio.h> #include <math.h> #include <list> #include "tokenizer.h" #include "parserSplitImpl.h" #include "pexcept.h" #include "splitObject.h" #include "mp_parser.h" std::string headerFileName; std::string mapID; std::string mapName; class Converter { public: Converter() { } void process(FILE *f); void readConfig(const char *filename); }; class FileInfo { public: std::string filename; FILE *f; }; std::list<FileInfo> files; FILE *isCreated(std::string filename) { for (std::list<FileInfo>::iterator iFile = files.begin(); iFile != files.end(); iFile++) if (iFile->filename == filename) return iFile->f; return NULL; } void copyFile(const std::string &inFile, const std::string &outFile) { FILE *fi = fopen(inFile.c_str(), "rb"); if (fi == NULL) { fprintf(stderr, "Can not open file '%s'\n", inFile.c_str()); exit(1); } FILE *fo = fopen(outFile.c_str(), "wb"); if (fo == NULL) { fprintf(stderr, "Can not open file '%s'\n", outFile.c_str()); exit(1); } unsigned char buf[1024]; for (;;) { int n = fread(buf, 1, 1024, fi); if (n > 0) fwrite(buf, 1, n, fo); if (n < 1024) break; } fclose(fo); fclose(fi); } std::string outDir; void checkFile(const std::string &inFile, const std::string &outFile) { FILE *fi = fopen(inFile.c_str(), "rb"); if (fi == NULL) { fprintf(stderr, "Can not open file '%s'\n", inFile.c_str()); exit(1); } FILE *fo = fopen(outFile.c_str(), "rb"); if (fo == NULL) { fclose(fi); fprintf(stderr, "%s: new\n", outFile.c_str()); copyFile(inFile, outFile); return; } unsigned char bufIn[1024]; unsigned char bufOut[1024]; bool good = false; for (;;) { int ni = fread(bufIn, 1, 1024, fi); int no = fread(bufOut, 1, 1024, fo); if (ni != no) break; if (memcmp(bufIn, bufOut, ni) != 0) break; if (ni < 1024) { good = true; break; } } fclose(fo); fclose(fi); if (good) return; fprintf(stderr, "%s: changed\n", outFile.c_str()); copyFile(inFile, outFile); } void Converter::process(FILE *f) { Tokenizer t(f); MPParser p(t); while (p.parseObject()) ; mkdir("split_tmp"); for (std::list<Rgn>::iterator iRgn = p.map.rgns.begin(); iRgn != p.map.rgns.end(); iRgn++) { std::string code; for (std::list<Attr>::iterator iAttr = iRgn->attrs.begin(); iAttr != iRgn->attrs.end(); iAttr++) if (iAttr->name == "CODE") code = iAttr->value; if (code.empty()) continue; for (SplitObj *file = firstSplitObj; file != NULL; file = (SplitObj *)(file->next)) { if (file->code == code) { if (file->file.empty()) { fprintf(stderr, "No file section for code %s\n", code.c_str()); exit(1); } FILE *fo; if ((fo = isCreated(file->file)) == NULL) { fo = fopen(("split_tmp\\" + file->file).c_str(), "wt"); if (fo == NULL) { fprintf(stderr, "Can not open file '%s'\n", file->file.c_str()); exit(1); } FileInfo fi; fi.filename = file->file; fi.f = fo; files.push_back(fi); p.map.printHeader(fo); } iRgn->print(fo, p.map.is6Digit()); break; } } } std::list<FileInfo>::iterator iFile; for (iFile = files.begin(); iFile != files.end(); iFile++) fclose(iFile->f); for (iFile = files.begin(); iFile != files.end(); iFile++) checkFile("split_tmp\\" + iFile->filename, outDir + iFile->filename); for (iFile = files.begin(); iFile != files.end(); iFile++) unlink(("split_tmp\\" + iFile->filename).c_str()); rmdir("split_tmp"); } void Converter::readConfig(const char *filename) { FILE *f = fopen(filename, "rt"); if (f == NULL) { fprintf(stderr, "File not found: %s\n", filename); exit(1); } Tokenizer t(f); t.lowerCaseMode(true); t.quoteChar('"'); t.wordChars('a', 'z'); t.wordChars('A', 'Z'); t.wordChar('_'); t.parseNumbers(); t.whitespaceChar(' '); t.whitespaceChar('\n'); t.whitespaceChar('\r'); t.whitespaceChar('\t'); t.slashSlashComments(true); t.slashStarComments(true); ConfigParser p(t); try { while (p.parseObject()) ; } catch (ParserException &) { t.printToken(); fclose(f); throw; } fclose(f); } static void printUsage(const char *name) { fprintf(stderr, "Usage: %s <config> -o <outdir> <config> <input>\n", name); } static std::string convertMapID(const char *s) { std::string id = "111"; id += (s[0] - 'A') / 10 + '0'; id += (s[0] - 'A') % 10 + '0'; id += s[2]; id += s[3]; id += s[5]; return id; } int main(int argc, char* argv[]) { bool doSplit = false; int firstArg = 1; if (argc > firstArg + 1) { if (strcmp(argv[firstArg], "-o") == 0) { outDir = argv[firstArg + 1]; if (outDir[outDir.length() - 1] != '\\') outDir += '\\'; firstArg += 2; } } if (argc < firstArg + 2) { printUsage(argv[0]); return 1; } const char *configFile = argv[firstArg]; Converter c; try { c.readConfig(configFile); } catch (ParserException &x) { fprintf(stderr, "%s\n", x.what()); return 1; } const char *inFile = argv[firstArg + 1]; FILE *f = fopen(inFile, "rt"); if (f == NULL) { fprintf(stderr, "Error opening file: %s\n", inFile); return 1; } try { c.process(f); } catch (ParserException &x) { fprintf(stderr, "%s:%d: %s\n", inFile, x.lineno(), x.what()); } fclose(f); return 0; } --- NEW FILE: parserSplitImpl.h --- #ifndef __PARSERIMPL_H__ #define __PARSERIMPL_H__ #include <tokenizer.h> #include "splitObject.h" class ConfigParser { public: ConfigParser(Tokenizer &_t); void parseStringLVar(const std::string &varName, SplitObj *obj); void parseAssign(const std::string &varName, SplitObj *obj); void parseBlock(SplitObj *obj); bool parseObject(); protected: Tokenizer &t; }; #endif --- NEW FILE: mpsplit.dsp --- # Microsoft Developer Studio Project File - Name="mpsplit" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=mpsplit - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "mpsplit.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "mpsplit.mak" CFG="mpsplit - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "mpsplit - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "mpsplit - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "mpsplit - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /W3 /GX /O2 /I "eval" /I "." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x419 /d "NDEBUG" # ADD RSC /l 0x419 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "mpsplit - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "eval" /I "." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c # ADD BASE RSC /l 0x419 /d "_DEBUG" # ADD RSC /l 0x419 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "mpsplit - Win32 Release" # Name "mpsplit - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\mp_parser.cpp # End Source File # Begin Source File SOURCE=.\mpsplit.cpp # End Source File # Begin Source File SOURCE=.\parserSplitImpl.cpp # End Source File # Begin Source File SOURCE=.\eval\pexcept.cpp # End Source File # Begin Source File SOURCE=.\splitObject.cpp # End Source File # Begin Source File SOURCE=.\eval\tokenizer.cpp # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\mp_parser.h # End Source File # Begin Source File SOURCE=.\parserSplitImpl.h # End Source File # Begin Source File SOURCE=.\splitObject.h # End Source File # Begin Source File SOURCE=.\eval\tokenizer.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project Index: mp_parser.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp_parser.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- mp_parser.cpp 23 Feb 2005 11:36:53 -0000 1.4 +++ mp_parser.cpp 24 Apr 2005 19:59:43 -0000 1.5 @@ -1,29 +1,41 @@ #include "mp_parser.h" +#include "pexcept.h" Map::Map() { } void Map::printHeader(FILE *f) { - fprintf(f, "id = %s\n", id.c_str()); - fprintf(f, "name = %s\n", name.c_str()); - fprintf(f, "typeSet = %s\n", typeSet.c_str()); + fprintf(f, "[IMG ID]\n"); + fprintf(f, "ID=%s\n", id.c_str()); + fprintf(f, "Name=%s\n", name.c_str()); + fprintf(f, "TypeSet=%s\n", typeSet.c_str()); switch (elevation) { case Feets: - fprintf(f, "elevation = feets\n"); + fprintf(f, "Elevation=F\n"); break; case Meters: - fprintf(f, "elevation = meters\n"); + fprintf(f, "Elevation=M\n"); break; } - fprintf(f, "preprocess = %s\n", preprocess ? "true" : "false"); - fprintf(f, "codePage = %d\n", codePage); - fprintf(f, "LBLCoding = %d\n", lblCoding); - fprintf(f, "treSize = %d\n", treSize); - fprintf(f, "treMargin = %f\n", treMargin); - fprintf(f, "RGNLimit = %d\n", rgnLimit); - fprintf(f, "POIIndex = %s\n", POIIndex ? "true" : "false"); + fprintf(f, "Preprocess=%s\n", preprocess ? "T" : "F"); + fprintf(f, "CodePage=%d\n", codePage); + fprintf(f, "LblCoding=%d\n", lblCoding); + fprintf(f, "TreSize=%d\n", treSize); + if (is6Digit()) + fprintf(f, "TreMargin=%.6f\n", treMargin); + else + fprintf(f, "TreMargin=%.5f\n", treMargin); + fprintf(f, "RgnLimit=%d\n", rgnLimit); + fprintf(f, "POIIndex=%s\n", POIIndex ? "Y" : "N"); + fprintf(f, "Levels=%d\n", levels.size()); + size_t i; + for (i = 0; i < levels.size(); i++) + fprintf(f, "Level%d=%d\n", i, levels[i].number); + for (i = 0; i < levels.size(); i++) + fprintf(f, "Zoom%d=%d\n", i, levels[i].zoom); + fprintf(f, "[END-IMG ID]\n"); fprintf(f, "\n"); } @@ -39,21 +51,21 @@ fprintf(f, "; %s=%s\n", name.c_str(), value.c_str()); } -Rgn::Rgn() : rgnType(POI), type(0), endLevel(0) { +Rgn::Rgn() : kind(kind::Point), type(0), endLevel(0) { } -void Rgn::print(FILE *f, const ObjectProp &op) { +void Rgn::print(FILE *f, const ObjectProp &op, bool is6Digit) { for (std::list<Attr>::iterator it = attrs.begin(); it != attrs.end(); it++) (*it).print(f); - switch (rgnType) { - case POI: + switch (op.kind) { + case kind::Point: fprintf(f, "[POI]\n"); break; - case Polyline: + case kind::Line: fprintf(f, "[POLYLINE]\n"); break; - case Polygon: + case kind::Polygon: fprintf(f, "[POLYGON]\n"); break; }; @@ -65,8 +77,61 @@ if (op.label.length() > 0) fprintf(f, "Label=%s\n", op.label.c_str()); + if (kind != op.kind) { + if (kind == kind::Point || op.kind != kind::Point) + throw ParserException("Only polyline and Polygon to Point conversion is supported", 0); + for (std::list<Element>::iterator it2 = elements.begin(); it2 != elements.end(); it2++) { + point_t pt; + pt.x = 0.0; + pt.y = 0.0; + double count = 0.0; + + for (std::list<point_t>::iterator it3 = (*it2).points.begin(); it3 != (*it2).points.end(); it3++) { + pt.x += (*it3).x; + pt.y += (*it3).y; + count += 1.0; + } + + pt.x /= count; + pt.y /= count; + + fprintf(f, "Data%d=", op.layerMin); + pt.print(f, is6Digit); + fprintf(f, "\n"); + } + } else { + for (std::list<Element>::iterator it2 = elements.begin(); it2 != elements.end(); it2++) + (*it2).print(f, op, is6Digit); + } + fprintf(f, "[END]\n"); + fprintf(f, "\n"); +} + +void Rgn::print(FILE *f, bool is6Digit) { + for (std::list<Attr>::iterator it = attrs.begin(); it != attrs.end(); it++) + (*it).print(f); + + switch (kind) { + case kind::Point: + fprintf(f, "[POI]\n"); + break; + case kind::Line: + fprintf(f, "[POLYLINE]\n"); + break; + case kind::Polygon: + fprintf(f, "[POLYGON]\n"); + break; + }; + + fprintf(f, "Type=0x%x\n", type); + + if (endLevel != 0) + fprintf(f, "EndLevel=%d\n", endLevel); + if (label.length() > 0) + fprintf(f, "Label=%s\n", label.c_str()); + for (std::list<Element>::iterator it2 = elements.begin(); it2 != elements.end(); it2++) - (*it2).print(f); + (*it2).print(f, is6Digit); fprintf(f, "[END]\n"); fprintf(f, "\n"); } @@ -74,18 +139,31 @@ Element::Element(int _level) : level(_level) { } -void Element::print(FILE *f) { +void Element::print(FILE *f, bool is6Digit) { fprintf(f, "Data%d=", level); for (std::list<point_t>::iterator it = points.begin(); it != points.end(); it++) { if (it != points.begin()) fprintf(f, ","); - (*it).print(f); + (*it).print(f, is6Digit); } fprintf(f, "\n"); } -void point_t::print(FILE *f) { - fprintf(f, "(%.6f,%.6f)", y, x); +void Element::print(FILE *f, const ObjectProp &op, bool is6Digit) { + fprintf(f, "Data%d=", op.layerMin); + for (std::list<point_t>::iterator it = points.begin(); it != points.end(); it++) { + if (it != points.begin()) + fprintf(f, ","); + (*it).print(f, is6Digit); + } + fprintf(f, "\n"); +} + +void point_t::print(FILE *f, bool is6Digits) { + if (is6Digits) + fprintf(f, "(%.6f,%.6f)", y, x); + else + fprintf(f, "(%.5f,%.5f)", y, x); } MPParser::MPParser(Tokenizer &_t) : t(_t) { @@ -195,8 +273,18 @@ map.rgnLimit = parseInt(t.sval); else if (varName == "poiindex") map.POIIndex = parseBool(t.sval); - else if (varName.substr(0, 5) == "level") { + else if (varName == "levels") { + int levelsCount = parseInt(t.sval); + for (int i = 0; i < levelsCount; i++) + map.levels.push_back(Level()); + } else if (varName.substr(0, 5) == "level") { + int levelNum = parseInt(varName.substr(5, 2)); + int levelValue = parseInt(t.sval); + map.levels[levelNum].number = levelValue; } else if (varName.substr(0, 4) == "zoom") { + int levelNum = parseInt(varName.substr(4, 2)); + int levelZoom = parseInt(t.sval); + map.levels[levelNum].zoom = levelZoom; } else throw ParserException(("Unknown variable: " + varName).c_str(), t.lineno()); } @@ -277,18 +365,18 @@ throw ParserException("'[' expected", t.lineno()); if (t.nextToken() != TT_WORD || (t.sval != "polyline" && t.sval != "polygon" && t.sval != "poi")) throw ParserException("'polyline', 'polygon' or 'poi' expected", t.lineno()); - enum Rgn::RgnType rgnType; + Kind kind; if (t.sval == "polyline") - rgnType = Rgn::Polyline; + kind = kind::Line; else if (t.sval == "polygon") - rgnType = Rgn::Polygon; + kind = kind::Polygon; else if (t.sval == "poi") - rgnType = Rgn::POI; + kind = kind::Point; if (t.nextToken() != ']') throw ParserException("']' expected", t.lineno()); - rgn.rgnType = rgnType; + rgn.kind = kind; for (;;) { ttype = t.nextToken(); if (ttype == '[') { Index: mp2mp.dsp =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp2mp.dsp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- mp2mp.dsp 14 Nov 2004 15:00:57 -0000 1.2 +++ mp2mp.dsp 24 Apr 2005 19:59:43 -0000 1.3 @@ -111,6 +111,10 @@ # End Source File # Begin Source File +SOURCE=.\eval\pexcept.cpp +# End Source File +# Begin Source File + SOURCE=.\eval\tokenizer.cpp # End Source File # End Group @@ -143,6 +147,10 @@ # End Source File # Begin Source File +SOURCE=.\eval\pexcept.h +# End Source File +# Begin Source File + SOURCE=.\eval\tokenizer.h # End Source File # End Group --- NEW FILE: parserSplitImpl.cpp --- #include "parserSplitImpl.h" #include "splitObject.h" #include "pexcept.h" #include "mp_parser.h" ConfigParser::ConfigParser(Tokenizer &_t) : t(_t) { } void ConfigParser::parseStringLVar(const std::string &varName, SplitObj *obj) { if (varName != "file") return; if (t.nextToken() != '=') throw ParserException("Expected '='", t.lineno()); if (t.nextToken() != TT_STRING) throw ParserException("Expected file value", t.lineno()); obj->file = t.sval; } void ConfigParser::parseAssign(const std::string &varName, SplitObj *obj) { parseStringLVar(varName, obj); } void ConfigParser::parseBlock(SplitObj *obj) { if (t.nextToken() != '{') throw ParserException("Expected '{'", t.lineno()); std::string varName; for (;;) { if (t.nextToken() == '}') break; if (t.ttype != TT_WORD) throw ParserException("Expected variable name or '}'", t.lineno()); varName = t.sval; parseAssign(varName, obj); if (t.nextToken() != ';') throw ParserException("Expected ';'", t.lineno()); } } bool ConfigParser::parseObject() { switch (t.nextToken()) { case TT_EOF: return false; case TT_WORD: break; default: throw ParserException("Expected 'code'", t.lineno()); } if (t.sval != "code") throw ParserException("Expected 'code'", t.lineno()); if (t.nextToken() != TT_STRING) throw ParserException("Expected code value", t.lineno()); SplitObj *obj = new SplitObj(t.sval.c_str()); parseBlock(obj); addSplitObj(obj); return true; }; Index: mp2mp.dsw =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp2mp.dsw,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- mp2mp.dsw 7 Nov 2004 13:58:57 -0000 1.1.1.1 +++ mp2mp.dsw 24 Apr 2005 19:59:43 -0000 1.2 @@ -15,6 +15,30 @@ ############################################################################### +Project: "mpmerge"=.\mpmerge.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "mpsplit"=.\mpsplit.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + Global: Package=<5> |