cmap-cvs Mailing List for cmap (Page 7)
Status: Beta
Brought to you by:
dyp
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(87) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(6) |
Nov
(5) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
|
Feb
(7) |
Mar
|
Apr
(5) |
May
|
Jun
(6) |
Jul
|
Aug
(13) |
Sep
(5) |
Oct
(5) |
Nov
|
Dec
(5) |
2006 |
Jan
|
Feb
(3) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(3) |
Oct
(11) |
Nov
(4) |
Dec
(24) |
2007 |
Jan
(17) |
Feb
(9) |
Mar
(13) |
Apr
(3) |
May
(1) |
Jun
(7) |
Jul
(8) |
Aug
(17) |
Sep
(4) |
Oct
(2) |
Nov
(8) |
Dec
(7) |
2008 |
Jan
(2) |
Feb
(4) |
Mar
(32) |
Apr
(23) |
May
(19) |
Jun
(14) |
Jul
(15) |
Aug
(6) |
Sep
(5) |
Oct
(5) |
Nov
(2) |
Dec
|
From: Denis P. <dy...@us...> - 2006-02-26 05:45:19
|
Update of /cvsroot/cmap/mp2mp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13309 Modified Files: parserImpl.cpp Log Message: Cast to int Index: parserImpl.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/parserImpl.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- parserImpl.cpp 18 Dec 2005 19:46:09 -0000 1.8 +++ parserImpl.cpp 26 Feb 2006 05:45:12 -0000 1.9 @@ -10,7 +10,7 @@ virtual int getValue(const void *obj, const ObjectProp &op, int numArray) { const mp::Rgn *rgn = (const mp::Rgn *)obj; - return rgn->getArea() / 1e6; + return (int)(rgn->getArea() / 1e6); }; }; @@ -21,7 +21,7 @@ virtual int getValue(const void *obj, const ObjectProp &op, int numArray) { const mp::Rgn *rgn = (const mp::Rgn *)obj; - return rgn->getLength(); + return (int)rgn->getLength(); }; }; @@ -32,7 +32,7 @@ virtual int getValue(const void *obj, const ObjectProp &op, int numArray) { const mp::Rgn *rgn = (const mp::Rgn *)obj; - return rgn->getWidth(); + return (int)rgn->getWidth(); }; }; @@ -43,7 +43,7 @@ virtual int getValue(const void *obj, const ObjectProp &op, int numArray) { const mp::Rgn *rgn = (const mp::Rgn *)obj; - return rgn->getHeight(); + return (int)rgn->getHeight(); }; }; |
From: Denis P. <dy...@us...> - 2006-02-02 16:05:46
|
Update of /cvsroot/cmap/mp2mp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5847 Modified Files: mp_parser.h mp_parser.cpp Log Message: Line closure made for polygon converted to polylines. Index: mp_parser.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp_parser.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- mp_parser.cpp 18 Dec 2005 19:46:09 -0000 1.14 +++ mp_parser.cpp 2 Feb 2006 16:05:37 -0000 1.15 @@ -257,7 +257,10 @@ const size_t cElements = elements.size(); for (size_t cElement = 0; cElement < cElements; ++ cElement) { Element &element = elements[cElement]; - element.status = isHoleOfAny(element) ? Element::INNER : Element::OUTER; + if (kind == kind::Polygon) + element.status = isHoleOfAny(element) ? Element::INNER : Element::OUTER; + else + element.status = Element::UNSPECIFIED; } } @@ -305,7 +308,7 @@ attrs.push_back(attr); } -Element::Element(int _level) : level(_level) { +Element::Element(int _level) : level(_level), status(UNSPECIFIED) { } /////////////////////////////////////////////////////////////// @@ -442,11 +445,13 @@ fprintf(f, ","); (*it).print(f, is6Digit); } - if (op.kind == kind::Line) + + if (status != UNSPECIFIED && op.kind == kind::Line) if (points[0].x != points[points.size() - 1].x || points[0].y != points[points.size() - 1].y) { fprintf(f, ","); points[0].print(f, is6Digit); } + fprintf(f, "\n"); } Index: mp_parser.h =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp_parser.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- mp_parser.h 18 Dec 2005 19:46:09 -0000 1.12 +++ mp_parser.h 2 Feb 2006 16:05:37 -0000 1.13 @@ -24,6 +24,7 @@ Element(int _level); enum StatusType { + UNSPECIFIED, INNER, OUTER } status; |
From: Denis P. <dy...@us...> - 2005-12-18 19:49:29
|
Update of /cvsroot/cmap/libs/eval In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30604 Modified Files: eval.h Log Message: Make it compile Index: eval.h =================================================================== RCS file: /cvsroot/cmap/libs/eval/eval.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- eval.h 18 Dec 2005 19:48:36 -0000 1.7 +++ eval.h 18 Dec 2005 19:49:21 -0000 1.8 @@ -53,8 +53,6 @@ std::string zip; std::string www; - std::string phone; - Kind kind; //HACK until everything is cleaned out |
From: Denis P. <dy...@us...> - 2005-12-18 19:48:44
|
Update of /cvsroot/cmap/libs/eval In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30488 Modified Files: parser.cpp evalImpl.h eval.h Log Message: Äîáàâèë zip, www, roadClass, speedLimit Index: parser.cpp =================================================================== RCS file: /cvsroot/cmap/libs/eval/parser.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- parser.cpp 21 Aug 2005 07:15:18 -0000 1.8 +++ parser.cpp 18 Dec 2005 19:48:35 -0000 1.9 @@ -39,6 +39,10 @@ return new LayerMinVar(); if (varName == "layer_max") return new LayerMaxVar(); + if (varName == "road_class") + return new RoadClassVar(); + if (varName == "speed_limit") + return new SpeedLimitVar(); if (varName == "intattr") { if (t.nextToken() != TT_STRING) throw ParserException("Attr name expected", t.lineno()); @@ -64,6 +68,12 @@ return new StreetNameLVar(); if (varName == "house") return new HouseLVar(); + if (varName == "phone") + return new PhoneLVar(); + if (varName == "zip") + return new ZipLVar(); + if (varName == "www") + return new WWWLVar(); if (varName == "attr") { if (t.nextToken() != TT_STRING) throw ParserException("Attr name expected", t.lineno()); Index: evalImpl.h =================================================================== RCS file: /cvsroot/cmap/libs/eval/evalImpl.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- evalImpl.h 22 Aug 2005 08:49:50 -0000 1.8 +++ evalImpl.h 18 Dec 2005 19:48:36 -0000 1.9 @@ -88,6 +88,36 @@ } }; +class PhoneLVar : public StringLVar { + virtual std::string getValue(const void *, const ObjectProp &op) { + return op.phone; + } + + virtual void setValue(ObjectProp &op, const std::string &value) { + op.phone = value; + } +}; + +class ZipLVar : public StringLVar { + virtual std::string getValue(const void *, const ObjectProp &op) { + return op.zip; + } + + virtual void setValue(ObjectProp &op, const std::string &value) { + op.zip = value; + } +}; + +class WWWLVar : public StringLVar { + virtual std::string getValue(const void *, const ObjectProp &op) { + return op.www; + } + + virtual void setValue(ObjectProp &op, const std::string &value) { + op.www = value; + } +}; + class StringAttrVar : public StringLVar { public: StringAttrVar(const std::string &_attrName) : attrName(_attrName) { @@ -176,6 +206,26 @@ } }; +class RoadClassVar : public IntLVar { + virtual int getValue(const void *, const ObjectProp &op, int) { + return op.roadClass; + } + + virtual void setValue(ObjectProp &op, int value) { + op.roadClass = value; + } +}; + +class SpeedLimitVar : public IntLVar { + virtual int getValue(const void *, const ObjectProp &op, int) { + return op.speedLimit; + } + + virtual void setValue(ObjectProp &op, int value) { + op.speedLimit = value; + } +}; + class PointVar : public IntLVar { virtual int getValue(const void *, const ObjectProp &op, int) { return op.typePoint; Index: eval.h =================================================================== RCS file: /cvsroot/cmap/libs/eval/eval.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- eval.h 18 Dec 2005 19:42:48 -0000 1.6 +++ eval.h 18 Dec 2005 19:48:36 -0000 1.7 @@ -49,6 +49,9 @@ std::string cityName; std::string streetName; std::string house; + std::string phone; + std::string zip; + std::string www; std::string phone; @@ -59,6 +62,9 @@ int typeLine; int typePoly; + int roadClass; + int speedLimit; + Attrs attrs; void print(FILE *f) const { |
From: Denis P. <dy...@us...> - 2005-12-18 19:46:20
|
Update of /cvsroot/cmap/mp2mp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30014 Modified Files: parserImpl.cpp mp_parser.h mp_parser.cpp Log Message: Äîáàâèë òåëåôîí Ïðàâèëüíî ðàçáèðàåòñÿ íîìåð äîìà Ïëîùàäü è äëèíà ñ÷èòàåòñÿ â ìåòðàõ Èñïðàâëåíà îøèáêà ñ ïðîïóñêîì çàïÿòîé ïåðåä ïîñëåäíåé ïàðîé êîîðäèíàò. Index: parserImpl.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/parserImpl.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- parserImpl.cpp 24 Sep 2005 16:01:11 -0000 1.7 +++ parserImpl.cpp 18 Dec 2005 19:46:09 -0000 1.8 @@ -10,7 +10,7 @@ virtual int getValue(const void *obj, const ObjectProp &op, int numArray) { const mp::Rgn *rgn = (const mp::Rgn *)obj; - return rgn->getArea() * 1e6; + return rgn->getArea() / 1e6; }; }; @@ -21,7 +21,7 @@ virtual int getValue(const void *obj, const ObjectProp &op, int numArray) { const mp::Rgn *rgn = (const mp::Rgn *)obj; - return rgn->getLength() * 1e3; + return rgn->getLength(); }; }; @@ -32,7 +32,7 @@ virtual int getValue(const void *obj, const ObjectProp &op, int numArray) { const mp::Rgn *rgn = (const mp::Rgn *)obj; - return rgn->getWidth() * 1e3; + return rgn->getWidth(); }; }; @@ -43,7 +43,7 @@ virtual int getValue(const void *obj, const ObjectProp &op, int numArray) { const mp::Rgn *rgn = (const mp::Rgn *)obj; - return rgn->getHeight() * 1e3; + return rgn->getHeight(); }; }; Index: mp_parser.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp_parser.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- mp_parser.cpp 23 Oct 2005 16:15:33 -0000 1.13 +++ mp_parser.cpp 18 Dec 2005 19:46:09 -0000 1.14 @@ -4,6 +4,8 @@ #include "mp_parser.h" #include "pexcept.h" +const float c_PI = 3.14159265358979f; + namespace mp { Map::Map() : preprocess(Unknown), POIIndex(Unknown) { @@ -71,15 +73,15 @@ fprintf(f, "[POI]\n"); break; case kind::Line: - fprintf(f, "; LENGTH=%d\n", (int)(getLength() * 1.e3)); - fprintf(f, "; WIDTH=%d\n", (int)(getWidth() * 1.e3)); - fprintf(f, "; HEIGHT=%d\n", (int)(getHeight() * 1.e3)); + fprintf(f, "; RLENGTH=%d\n", (int)getLength()); + fprintf(f, "; RWIDTH=%d\n", (int)(getWidth())); + fprintf(f, "; RHEIGHT=%d\n", (int)(getHeight())); fprintf(f, "[POLYLINE]\n"); break; case kind::Polygon: - fprintf(f, "; AREA=%d\n", (int)(getArea() * 1.e6)); - fprintf(f, "; WIDTH=%d\n", (int)(getWidth() * 1.e3)); - fprintf(f, "; HEIGHT=%d\n", (int)(getHeight() * 1.e3)); + fprintf(f, "; RAREA=%d\n", (int)(getArea() / 1.e6)); + fprintf(f, "; RWIDTH=%d\n", (int)(getWidth())); + fprintf(f, "; RHEIGHT=%d\n", (int)(getHeight())); fprintf(f, "[POLYGON]\n"); break; }; @@ -100,6 +102,8 @@ fprintf(f, "StreetDesc=%s\n", op.streetName.c_str()); if (op.house.length() > 0) fprintf(f, "HouseNumber=%s\n", op.house.c_str()); + if (op.phone.length() > 0) + fprintf(f, "Phone=%s\n", op.phone.c_str()); if (op.direction) fprintf(f, "DirIndicator=1\n"); if (op.city) @@ -160,6 +164,22 @@ fprintf(f, "EndLevel=%d\n", endLevel); if (label.length() > 0) fprintf(f, "Label=%s\n", label.c_str()); + if (countryName.length() > 0) + fprintf(f, "CountryName=%s\n", countryName.c_str()); + if (regionName.length() > 0) + fprintf(f, "RegionName=%s\n", regionName.c_str()); + if (cityName.length() > 0) + fprintf(f, "CityName=%s\n", cityName.c_str()); + if (streetName.length() > 0) + fprintf(f, "StreetDesc=%s\n", streetName.c_str()); + if (house.length() > 0) + fprintf(f, "HouseNumber=%s\n", house.c_str()); + if (phone.length() > 0) + fprintf(f, "Phone=%s\n", phone.c_str()); + if (direction) + fprintf(f, "DirIndicator=1\n"); + if (city) + fprintf(f, "City=Y\n"); for (Elements::const_iterator it2 = elements.begin(); it2 != elements.end(); it2++) (*it2).print(f, is6Digit); @@ -187,7 +207,7 @@ const Element &element = elements[cElement]; fLength += element.getLength(); } - return fLength; + return fLength*40e6/360; } inline double max(const double x1, const double x2) { @@ -207,7 +227,7 @@ const Element &element = elements[cElement]; fMaxHeight = max(fMaxHeight, element.getHeight()); } - return fMaxHeight; + return fMaxHeight*40e6/360; } double Rgn::getWidth() const { @@ -219,7 +239,7 @@ const Element &element = elements[cElement]; fMaxWidth = max(fMaxWidth, element.getWidth()); } - return fMaxWidth; + return fMaxWidth*40e6/360; } bool Rgn::isHoleOfAny(const Element &_element) { @@ -423,8 +443,10 @@ (*it).print(f, is6Digit); } if (op.kind == kind::Line) - if (points[0].x != points[points.size() - 1].x || points[0].y != points[points.size() - 1].y) + if (points[0].x != points[points.size() - 1].x || points[0].y != points[points.size() - 1].y) { + fprintf(f, ","); points[0].print(f, is6Digit); + } fprintf(f, "\n"); } @@ -433,19 +455,28 @@ if (cPoints <= 2) return 0; - double fArea = 0; - for (size_t cPoint = 0; cPoint < cPoints; ++ cPoint) { + double fMeanY = 0.0; + size_t cPoint; + for (cPoint = 0; cPoint < cPoints; ++ cPoint) { + const point_t & p0 = points [cPoint]; + + fMeanY += p0.y; + } + fMeanY /= cPoints; + + const double fCosY = ::cos (fMeanY*c_PI/180); + + double fArea = 0.0; + for (cPoint = 0; cPoint < cPoints; ++ cPoint) { const point_t & p0 = points [cPoint]; const point_t & p1 = points [cPoint + 1 == cPoints ? 0 : cPoint + 1]; fArea += (p1.x - p0.x)*(p0.y + p1.y); } - return ::fabs (fArea)*.5; + return ::fabs (fArea)*0.5*(40000000.0/360.0)*(40000000.0/360.0)*fCosY; } -const float c_PI = 3.14159265358979f; - double Element::getLength () const { const size_t cPoints = points.size (); if (cPoints <= 1) @@ -765,9 +796,12 @@ } else if (varName == "streetdesc") { t.nextToEOL(true); rgn.streetName = t.sval; - } else if (varName == "housename") { + } else if (varName == "housenumber") { t.nextToEOL(true); - rgn.houseName = t.sval; + rgn.house = t.sval; + } else if (varName == "phone") { + t.nextToEOL(true); + rgn.phone = t.sval; } else if (varName == "endlevel") rgn.endLevel = parseInt(); else if (varName == "type") Index: mp_parser.h =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp_parser.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- mp_parser.h 21 Oct 2005 08:09:30 -0000 1.11 +++ mp_parser.h 18 Dec 2005 19:46:09 -0000 1.12 @@ -82,7 +82,9 @@ std::string regionName; std::string cityName; std::string streetName; - std::string houseName; + std::string house; + + std::string phone; std::string filename; unsigned int line; |
From: Denis P. <dy...@us...> - 2005-12-18 19:44:11
|
Update of /cvsroot/cmap/mp2mp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29707 Modified Files: object.cpp Log Message: Äîáàâèë òåëåôîí Index: object.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/object.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- object.cpp 28 Aug 2005 22:23:58 -0000 1.6 +++ object.cpp 18 Dec 2005 19:44:01 -0000 1.7 @@ -20,7 +20,8 @@ o.regionName = rgn->regionName; o.cityName = rgn->cityName; o.streetName = rgn->streetName; - o.house = rgn->houseName; + o.house = rgn->house; + o.phone = rgn->phone; for (mp::Attrs::const_iterator iAttr = rgn->attrs.begin (); iAttr != rgn->attrs.end (); ++iAttr) { const mp::Attr &attr = *iAttr; |
From: Denis P. <dy...@us...> - 2005-12-18 19:42:56
|
Update of /cvsroot/cmap/libs/eval In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29478 Modified Files: eval.h Log Message: Äîáàâèë òåëåôîí Index: eval.h =================================================================== RCS file: /cvsroot/cmap/libs/eval/eval.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- eval.h 21 Aug 2005 07:15:18 -0000 1.5 +++ eval.h 18 Dec 2005 19:42:48 -0000 1.6 @@ -50,6 +50,8 @@ std::string streetName; std::string house; + std::string phone; + Kind kind; //HACK until everything is cleaned out |
From: Denis P. <dy...@us...> - 2005-10-23 16:16:15
|
Update of /cvsroot/cmap/mp2mp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22046 Modified Files: cityupdate.dsp Log Message: Update project Index: cityupdate.dsp =================================================================== RCS file: /cvsroot/cmap/mp2mp/cityupdate.dsp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- cityupdate.dsp 21 Oct 2005 08:15:19 -0000 1.1 +++ cityupdate.dsp 23 Oct 2005 16:16:07 -0000 1.2 @@ -64,7 +64,7 @@ # PROP Intermediate_Dir "cityupdate___Win32_Debug" # 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" /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 |
From: Denis P. <dy...@us...> - 2005-10-23 16:15:42
|
Update of /cvsroot/cmap/mp2mp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21806 Modified Files: mp_parser.cpp Log Message: Generate only one point for multiple elements Index: mp_parser.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp_parser.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- mp_parser.cpp 21 Oct 2005 08:09:30 -0000 1.12 +++ mp_parser.cpp 23 Oct 2005 16:15:33 -0000 1.13 @@ -108,25 +108,25 @@ if (kind != op.kind && op.kind == kind::Point) { unsigned int layerMax = op.layerMax > 0 ? op.layerMax : op.layerMin; for (unsigned int i = op.layerMin; i <= layerMax; i++) { - for (Elements::const_iterator it2 = elements.begin(); it2 != elements.end(); it2++) { - point_t pt; - pt.x = 0.0; - pt.y = 0.0; - double count = 0.0; + point_t pt; + pt.x = 0.0; + pt.y = 0.0; + double count = 0.0; + for (Elements::const_iterator it2 = elements.begin(); it2 != elements.end(); it2++) { for (points_t::const_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; + pt.x /= count; + pt.y /= count; - fprintf(f, "Data%d=", i); - pt.print(f, is6Digit); - fprintf(f, "\n"); - } + fprintf(f, "Data%d=", i); + pt.print(f, is6Digit); + fprintf(f, "\n"); } } else { unsigned int layerMax = op.layerMax > 0 ? op.layerMax : op.layerMin; |
From: Denis P. <dy...@us...> - 2005-10-21 08:15:27
|
Update of /cvsroot/cmap/mp2mp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31664 Modified Files: Makefile Added Files: cityupdate.dsp cityupdate.cpp Log Message: Add cityupdate --- NEW FILE: cityupdate.dsp --- # Microsoft Developer Studio Project File - Name="cityupdate" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=cityupdate - 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 "cityupdate.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 "cityupdate.mak" CFG="cityupdate - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "cityupdate - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "cityupdate - 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)" == "cityupdate - 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 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)" == "cityupdate - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "cityupdate___Win32_Debug" # PROP BASE Intermediate_Dir "cityupdate___Win32_Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "cityupdate___Win32_Debug" # PROP Intermediate_Dir "cityupdate___Win32_Debug" # 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" /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 "cityupdate - Win32 Release" # Name "cityupdate - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\cityupdate.cpp # End Source File # Begin Source File SOURCE=.\eval\eval.cpp # End Source File # Begin Source File SOURCE=.\mp_parser.cpp # End Source File # Begin Source File SOURCE=.\object.cpp # End Source File # Begin Source File SOURCE=.\eval\parser.cpp # End Source File # Begin Source File SOURCE=.\parserImpl.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" # 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: Makefile =================================================================== RCS file: /cvsroot/cmap/mp2mp/Makefile,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Makefile 24 Apr 2005 20:05:12 -0000 1.1 +++ Makefile 21 Oct 2005 08:15:19 -0000 1.2 @@ -1,10 +1,13 @@ SOURCES = eval/eval.cpp eval/parser.cpp eval/tokenizer.cpp eval/pexcept.cpp \ - mp2mp.cpp mp_parser.cpp object.cpp parserImpl.cpp + mp_parser.cpp object.cpp parserImpl.cpp HEADERS = eval/eval.h eval/evalImpl.h eval/parser.h eval/tokenizer.h eval/pexcept.h \ mp_parser.h object.h parserImpl.h -all: mp2mp +all: mp2mp cityupdate -mp2mp: $(SOURCES) $(HEADERS) - $(CXX) -g3 -o mp2mp -I. -Ieval $(SOURCES) -lm +mp2mp: mp2mp.cpp $(SOURCES) $(HEADERS) + $(CXX) -g3 -o mp2mp -I. -Ieval mp2mp.cpp $(SOURCES) -lm + +cityupdate: cityupdate.cpp $(SOURCES) $(HEADERS) + $(CXX) -g3 -o cityupdate -I. -Ieval cityupdate.cpp $(SOURCES) -lm --- NEW FILE: cityupdate.cpp --- # pragma warning (disable : 4786) #include <stdio.h> #include <math.h> #include <list> #include <map> #include "tokenizer.h" #include "pexcept.h" #include "mp_parser.h" std::string headerFileName; std::string mapID; std::string mapName; unsigned char lower(unsigned char c) { if (c >= 192 && c < 224) c += 32; return c; c = 'à'; switch (c) { case 'À': return 'à'; case 'Á': return 'á'; case 'Â': return 'â'; case 'Ã': return 'ã'; case 'Ä': return 'ä'; case 'Å': return 'å'; case '¨': return '¸'; case 'Æ': return 'æ'; case 'Ç': return 'ç'; case 'È': return 'è'; case 'É': return 'é'; case 'Ê': return 'ê'; case 'Ë': return 'ë'; case 'Ì': return 'ì'; case 'Í': return 'í'; case 'Î': return 'î'; case 'Ï': return 'ï'; case 'Ð': return 'ð'; case 'Ñ': return 'ñ'; case 'Ò': return 'ò'; case 'Ó': return 'ó'; case 'Ô': return 'ô'; case 'Õ': return 'õ'; case 'Ö': return 'ö'; case '×': return '÷'; case 'Ø': return 'ø'; case 'Ù': return 'ù'; case 'Ý': return 'ý'; case 'Þ': return 'þ'; case 'ß': return 'ÿ'; } return c; } class City { public: City() : adm(0), population(0), next(NULL) { } std::string countryName; std::string regionName; std::string name; int adm; // X43 int population; // X38 mp::point_t center; City *next; }; class Converter { public: Converter() { } void process(const char *filename); void processSettle(const char *filename); void readCities(const char *filename); void readAdm(const char *filename); void readPop(const char *filename); void updatePopulation(const std::string &name, int popul); void addCity(mp::Rgn &rgn); City *findCity(const std::string &name, const mp::point_t &pt); void updateAdm(mp::Rgn &rgn); std::map<std::string,City *> cities; mp::Map adm; }; const double c_A = 6378137; const double c_a = 1/298.257223563; const double c_e2 = 2*c_a - c_a*c_a; const float c_PI = 3.14159265358979f; double Distance (const mp::point_t & _1, const mp::point_t & _2) { const double fSinB1 = ::sin (_1.y*c_PI/180); const double fCosB1 = ::cos (_1.y*c_PI/180); const double fSinL1 = ::sin (_1.x*c_PI/180); const double fCosL1 = ::cos (_1.x*c_PI/180); const double N1 = c_A/::sqrt (1 - c_e2*fSinB1*fSinB1); const double X1 = N1*fCosB1*fCosL1; const double Y1 = N1*fCosB1*fSinL1; const double Z1 = (1 - c_e2)*N1*fSinB1; const double fSinB2 = ::sin (_2.y*c_PI/180); const double fCosB2 = ::cos (_2.y*c_PI/180); const double fSinL2 = ::sin (_2.x*c_PI/180); const double fCosL2 = ::cos (_2.x*c_PI/180); const double N2 = c_A/::sqrt (1 - c_e2*fSinB2*fSinB2); const double X2 = N2*fCosB2*fCosL2; const double Y2 = N2*fCosB2*fSinL2; const double Z2 = (1 - c_e2)*N2*fSinB2; const double D = ::sqrt ((X1 - X2)*(X1 - X2) + (Y1 - Y2)*(Y1 - Y2) + (Z1 - Z2)*(Z1 - Z2)); const double R = N1; const double D2 = 2*R*::asin (.5f*D/R); return D2; } City *Converter::findCity(const std::string &name, const mp::point_t &pt) { std::string lname; for (size_t i=0; i < name.length(); i++) lname += lower(name[i]); City *city = cities[lname]; if (city == NULL) return NULL; for (City *c = city; ; c = c->next) { double dist = Distance(pt, c->center); if (dist < 10000.0) return c; printf("Found a city %s, but dist is: %f\n", name.c_str(), dist); if (c->next == NULL) break; } return NULL; } inline double min(const double x1, const double x2) { return x1 < x2 ? x1 : x2; } inline double max(const double x1, const double x2) { return x1 > x2 ? x1 : x2; } void Converter::addCity(mp::Rgn &rgn) { std::string lname; for (size_t i=0; i < rgn.label.length(); i++) lname += lower(rgn.label[i]); City *city = cities[lname]; // Add a new city if (city == NULL) { city = new City; city->name = lname; city->adm = rgn.getIntAttr("X43"); city->population = rgn.getIntAttr("X38"); city->center.x = 0.0; city->center.y = 0.0; int count = 0; for (mp::Elements::const_iterator it2 = rgn.elements.begin(); it2 != rgn.elements.end(); it2++) { for (mp::points_t::const_iterator it3 = (*it2).points.begin(); it3 != (*it2).points.end(); it3++) { city->center.x += (*it3).x; city->center.y += (*it3).y; count += 1; } } city->center.x /= (double)count; city->center.y /= (double)count; cities[city->name] = city; return; } if (city->adm != rgn.getIntAttr("X43")) { if (city->adm == 0) { city->adm = rgn.getIntAttr("X43"); } else { if (rgn.getIntAttr("X43") != 0) printf("Found duplicate city for %s with different adm: %d - %d\n", city->name.c_str(), city->adm, rgn.getIntAttr("X43")); } } if (city->population != rgn.getIntAttr("X38")) { if (city->population == 0) { city->population = rgn.getIntAttr("X38"); } else { if (rgn.getIntAttr("X38") != 0) printf("Found duplicate city for %s with different population: %d - %d\n", city->name.c_str(), city->population, rgn.getIntAttr("X38")); } } mp::point_t pt; pt.x = 0.0; pt.y = 0.0; int count = 0; for (mp::Elements::const_iterator it2 = rgn.elements.begin(); it2 != rgn.elements.end(); it2++) { for (mp::points_t::const_iterator it3 = (*it2).points.begin(); it3 != (*it2).points.end(); it3++) { pt.x += (*it3).x; pt.y += (*it3).y; count += 1; } } pt.x /= (double)count; pt.y /= (double)count; double minDist = 0.0; for (City *c = city; ; c = c->next) { double dist = Distance(pt, c->center); if (dist < 10000.0) { printf("City %s has close duplicate\n", city->name.c_str()); return; } if (c == city) minDist = dist; else minDist = min(minDist, dist); if (c->next == NULL) break; } printf("City %s duplicate: %f\n", city->name.c_str(), minDist); if (minDist > 10000.0) { // fprintf(stderr, "City %s duplicate is too far from original\n", city->name.c_str()); City *city2 = new City; city2->name = lname; city2->adm = rgn.getIntAttr("X43"); city2->population = rgn.getIntAttr("X38"); city2->center = pt; c->next = city2; } } void Converter::readCities(const char *filename) { fprintf(stderr, "Read cities from: %s\n", filename); FILE *f = fopen(filename, "rt"); if (f == NULL) { fprintf(stderr, "File not found: %s\n", filename); exit(1); } Tokenizer t(f); mp::MPParser p(t, filename); try { while (p.parseObject()) ; } catch (ParserException &) { fprintf(stderr, "Error in file: '%s'\n", filename); t.printToken(); fclose(f); throw; } for (mp::Rgns::iterator it = p.map.rgns.begin(); it != p.map.rgns.end(); it++) { mp::Rgn &rgn = *it; addCity(rgn); } fclose(f); } void Converter::updatePopulation(const std::string &name, int popul) { std::string city = name; if (city.substr(0, 4) == "ïãò ") city = city.substr(4); else if (city.substr(0, 3) == "ã. ") city = city.substr(3); else if (city.substr(0, 3) == "ñ. ") city = city.substr(3); else if (city.substr(0, 3) == "c. ") city = city.substr(3); else if (city.substr(0, 3) == "ï. ") city = city.substr(3); else if (city.substr(0, 3) == "ä. ") city = city.substr(3); else if (city.substr(0, 4) == "ñë. ") city = city.substr(4); else if (city.substr(0, 8) == "æ-ä ñò. ") city = city.substr(8); else if (city.substr(0, 4) == "ñò. ") city = city.substr(4); else if (city.substr(0, 6) == "ñò-öà ") city = city.substr(6); else if (city.substr(0, 4) == "àóë ") city = city.substr(4); else if (city.substr(0, 3) == "õ. ") city = city.substr(3); int adm = -1; if (city.length() > 5 && city.substr(city.length() - 5) == " (ðö)") { city = city.substr(0, city.length() - 5); adm = 4; } /* if (adm > 0) printf("city: '%s': %d: ðö\n", city.c_str(), popul); else printf("city: '%s': %d\n", city.c_str(), popul); */ City *c = cities[city]; if (c != NULL) { if (adm > 0) c->adm = adm; c->population = popul; // printf("Found: '%s': %d\n", city.c_str(), popul); } else { // printf("Not found: '%s': %d\n", city.c_str(), popul); c = new City; c->name = city; c->adm = adm; c->population = popul; c->center.x = 0.0; c->center.y = 0.0; cities[c->name] = c; } } void Converter::readPop(const char *filename) { fprintf(stderr, "Read populations from: %s\n", filename); FILE *f = fopen(filename, "rt"); if (f == NULL) { fprintf(stderr, "File not found: %s\n", filename); exit(1); } Tokenizer t(f); // t.wordChars(32, (char)(unsigned char)255); // t.ordinaryChars('0', '9'); // t.ordinaryChar(','); // t.parseNumbers(); std::string lname; std::string pop; int pos = 0; for (;;) { int token = t.nextToken(); // t.printToken(); if (token == TT_EOF) break; if (token == TT_NUMBER) { printf("%s: %d\n", lname.c_str(), t.nval); lname = ""; continue; } if (token == '\n') { int popul = strtol(pop.c_str(), NULL, 10); updatePopulation(lname, popul); // printf("%s: %d\n", lname.c_str(), popul); lname = ""; pop = ""; pos = 0; continue; } if (token != ',') { switch (pos) { case 0: lname += lower(token); break; case 1: pop += token; break; } continue; } pos++; } fclose(f); } void Converter::readAdm(const char *filename) { fprintf(stderr, "Read adm from: %s\n", filename); FILE *f = fopen(filename, "rt"); if (f == NULL) { fprintf(stderr, "File not found: %s\n", filename); exit(1); } Tokenizer t(f); mp::MPParser p(t, filename); try { while (p.parseObject()) ; } catch (ParserException &) { fprintf(stderr, "Error in file: '%s'\n", filename); t.printToken(); fclose(f); throw; } adm = p.map; for (mp::Rgns::iterator it = adm.rgns.begin(); it != adm.rgns.end(); it++) { mp::Rgn &rgn = *it; bool first = true; for (mp::Elements::const_iterator it2 = rgn.elements.begin(); it2 != rgn.elements.end(); it2++) { const mp::Element &element = (*it2); for (mp::points_t::const_iterator it3 = element.points.begin(); it3 != element.points.end(); it3++) { if (first) { rgn.bottomleft = (*it3); rgn.topright = (*it3); first = false; } else { rgn.bottomleft.x = min(rgn.bottomleft.x, (*it3).x); rgn.bottomleft.y = min(rgn.bottomleft.y, (*it3).y); rgn.topright.x = max(rgn.topright.x, (*it3).x); rgn.topright.y = max(rgn.topright.y, (*it3).y); } } } } fclose(f); } namespace mp { int PolygonContainsPt (const mp::points_t &_points, double _x, double _y); } bool checkIn(mp::Rgn &rgn, mp::point_t &pt) { if (rgn.bottomleft.x > pt.x || rgn.bottomleft.y > pt.y || rgn.topright.x < pt.x || rgn.topright.y < pt.y) return false; for (mp::Elements::const_iterator it2 = rgn.elements.begin(); it2 != rgn.elements.end(); it2++) if (mp::PolygonContainsPt((*it2).points, pt.x, pt.y) >= 0) return true; return false; } void Converter::updateAdm(mp::Rgn &city) { bool foundCity = false; mp::point_t pt; pt.x = 0.0; pt.y = 0.0; int count = 0; for (mp::Elements::const_iterator it2 = city.elements.begin(); it2 != city.elements.end(); it2++) { for (mp::points_t::const_iterator it3 = (*it2).points.begin(); it3 != (*it2).points.end(); it3++) { pt.x += (*it3).x; pt.y += (*it3).y; count += 1; } } pt.x /= (double)count; pt.y /= (double)count; for (mp::Rgns::iterator it = adm.rgns.begin(); it != adm.rgns.end(); it++) { mp::Rgn &rgn = *it; if (checkIn(rgn, pt)) { if (foundCity) printf("City %s is found in (%s, %s, %s) and in (%s, %s, %s)\n", city.label.c_str(), city.getAttr("COUNTRY"), city.getAttr("REGION"), city.getAttr("COUNTY"), rgn.getAttr("name_cntr"), rgn.getAttr("name_adm1"), rgn.getAttr("name_adm2")); city.setAttr("COUNTRY", rgn.getAttr("name_cntr")); const char *region = rgn.getAttr("name_adm1"); if (region != NULL) city.setAttr("REGION", region); const char *county = rgn.getAttr("name_adm2"); if (county != NULL) city.setAttr("COUNTY", county); foundCity = true; } } } int fromIngitAdm(int adm) { switch (adm) { case 0: return 0; case 1: return 1; case 2: case 3: case 4: case 5: case 6: case 8: return 3; case 9: return 4; case 10: return 5; case 11: return 6; default: printf("Invalid adm value: %d\n", adm); } return 0; } void Converter::process(const char *filename) { fprintf(stderr, "Read settles list from: %s\n", filename); FILE *f = fopen(filename, "rt"); if (f == NULL) { fprintf(stderr, "File not found: %s\n", filename); exit(1); } Tokenizer t(f); try { for (;;) { t.nextToEOL(true); if (t.ttype == TT_EOF) break; if (t.sval.empty()) break; processSettle(t.sval.c_str()); } } catch (ParserException &) { fprintf(stderr, "Error in file: '%s'\n", filename); t.printToken(); fclose(f); throw; } fclose(f); } void Converter::processSettle(const char *filename) { fprintf(stderr, "Read settles from: %s\n", filename); FILE *f = fopen(filename, "rt"); if (f == NULL) { fprintf(stderr, "File not found: %s\n", filename); exit(1); } Tokenizer t(f); mp::MPParser p(t, filename); try { while (p.parseObject()) ; } catch (ParserException &) { fprintf(stderr, "Error in file: '%s'\n", filename); t.printToken(); fclose(f); throw; } fclose(f); std::string outFilename = "out\\"; outFilename = filename; //outFilename += filename; FILE *fo = fopen(outFilename.c_str(), "wt"); if (f == NULL) { fprintf(stderr, "File not found: %s\n", outFilename.c_str()); exit(1); } p.map.printHeader(fo); for (mp::Rgns::iterator it = p.map.rgns.begin(); it != p.map.rgns.end(); it++) { mp::Rgn &rgn = *it; if (!rgn.label.empty()) printf("Processing: %s\n", rgn.label.c_str()); mp::point_t pt; pt.x = 0.0; pt.y = 0.0; int count = 0; for (mp::Elements::const_iterator it2 = rgn.elements.begin(); it2 != rgn.elements.end(); it2++) { for (mp::points_t::const_iterator it3 = (*it2).points.begin(); it3 != (*it2).points.end(); it3++) { pt.x += (*it3).x; pt.y += (*it3).y; count += 1; } } pt.x /= (double)count; pt.y /= (double)count; updateAdm(rgn); City *c = findCity(rgn.label, pt); if (c != NULL) { printf("Update: %s\n", rgn.label.c_str()); if (fromIngitAdm(c->adm) > 0 && rgn.getAttr("ADM") == NULL) rgn.setIntAttr("ADM", fromIngitAdm(c->adm)); if (c->population > 0) rgn.setIntAttr("POPULATION", c->population); } rgn.print(fo, true); } fclose(fo); } static void printUsage(const char *name) { fprintf(stderr, "Usage: %s [-h header_file] <config> [<output>]\n", name); } int main(int argc, char* argv[]) { int firstArg = 1; /* if (argc < firstArg + 1) { printUsage(argv[0]); return 1; } */ Converter c; try { c.readCities("c:\\tmp\\rf.mp"); c.readAdm("c:\\tmp\\adm.mp"); c.readPop("pop.csv"); c.process("settle.lst"); } catch (ParserException &x) { fprintf(stderr, "%s\n", x.what()); return 1; } return 0; } |
From: Denis P. <dy...@us...> - 2005-10-21 08:09:39
|
Update of /cvsroot/cmap/mp2mp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29854 Modified Files: mp_parser.h mp_parser.cpp Log Message: constify some methods. Handle [rgnxx] headers. Allow to set int attrs. Index: mp_parser.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp_parser.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- mp_parser.cpp 24 Sep 2005 16:01:11 -0000 1.11 +++ mp_parser.cpp 21 Oct 2005 08:09:30 -0000 1.12 @@ -54,14 +54,14 @@ } */ -void Attr::print(FILE *f) { +void Attr::print(FILE *f) const { fprintf(f, "; %s=%s\n", name.c_str(), value.c_str()); } Rgn::Rgn() : kind(kind::Point), type(0), endLevel(0), direction(Unknown), city(Unknown) { } -void Rgn::print(FILE *f, const ObjectProp &op, bool is6Digit) { +void Rgn::print(FILE *f, const ObjectProp &op, bool is6Digit) const { fprintf(f, "; LOC=%s:%u\n", filename.c_str(), line); for (::Attrs::const_iterator it = op.attrs.begin(); it != op.attrs.end(); it++) (*it).print(f); @@ -108,13 +108,13 @@ if (kind != op.kind && op.kind == kind::Point) { unsigned int layerMax = op.layerMax > 0 ? op.layerMax : op.layerMin; for (unsigned int i = op.layerMin; i <= layerMax; i++) { - for (Elements::iterator it2 = elements.begin(); it2 != elements.end(); it2++) { + for (Elements::const_iterator it2 = elements.begin(); it2 != elements.end(); it2++) { point_t pt; pt.x = 0.0; pt.y = 0.0; double count = 0.0; - for (points_t::iterator it3 = (*it2).points.begin(); it3 != (*it2).points.end(); it3++) { + for (points_t::const_iterator it3 = (*it2).points.begin(); it3 != (*it2).points.end(); it3++) { pt.x += (*it3).x; pt.y += (*it3).y; count += 1.0; @@ -131,15 +131,15 @@ } else { unsigned int layerMax = op.layerMax > 0 ? op.layerMax : op.layerMin; for (unsigned int i = op.layerMin; i <= layerMax; i++) - for (Elements::iterator it2 = elements.begin(); it2 != elements.end(); it2++) + for (Elements::const_iterator it2 = elements.begin(); it2 != elements.end(); it2++) (*it2).print(f, op, is6Digit, i); } fprintf(f, "[END]\n"); fprintf(f, "\n"); } -void Rgn::print(FILE *f, bool is6Digit) { - for (Attrs::iterator it = attrs.begin(); it != attrs.end(); it++) +void Rgn::print(FILE *f, bool is6Digit) const { + for (Attrs::const_iterator it = attrs.begin(); it != attrs.end(); it++) (*it).print(f); switch (kind) { @@ -161,7 +161,7 @@ if (label.length() > 0) fprintf(f, "Label=%s\n", label.c_str()); - for (Elements::iterator it2 = elements.begin(); it2 != elements.end(); it2++) + for (Elements::const_iterator it2 = elements.begin(); it2 != elements.end(); it2++) (*it2).print(f, is6Digit); fprintf(f, "[END]\n"); fprintf(f, "\n"); @@ -241,6 +241,50 @@ } } +const char *Rgn::getAttr(const std::string &name) const { + for (Attrs::const_iterator it = attrs.begin(); it != attrs.end(); it++) + if (it->name == name) + return it->value.c_str(); + return NULL; +} + +int Rgn::getIntAttr(const std::string &name) const { + for (Attrs::const_iterator it = attrs.begin(); it != attrs.end(); it++) + if (it->name == name) + return ::strtol(it->value.c_str(), NULL, 10); + return 0; +} + +void Rgn::setAttr(const std::string name, const std::string value) { + for (Attrs::iterator iAttr = attrs.begin (); iAttr != attrs.end (); ++iAttr) { + Attr &attr = *iAttr; + if (attr.name == name) { + attr.value = value; + return; + } + } + Attr attr; + attr.name = name; + attr.value = value; + attrs.push_back(attr); +} + +void Rgn::setIntAttr(const std::string name, const int value) { + char s[20]; + ::sprintf(s, "%d", value); + for (Attrs::iterator iAttr = attrs.begin (); iAttr != attrs.end (); ++iAttr) { + Attr &attr = *iAttr; + if (attr.name == name) { + attr.value = s; + return; + } + } + Attr attr; + attr.name = name; + attr.value = s; + attrs.push_back(attr); +} + Element::Element(int _level) : level(_level) { } @@ -361,9 +405,9 @@ return false; } -void Element::print(FILE *f, bool is6Digit) { +void Element::print(FILE *f, bool is6Digit) const { fprintf(f, "Data%d=", level); - for (points_t::iterator it = points.begin(); it != points.end(); it++) { + for (points_t::const_iterator it = points.begin(); it != points.end(); it++) { if (it != points.begin()) fprintf(f, ","); (*it).print(f, is6Digit); @@ -371,9 +415,9 @@ fprintf(f, "\n"); } -void Element::print(FILE *f, const ObjectProp &op, bool is6Digit, unsigned int _level) { +void Element::print(FILE *f, const ObjectProp &op, bool is6Digit, unsigned int _level) const { fprintf(f, "Data%d=", _level); - for (points_t::iterator it = points.begin(); it != points.end(); it++) { + for (points_t::const_iterator it = points.begin(); it != points.end(); it++) { if (it != points.begin()) fprintf(f, ","); (*it).print(f, is6Digit); @@ -455,7 +499,7 @@ return fMaxX - fMinX; } -void point_t::print(FILE *f, bool is6Digits) { +void point_t::print(FILE *f, bool is6Digits) const { if (is6Digits) fprintf(f, "(%.6f,%.6f)", y, x); else @@ -677,14 +721,14 @@ if (ttype != '[') throw ParserException("'[' expected", t.lineno()); - if (t.nextToken() != TT_WORD || (t.sval != "polyline" && t.sval != "polygon" && t.sval != "poi")) + if (t.nextToken() != TT_WORD || (t.sval != "polyline" && t.sval != "polygon" && t.sval != "poi" && t.sval != "rgn10" && t.sval != "rgn20" && t.sval != "rgn40" && t.sval != "rgn80")) throw ParserException("'polyline', 'polygon' or 'poi' expected", t.lineno()); Kind kind; - if (t.sval == "polyline") + if (t.sval == "polyline" || t.sval == "rgn40") kind = kind::Line; - else if (t.sval == "polygon") + else if (t.sval == "polygon" || t.sval == "rgn80") kind = kind::Polygon; - else if (t.sval == "poi") + else if (t.sval == "poi" || t.sval == "rgn10" || t.sval == "rgn20") kind = kind::Point; if (t.nextToken() != ']') Index: mp_parser.h =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp_parser.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- mp_parser.h 24 Sep 2005 16:01:11 -0000 1.10 +++ mp_parser.h 21 Oct 2005 08:09:30 -0000 1.11 @@ -14,7 +14,7 @@ double x; double y; - void print(FILE *f, bool is6Digits); + void print(FILE *f, bool is6Digits) const; }; typedef std::vector<point_t> points_t; @@ -30,8 +30,8 @@ int level; points_t points; - void print(FILE *f, bool is6Digit); - void print(FILE *f, const ObjectProp &op, bool is6Digit, unsigned int level); + void print(FILE *f, bool is6Digit) const; + void print(FILE *f, const ObjectProp &op, bool is6Digit, unsigned int level) const; double getArea() const; double getLength() const; double getHeight() const; @@ -46,7 +46,7 @@ std::string name; std::string value; - void print(FILE *f); + void print(FILE *f) const; }; typedef std::vector<Attr> Attrs; @@ -87,14 +87,21 @@ std::string filename; unsigned int line; - void print(FILE *f, bool is6Digit); - void print(FILE *f, const ObjectProp &op, bool is6Digit); + void print(FILE *f, bool is6Digit) const; + void print(FILE *f, const ObjectProp &op, bool is6Digit) const; double getArea() const; double getLength() const; double getHeight() const; double getWidth() const; bool isHoleOfAny(const Element &_element); void refreshInners(); + const char *getAttr(const std::string &name) const; + int getIntAttr(const std::string &name) const; + void setAttr(const std::string name, const std::string value); + void setIntAttr(const std::string name, const int value); + + point_t topright; // max + point_t bottomleft; // min }; typedef std::list<Rgn> Rgns; |
From: Denis P. <dy...@us...> - 2005-10-21 07:58:26
|
Update of /cvsroot/cmap/libs/eval In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27389 Modified Files: tokenizer.cpp Log Message: Fix work with chars above 127. Index: tokenizer.cpp =================================================================== RCS file: /cvsroot/cmap/libs/eval/tokenizer.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- tokenizer.cpp 25 Sep 2005 11:57:36 -0000 1.9 +++ tokenizer.cpp 21 Oct 2005 07:58:12 -0000 1.10 @@ -130,7 +130,7 @@ if (c == '\n') c = read(); if (eolIsSignificantP) { - peekc = (char)c; + peekc = c; return ttype = TT_EOL; } } else { @@ -152,7 +152,7 @@ if (c == '-') { c = read(); if (c < '0' || c > '9') { - peekc = (char)c; + peekc = c; return ttype = '-'; } neg = true; @@ -171,7 +171,7 @@ else break; } - peekc = (char)c; + peekc = c; nval = v; return ttype = TT_NUMBER; } @@ -195,11 +195,11 @@ } else break; } - peekc = (char)c; + peekc = c; dval = neg ? -(v + fr) : (v + fr); return ttype = TT_FLOAT; } - peekc = (char)c; + peekc = c; nval = neg ? -v : v; return ttype = TT_NUMBER; } @@ -211,7 +211,7 @@ c = read(); _ctype = c < 0 ? CT_WHITESPACE : c < 256 ? ct[c] : CT_ALPHA; } while ((_ctype & (CT_ALPHA | CT_DIGIT)) != 0); - peekc = (char)c; + peekc = c; if (forceLower) for (unsigned int i = 0; i < sval.length(); i++) sval[i] = tolower(sval[i]); @@ -222,12 +222,12 @@ if (produceCommentsP) { sval = ""; while ((c = read()) != '\n' && c != '\r' && c >= 0) - sval += (unsigned char)c; - peekc = (char)c; + sval += c; + peekc = c; return ttype = TT_COMMENT; } while ((c = read()) != '\n' && c != '\r' && c >= 0); - peekc = (char)c; + peekc = c; return nextToken(); } @@ -253,9 +253,9 @@ c = (c << 3) + (c2 - '0'); peekc = read(); } else - peekc = (char)c2; + peekc = c2; } else - peekc = (char)c2; + peekc = c2; } else { switch (c) { case 'a': @@ -321,10 +321,10 @@ return nextToken(); } else if (c == '/' && slashSlashCommentsP) { while ((c = read()) != '\n' && c != '\r' && c >= 0); - peekc = (char)c; + peekc = c; return nextToken(); } else { - peekc = (char)c; + peekc = c; return ttype = '/'; } } |
From: Denis P. <dy...@us...> - 2005-09-25 12:03:41
|
Update of /cvsroot/cmap/cmap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30369 Modified Files: cmap.dsp header.txt parserImpl.cpp parserImpl.h topo.conf Log Message: Updated cmap to a new eval arch. topo.conf updated. TODO: update plan.conf Index: parserImpl.cpp =================================================================== RCS file: /cvsroot/cmap/cmap/parserImpl.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- parserImpl.cpp 31 Oct 2004 09:06:40 -0000 1.1 +++ parserImpl.cpp 25 Sep 2005 12:03:33 -0000 1.2 @@ -1,40 +1,12 @@ #include <stdio.h> +#include <eval/pexcept.h> + #include "parserImpl.h" #include "object.h" #include "IngitFile.h" -class AttrVar : public StringRVar { -public: - AttrVar(int _n) : n(_n) { - } - - virtual std::string getValue(const void *obj, const ObjectProp &) { - const h_object *o = (const h_object *)obj; - if (o->atr_cod[n] == NULL) - return ""; - return o->atr_cod[n]; - } - - int n; -}; - -class IntAttrVar : public IntRVar { -public: - IntAttrVar(int _n) : n(_n) { - } - - virtual int getValue(const void *obj, const ObjectProp &, int) { - const h_object *o = (const h_object *)obj; - if (o->atr_cod[n] == NULL) - return 0; - return strtol(o->atr_cod[n], NULL, 10); - } - - int n; -}; - class SquareVar : public IntRVar { virtual int getValue(const void *obj, const ObjectProp &, int numArray) { const h_object *o = (const h_object *)obj; @@ -53,14 +25,6 @@ } }; -class AttrSetVar : public SetVar { -public: - virtual bool getIn(const void *obj, int index) { - const h_object *o = (const h_object *)obj; - return o->atr_cod[index] != NULL; - } -}; - static ObjectConf *firstObj = NULL; static ObjectConf *lastObj = NULL; @@ -150,6 +114,17 @@ printf("Unknown object type: '%c'\n", object->Cod[0]); exit(1); } + + for (int i=0; i < 120; i++) { + if (object->atr_cod[i] == NULL) + continue; + Attr a; + char s[20]; + ::sprintf(s, "X%d", i); + a.name = s; + a.value = object->atr_cod[i]; + op.attrs.push_back(a); + } } ConfigParserImpl::ConfigParserImpl(Tokenizer &_t) : ConfigParser(_t) { @@ -163,33 +138,6 @@ return new SquareVar(); if (varName == "length") return new LengthVar(); - if ((varName.length() > 7) && (strncmp(varName.c_str(), "intattr", 7) == 0)) { // intattrNUM var - char *err; - long n = strtol(varName.c_str() + 7, &err, 10); - if ((*err != 0) || (n > 110)) - throw ParserException(("Unknown variable: " + varName).c_str()); - return new IntAttrVar(n); - } - return NULL; -} - -StringRVar *ConfigParserImpl::parseStringRVar(const std::string &varName) { - StringRVar *var = ConfigParser::parseStringRVar(varName); - if (var != NULL) - return var; - if ((varName.length() > 4) && (strncmp(varName.c_str(), "attr", 4) == 0)) { // attrNUM var - char *err; - long n = strtol(varName.c_str() + 4, &err, 10); - if ((*err != 0) || (n > 110)) - throw ParserException(("Unknown variable: " + varName).c_str()); - return new AttrVar(n); - } - return NULL; -} - -SetVar *ConfigParserImpl::parseSetVar(const std::string &varName) { - if (varName == "attr") - return new AttrSetVar(); return NULL; } @@ -203,17 +151,17 @@ case TT_WORD: break; default: - throw ParserException("Expected 'file'"); + throw ParserException("Expected 'file'", t.lineno()); } if (t.sval != "object") - throw ParserException("Expected 'object'"); + throw ParserException("Expected 'object'", t.lineno()); if (t.nextToken() != TT_STRING) - throw ParserException("Expected object code"); + throw ParserException("Expected object code", t.lineno()); if (t.sval.length() > 8) - throw ParserException("Object code is longer than 8"); + throw ParserException("Object code is longer than 8", t.lineno()); ObjectConfImpl *obj = new ObjectConfImpl(t.sval.c_str()); Index: header.txt =================================================================== RCS file: /cvsroot/cmap/cmap/header.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- header.txt 24 Apr 2004 19:48:08 -0000 1.2 +++ header.txt 25 Sep 2005 12:03:33 -0000 1.3 @@ -9,8 +9,6 @@ TreMargin=0.02000 RgnLimit=500 POIIndex=Y -AlignMethod=0.0001 -LevelFill=40 Levels=5 Level0=21 Level1=20 Index: cmap.dsp =================================================================== RCS file: /cvsroot/cmap/cmap/cmap.dsp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- cmap.dsp 5 Feb 2005 12:12:27 -0000 1.9 +++ cmap.dsp 25 Sep 2005 12:03:33 -0000 1.10 @@ -121,6 +121,10 @@ # End Source File # Begin Source File +SOURCE=.\eval\pexcept.cpp +# End Source File +# Begin Source File + SOURCE=.\PolishFormat.cpp # End Source File # Begin Source File @@ -177,6 +181,10 @@ # End Source File # Begin Source File +SOURCE=.\eval\pexcept.h +# End Source File +# Begin Source File + SOURCE=.\PolishFormat.h # End Source File # Begin Source File Index: parserImpl.h =================================================================== RCS file: /cvsroot/cmap/cmap/parserImpl.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- parserImpl.h 5 Feb 2005 12:12:27 -0000 1.2 +++ parserImpl.h 25 Sep 2005 12:03:33 -0000 1.3 @@ -9,8 +9,6 @@ ConfigParserImpl(Tokenizer &_t); virtual IntRVar *parseIntRVar(const std::string &varName); - virtual StringRVar *parseStringRVar(const std::string &varName); - virtual SetVar *parseSetVar(const std::string &varName); virtual bool parseObject(); virtual void parseBlockStart(ObjectConf *obj); }; Index: topo.conf =================================================================== RCS file: /cvsroot/cmap/cmap/topo.conf,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- topo.conf 31 Oct 2004 09:06:40 -0000 1.10 +++ topo.conf 25 Sep 2005 12:03:33 -0000 1.11 @@ -123,7 +123,7 @@ polygon = 0x4D; layer_min = 0; layer_max = 1; - label = attr9; + label = attr "X9"; } // Ôèðíîâûå ïîëÿ object "22120000" { @@ -131,7 +131,7 @@ polygon = 0x4D; layer_min = 0; [...1305 lines suppressed...] + label = attr "X9"; } // Ñîëîí÷àêè object "72320000" { @@ -2807,7 +2807,7 @@ point = 0x660F; layer_min = 0; layer_max = 0; - label = attr9; + label = attr "X9"; } // Êîïåö object "81130000" { @@ -2828,5 +2828,5 @@ line = 0x1C; layer_min = 0; layer_max = 0; - label = attr9; + label = attr "X9"; } |
From: Denis P. <dy...@us...> - 2005-09-25 11:57:59
|
Update of /cvsroot/cmap/libs/eval In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28967 Modified Files: tokenizer.cpp Log Message: Correctly output line number Index: tokenizer.cpp =================================================================== RCS file: /cvsroot/cmap/libs/eval/tokenizer.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- tokenizer.cpp 24 Apr 2005 19:59:51 -0000 1.8 +++ tokenizer.cpp 25 Sep 2005 11:57:36 -0000 1.9 @@ -64,22 +64,22 @@ printf("eol\n"); break; case TT_NUMBER: - printf("%ld: num: %d\n", lineno(), nval); + printf("%ld: num: %d\n", lineno() + 1, nval); break; case TT_FLOAT: - printf("%ld: float: %f\n", lineno(), dval); + printf("%ld: float: %f\n", lineno() + 1, dval); break; case TT_WORD: - printf("%ld: word: %s\n", lineno(), sval.c_str()); + printf("%ld: word: %s\n", lineno() + 1, sval.c_str()); break; case TT_STRING: - printf("%ld: string: %s\n", lineno(), sval.c_str()); + printf("%ld: string: %s\n", lineno() + 1, sval.c_str()); break; case TT_COMMENT: - printf("%ld: comment: %s\n", lineno(), sval.c_str()); + printf("%ld: comment: %s\n", lineno() + 1, sval.c_str()); break; default: - printf("%ld: char: %c\n", lineno(), (unsigned char)ttype); + printf("%ld: char: %c\n", lineno() + 1, (unsigned char)ttype); break; } } |
From: Denis P. <dy...@us...> - 2005-09-24 16:01:22
|
Update of /cvsroot/cmap/mp2mp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6998 Modified Files: mp_parser.cpp mp_parser.h parserImpl.cpp Log Message: Add height and width Index: parserImpl.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/parserImpl.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- parserImpl.cpp 23 Sep 2005 05:10:39 -0000 1.6 +++ parserImpl.cpp 24 Sep 2005 16:01:11 -0000 1.7 @@ -25,6 +25,28 @@ }; }; +class WidthExpr : public IntRVar { +public: + virtual ~WidthExpr() { + } + + virtual int getValue(const void *obj, const ObjectProp &op, int numArray) { + const mp::Rgn *rgn = (const mp::Rgn *)obj; + return rgn->getWidth() * 1e3; + }; +}; + +class HeightExpr : public IntRVar { +public: + virtual ~HeightExpr() { + } + + virtual int getValue(const void *obj, const ObjectProp &op, int numArray) { + const mp::Rgn *rgn = (const mp::Rgn *)obj; + return rgn->getHeight() * 1e3; + }; +}; + ConfigParserImpl::ConfigParserImpl(Tokenizer &_t) : ConfigParser(_t) { } @@ -33,6 +55,10 @@ return new AreaExpr; if (varName == "length") return new LengthExpr; + if (varName == "width") + return new WidthExpr; + if (varName == "height") + return new HeightExpr; return ConfigParser::parseIntRVar(varName); } Index: mp_parser.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp_parser.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- mp_parser.cpp 23 Sep 2005 05:10:39 -0000 1.10 +++ mp_parser.cpp 24 Sep 2005 16:01:11 -0000 1.11 @@ -72,10 +72,14 @@ break; case kind::Line: fprintf(f, "; LENGTH=%d\n", (int)(getLength() * 1.e3)); + fprintf(f, "; WIDTH=%d\n", (int)(getWidth() * 1.e3)); + fprintf(f, "; HEIGHT=%d\n", (int)(getHeight() * 1.e3)); fprintf(f, "[POLYLINE]\n"); break; case kind::Polygon: fprintf(f, "; AREA=%d\n", (int)(getArea() * 1.e6)); + fprintf(f, "; WIDTH=%d\n", (int)(getWidth() * 1.e3)); + fprintf(f, "; HEIGHT=%d\n", (int)(getHeight() * 1.e3)); fprintf(f, "[POLYGON]\n"); break; }; @@ -186,6 +190,38 @@ return fLength; } +inline double max(const double x1, const double x2) { + return x1 > x2 ? x1 : x2; +} + +inline double min(const double x1, const double x2) { + return x1 < x2 ? x1 : x2; +} + +double Rgn::getHeight() const { + const size_t cElements = elements.size(); + if (cElements == 0) + return 0; + double fMaxHeight = elements[0].getHeight(); + for (size_t cElement = 1; cElement < cElements; ++ cElement) { + const Element &element = elements[cElement]; + fMaxHeight = max(fMaxHeight, element.getHeight()); + } + return fMaxHeight; +} + +double Rgn::getWidth() const { + const size_t cElements = elements.size(); + if (cElements == 0) + return 0; + double fMaxWidth = elements[0].getWidth(); + for (size_t cElement = 1; cElement < cElements; ++ cElement) { + const Element &element = elements[cElement]; + fMaxWidth = max(fMaxWidth, element.getWidth()); + } + return fMaxWidth; +} + bool Rgn::isHoleOfAny(const Element &_element) { const size_t cElements = elements.size(); for (size_t cElement = 0; cElement < cElements; ++ cElement) { @@ -384,6 +420,41 @@ return fLength; } +double Element::getHeight() const { + const size_t cPoints = points.size (); + if (cPoints <= 1) + return 0; + + double fMinY = 360; + double fMaxY = -360; + + for (size_t cPoint = 0; cPoint < cPoints; ++ cPoint) { + const point_t & p = points [cPoint]; + + fMinY = min(p.y, fMinY); + fMaxY = max(p.y, fMaxY); + } + + return fMaxY - fMinY; +} + +double Element::getWidth() const { + const size_t cPoints = points.size (); + if (cPoints <= 1) + return 0; + + double fMinX = 360; + double fMaxX = -360; + for (size_t cPoint = 0; cPoint < cPoints; ++ cPoint) { + const point_t & p = points [cPoint]; + + fMinX = min(p.x, fMinX); + fMaxX = max(p.x, fMaxX); + } + + return fMaxX - fMinX; +} + void point_t::print(FILE *f, bool is6Digits) { if (is6Digits) fprintf(f, "(%.6f,%.6f)", y, x); Index: mp_parser.h =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp_parser.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- mp_parser.h 23 Sep 2005 05:10:39 -0000 1.9 +++ mp_parser.h 24 Sep 2005 16:01:11 -0000 1.10 @@ -34,6 +34,8 @@ void print(FILE *f, const ObjectProp &op, bool is6Digit, unsigned int level); double getArea() const; double getLength() const; + double getHeight() const; + double getWidth() const; bool isHoleOf(const Element &_outer) const; }; @@ -89,6 +91,8 @@ void print(FILE *f, const ObjectProp &op, bool is6Digit); double getArea() const; double getLength() const; + double getHeight() const; + double getWidth() const; bool isHoleOfAny(const Element &_element); void refreshInners(); }; |
From: Denis P. <dy...@us...> - 2005-09-23 05:10:54
|
Update of /cvsroot/cmap/mp2mp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2507 Modified Files: mp2mp.dsw mp_parser.cpp mp_parser.h parserImpl.cpp parserImpl.h Log Message: area & length added Index: parserImpl.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/parserImpl.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- parserImpl.cpp 28 Aug 2005 22:23:58 -0000 1.5 +++ parserImpl.cpp 23 Sep 2005 05:10:39 -0000 1.6 @@ -3,9 +3,39 @@ #include "pexcept.h" #include "mp_parser.h" +class AreaExpr : public IntRVar { +public: + virtual ~AreaExpr() { + } + + virtual int getValue(const void *obj, const ObjectProp &op, int numArray) { + const mp::Rgn *rgn = (const mp::Rgn *)obj; + return rgn->getArea() * 1e6; + }; +}; + +class LengthExpr : public IntRVar { +public: + virtual ~LengthExpr() { + } + + virtual int getValue(const void *obj, const ObjectProp &op, int numArray) { + const mp::Rgn *rgn = (const mp::Rgn *)obj; + return rgn->getLength() * 1e3; + }; +}; + ConfigParserImpl::ConfigParserImpl(Tokenizer &_t) : ConfigParser(_t) { } +IntRVar *ConfigParserImpl::parseIntRVar(const std::string &varName) { + if (varName == "area") + return new AreaExpr; + if (varName == "length") + return new LengthExpr; + return ConfigParser::parseIntRVar(varName); +} + bool ConfigParserImpl::parseObject() { switch (t.nextToken()) { case TT_EOF: Index: parserImpl.h =================================================================== RCS file: /cvsroot/cmap/mp2mp/parserImpl.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- parserImpl.h 28 Aug 2005 22:23:58 -0000 1.2 +++ parserImpl.h 23 Sep 2005 05:10:39 -0000 1.3 @@ -8,6 +8,7 @@ ConfigParserImpl(Tokenizer &_t); virtual bool parseObject(); + virtual IntRVar *parseIntRVar(const std::string &varName); }; #endif Index: mp_parser.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp_parser.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- mp_parser.cpp 9 Sep 2005 09:58:54 -0000 1.9 +++ mp_parser.cpp 23 Sep 2005 05:10:39 -0000 1.10 @@ -1,3 +1,6 @@ +#include <math.h> +#include <assert.h> + #include "mp_parser.h" #include "pexcept.h" @@ -68,9 +71,11 @@ fprintf(f, "[POI]\n"); break; case kind::Line: + fprintf(f, "; LENGTH=%d\n", (int)(getLength() * 1.e3)); fprintf(f, "[POLYLINE]\n"); break; case kind::Polygon: + fprintf(f, "; AREA=%d\n", (int)(getArea() * 1.e6)); fprintf(f, "[POLYGON]\n"); break; }; @@ -99,13 +104,13 @@ if (kind != op.kind && op.kind == kind::Point) { unsigned int layerMax = op.layerMax > 0 ? op.layerMax : op.layerMin; for (unsigned int i = op.layerMin; i <= layerMax; i++) { - for (std::list<Element>::iterator it2 = elements.begin(); it2 != elements.end(); it2++) { + for (Elements::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++) { + for (points_t::iterator it3 = (*it2).points.begin(); it3 != (*it2).points.end(); it3++) { pt.x += (*it3).x; pt.y += (*it3).y; count += 1.0; @@ -122,7 +127,7 @@ } else { unsigned int layerMax = op.layerMax > 0 ? op.layerMax : op.layerMin; for (unsigned int i = op.layerMin; i <= layerMax; i++) - for (std::list<Element>::iterator it2 = elements.begin(); it2 != elements.end(); it2++) + for (Elements::iterator it2 = elements.begin(); it2 != elements.end(); it2++) (*it2).print(f, op, is6Digit, i); } fprintf(f, "[END]\n"); @@ -130,7 +135,7 @@ } void Rgn::print(FILE *f, bool is6Digit) { - for (std::list<Attr>::iterator it = attrs.begin(); it != attrs.end(); it++) + for (Attrs::iterator it = attrs.begin(); it != attrs.end(); it++) (*it).print(f); switch (kind) { @@ -152,18 +157,177 @@ if (label.length() > 0) fprintf(f, "Label=%s\n", label.c_str()); - for (std::list<Element>::iterator it2 = elements.begin(); it2 != elements.end(); it2++) + for (Elements::iterator it2 = elements.begin(); it2 != elements.end(); it2++) (*it2).print(f, is6Digit); fprintf(f, "[END]\n"); fprintf(f, "\n"); } +double Rgn::getArea() const { + double fArea = 0.0; + const size_t cElements = elements.size(); + for (size_t cElement = 0; cElement < cElements; ++ cElement) { + const Element &element = elements[cElement]; + if (element.status == Element::OUTER) + fArea += element.getArea(); + else + fArea -= element.getArea(); + } + return fArea; +} + +double Rgn::getLength() const { + double fLength = 0.0; + const size_t cElements = elements.size(); + for (size_t cElement = 0; cElement < cElements; ++ cElement) { + const Element &element = elements[cElement]; + fLength += element.getLength(); + } + return fLength; +} + +bool Rgn::isHoleOfAny(const Element &_element) { + const size_t cElements = elements.size(); + for (size_t cElement = 0; cElement < cElements; ++ cElement) { + Element &element = elements[cElement]; + if (&element != &_element) + if (_element.isHoleOf(element)) + return true; + } + return false; +} + +void Rgn::refreshInners() { + const size_t cElements = elements.size(); + for (size_t cElement = 0; cElement < cElements; ++ cElement) { + Element &element = elements[cElement]; + element.status = isHoleOfAny(element) ? Element::INNER : Element::OUTER; + } +} + Element::Element(int _level) : level(_level) { } +/////////////////////////////////////////////////////////////// +// +// The algorithm was obtained from pGPSMap.js written by Olexa Ryznik (http://www.olexa.ua) +// +// Returns 1 if point is entirely within polygon, +// 0 if it is on its border and +// -1 if it is outside polygon. +// +int PolygonContainsPt (const points_t &_points, double _x, double _y) { + size_t cc = 0; + + int iLastTouchingLinkSide = 0; + size_t cFirstPoint = 0; + bool bFirstPointPassed = false; + + size_t cNodesWithEqualY = 0; + + size_t cPoints = _points.size(); + for (size_t cPoint = 1; cPoint != cFirstPoint + 1 || ! bFirstPointPassed; ++ cPoint) { + // Get the first point of chain. + size_t cPoint0 = cPoint - 1; + while (cPoint0 >= cPoints) + cPoint0 -= cPoints; + float y0 = static_cast<float> (_points [cPoint0].y); + float x0 = static_cast<float> (_points [cPoint0].x); + + // Get the second point of chain. + while (cPoint >= cPoints) + cPoint -= cPoints; + float y1 = static_cast<float> (_points [cPoint].y); + float x1 = static_cast<float> (_points [cPoint].x); + + if (x0 == x1 && y0 == y1) { + // Infinite loop protection. + ++ cNodesWithEqualY; + if (cNodesWithEqualY > cPoints) + return -1; + + continue; + } + + if ( + (y0 < _y && _y < y1) || + (y0 > _y && _y > y1) + ) { + // Chain crosses point's latitude. + const float x = x0 + (_y - y0)*(x1 - x0)/(y1 - y0); + if (x == _x) + // Chain crosses the point. + return 0; + else if (x < _x) + // Chain passes under the point. + ++ cc; + + bFirstPointPassed = true; + } else if (y0 == _y && y1 == _y) { + // Chain is entirely within point's latitude. + if ( + (x0 <= _x && x1 >= _x) || + (x0 >= _x && x1 <= _x) + ) + // Chain crosses the point. + return 0; + + if (cFirstPoint == cPoint - 1 && x1 < _x) + // There was no any link that crosses point's latitude or finishes at it yet. + ++ cFirstPoint; + + // Infinite loop protection. + assert (y0 == y1); + ++ cNodesWithEqualY; + if (cNodesWithEqualY > cPoints) + return -1; + } else if (y0 != _y && y1 == _y) { + // Chain finishes at point's latitude. + if (x1 == _x) + // Chain crosses the point. + return 0; + else if (x1 < _x) + // Remember last touching chain side. + iLastTouchingLinkSide = y0 < _y ? -1 : 1; + bFirstPointPassed = true; + } else if (y0 == _y && y1 != _y) { + // Chain starts at point's latitude. + if (x0 == _x) + // Chain crosses the point. + return 0; + else if (x0 < _x) + if (iLastTouchingLinkSide == 0) + // There was no touching chain yet. + // We should loop through the polygon 'till this point. + cFirstPoint = cPoint; + else if ( + iLastTouchingLinkSide == -1 && y1 > _y || + iLastTouchingLinkSide == 1 && y1 < _y + ) + // This links with previous touching chain together cross point's latitude. + ++ cc; + } else + // Chain does not cross point's latitude. + bFirstPointPassed = true; + } + return (cc & 0x1) ? 1 : -1; +} + +bool Element::isHoleOf(const Element &_outer) const { + for (size_t cInnerPoint = 0; cInnerPoint < points.size(); ++ cInnerPoint) { + const int iContains = PolygonContainsPt(_outer.points, points[cInnerPoint].x, points[cInnerPoint].y); + if (iContains < 0) + return false; + else if (iContains > 0) + return true; + }; + + return false; +} + 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++) { + for (points_t::iterator it = points.begin(); it != points.end(); it++) { if (it != points.begin()) fprintf(f, ","); (*it).print(f, is6Digit); @@ -173,14 +337,53 @@ void Element::print(FILE *f, const ObjectProp &op, bool is6Digit, unsigned int _level) { fprintf(f, "Data%d=", _level); - for (std::list<point_t>::iterator it = points.begin(); it != points.end(); it++) { + for (points_t::iterator it = points.begin(); it != points.end(); it++) { if (it != points.begin()) fprintf(f, ","); (*it).print(f, is6Digit); } + if (op.kind == kind::Line) + if (points[0].x != points[points.size() - 1].x || points[0].y != points[points.size() - 1].y) + points[0].print(f, is6Digit); fprintf(f, "\n"); } +double Element::getArea() const { + const size_t cPoints = points.size (); + if (cPoints <= 2) + return 0; + + double fArea = 0; + for (size_t cPoint = 0; cPoint < cPoints; ++ cPoint) { + const point_t & p0 = points [cPoint]; + const point_t & p1 = points [cPoint + 1 == cPoints ? 0 : cPoint + 1]; + + fArea += (p1.x - p0.x)*(p0.y + p1.y); + } + + return ::fabs (fArea)*.5; +} + +const float c_PI = 3.14159265358979f; + +double Element::getLength () const { + const size_t cPoints = points.size (); + if (cPoints <= 1) + return 0; + + const double fCosY = ::cos (points [0].y*c_PI/180.0); + + double fLength = 0; + for (size_t cPoint = 0; cPoint + 1 < cPoints; ++ cPoint) { + const point_t & p0 = points [cPoint]; + const point_t & p1 = points [cPoint + 1]; + + fLength += ::sqrt ((p1.x - p0.x)*(p1.x - p0.x)*fCosY*fCosY + (p1.y - p0.y)*(p1.y - p0.y)); + } + + return fLength; +} + void point_t::print(FILE *f, bool is6Digits) { if (is6Digits) fprintf(f, "(%.6f,%.6f)", y, x); @@ -466,6 +669,8 @@ throw ParserException(("Unknown variable: " + varName).c_str(), t.lineno()); } + if (rgn.kind == kind::Polygon) + rgn.refreshInners(); map.rgns.push_back(rgn); ttype = t.nextToken(); Index: mp2mp.dsw =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp2mp.dsw,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- mp2mp.dsw 24 Apr 2005 19:59:43 -0000 1.2 +++ mp2mp.dsw 23 Sep 2005 05:10:39 -0000 1.3 @@ -3,6 +3,18 @@ ############################################################################### +Project: "cityupdate"=.\cityupdate.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + Project: "mp2mp"=.\mp2mp.dsp - Package Owner=<4> Package=<5> Index: mp_parser.h =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp_parser.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- mp_parser.h 9 Sep 2005 09:58:54 -0000 1.8 +++ mp_parser.h 23 Sep 2005 05:10:39 -0000 1.9 @@ -2,7 +2,7 @@ #define __MP_PARSER_H__ #include <string> -#include <list> +#include <vector> #include "tokenizer.h" #include "pexcept.h" #include "object.h" @@ -17,17 +17,27 @@ void print(FILE *f, bool is6Digits); }; +typedef std::vector<point_t> points_t; + class Element { public: Element(int _level); + enum StatusType { + INNER, + OUTER + } status; + int level; - std::list<point_t> points; + points_t points; void print(FILE *f, bool is6Digit); void print(FILE *f, const ObjectProp &op, bool is6Digit, unsigned int level); + double getArea() const; + double getLength() const; + bool isHoleOf(const Element &_outer) const; }; -typedef std::list<Element> Elements; +typedef std::vector<Element> Elements; class Attr { public: @@ -37,7 +47,7 @@ void print(FILE *f); }; -typedef std::list<Attr> Attrs; +typedef std::vector<Attr> Attrs; enum BoolType { Unknown, @@ -77,6 +87,10 @@ void print(FILE *f, bool is6Digit); void print(FILE *f, const ObjectProp &op, bool is6Digit); + double getArea() const; + double getLength() const; + bool isHoleOfAny(const Element &_element); + void refreshInners(); }; typedef std::list<Rgn> Rgns; |
From: Denis P. <dy...@us...> - 2005-09-09 09:59:10
|
Update of /cvsroot/cmap/mp2mp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2016 Modified Files: mp_parser.cpp mp_parser.h mpmerge.cpp mpsplit.cpp Log Message: Support comments in the end of file Do not use EndLevel Index: mp_parser.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp_parser.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- mp_parser.cpp 28 Aug 2005 22:23:58 -0000 1.8 +++ mp_parser.cpp 9 Sep 2005 09:58:54 -0000 1.9 @@ -90,38 +90,40 @@ if (op.streetName.length() > 0) fprintf(f, "StreetDesc=%s\n", op.streetName.c_str()); if (op.house.length() > 0) - fprintf(f, "HouseName=%s\n", op.house.c_str()); + fprintf(f, "HouseNumber=%s\n", op.house.c_str()); if (op.direction) fprintf(f, "DirIndicator=1\n"); if (op.city) fprintf(f, "City=Y\n"); if (kind != op.kind && op.kind == kind::Point) { - 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; + unsigned int layerMax = op.layerMax > 0 ? op.layerMax : op.layerMin; + for (unsigned int i = op.layerMin; i <= layerMax; i++) { + 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; - } + 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; + pt.x /= count; + pt.y /= count; - unsigned int layerMax = op.layerMax > 0 ? op.layerMax : op.layerMin; - for (unsigned int i = op.layerMin; i <= layerMax; i++) { fprintf(f, "Data%d=", i); 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); + unsigned int layerMax = op.layerMax > 0 ? op.layerMax : op.layerMin; + for (unsigned int i = op.layerMin; i <= layerMax; i++) + for (std::list<Element>::iterator it2 = elements.begin(); it2 != elements.end(); it2++) + (*it2).print(f, op, is6Digit, i); } fprintf(f, "[END]\n"); fprintf(f, "\n"); @@ -169,17 +171,14 @@ fprintf(f, "\n"); } -void Element::print(FILE *f, const ObjectProp &op, bool is6Digit) { - unsigned int layerMax = op.layerMax > 0 ? op.layerMax : op.layerMin; - for (unsigned int i = op.layerMin; i <= layerMax; i++) { - fprintf(f, "Data%d=", i); - 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 Element::print(FILE *f, const ObjectProp &op, bool is6Digit, unsigned int _level) { + 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, is6Digit); } + fprintf(f, "\n"); } void point_t::print(FILE *f, bool is6Digits) { @@ -399,6 +398,9 @@ rgn.attrs.push_back(a); } // Process region + if (ttype == TT_EOF) + return false; + if (ttype != '[') throw ParserException("'[' expected", t.lineno()); if (t.nextToken() != TT_WORD || (t.sval != "polyline" && t.sval != "polygon" && t.sval != "poi")) Index: mpmerge.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/mpmerge.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- mpmerge.cpp 12 Jun 2005 06:58:32 -0000 1.2 +++ mpmerge.cpp 9 Sep 2005 09:58:54 -0000 1.3 @@ -45,7 +45,7 @@ Tokenizer t(f); - MPParser p(t); + mp::MPParser p(t, filename); try { while (p.parseObject()) @@ -59,8 +59,8 @@ 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; + for (mp::Rgns::iterator it = p.map.rgns.begin(); it != p.map.rgns.end(); it++) { + mp::Rgn &rgn = *it; rgn.print(fo, true); } Index: mp_parser.h =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp_parser.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- mp_parser.h 28 Aug 2005 22:23:58 -0000 1.7 +++ mp_parser.h 9 Sep 2005 09:58:54 -0000 1.8 @@ -24,7 +24,7 @@ int level; std::list<point_t> points; void print(FILE *f, bool is6Digit); - void print(FILE *f, const ObjectProp &op, bool is6Digit); + void print(FILE *f, const ObjectProp &op, bool is6Digit, unsigned int level); }; typedef std::list<Element> Elements; Index: mpsplit.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/mpsplit.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- mpsplit.cpp 24 Apr 2005 19:59:43 -0000 1.1 +++ mpsplit.cpp 9 Sep 2005 09:58:54 -0000 1.2 @@ -17,7 +17,7 @@ Converter() { } - void process(FILE *f); + void process(FILE *f, const char *filename); void readConfig(const char *filename); }; @@ -99,19 +99,19 @@ copyFile(inFile, outFile); } -void Converter::process(FILE *f) { +void Converter::process(FILE *f, const char *filename) { Tokenizer t(f); - MPParser p(t); + mp::MPParser p(t, filename); while (p.parseObject()) ; mkdir("split_tmp"); - for (std::list<Rgn>::iterator iRgn = p.map.rgns.begin(); iRgn != p.map.rgns.end(); iRgn++) { + for (mp::Rgns::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++) + for (mp::Attrs::iterator iAttr = iRgn->attrs.begin(); iAttr != iRgn->attrs.end(); iAttr++) if (iAttr->name == "CODE") code = iAttr->value; if (code.empty()) @@ -238,7 +238,7 @@ } try { - c.process(f); + c.process(f, inFile); } catch (ParserException &x) { fprintf(stderr, "%s:%d: %s\n", inFile, x.lineno(), x.what()); } |
From: Denis P. <dy...@us...> - 2005-08-28 22:24:10
|
Update of /cvsroot/cmap/mp2mp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27212 Modified Files: mp2mp.cpp mp_parser.cpp mp_parser.h object.cpp parserImpl.cpp parserImpl.h Log Message: Support search attrs Index: mp2mp.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp2mp.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- mp2mp.cpp 30 Jun 2005 04:00:17 -0000 1.6 +++ mp2mp.cpp 28 Aug 2005 22:23:58 -0000 1.7 @@ -60,7 +60,7 @@ Tokenizer t(f); - MPParser p(t, filename); + mp::MPParser p(t, filename); try { while (p.parseObject()) @@ -74,8 +74,8 @@ // p.map.printHeader(stdout); ObjectProp op; - for (std::list<Rgn>::iterator it = p.map.rgns.begin(); it != p.map.rgns.end(); it++) { - Rgn &rgn = *it; + for (mp::Rgns::iterator it = p.map.rgns.begin(); it != p.map.rgns.end(); it++) { + mp::Rgn &rgn = *it; if (handle(&rgn, op, 0)) rgn.print(fo, op, true); } Index: mp_parser.h =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp_parser.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- mp_parser.h 30 Jun 2005 04:00:17 -0000 1.6 +++ mp_parser.h 28 Aug 2005 22:23:58 -0000 1.7 @@ -7,6 +7,8 @@ #include "pexcept.h" #include "object.h" +namespace mp { + class point_t { public: double x; @@ -25,6 +27,8 @@ void print(FILE *f, const ObjectProp &op, bool is6Digit); }; +typedef std::list<Element> Elements; + class Attr { public: std::string name; @@ -33,6 +37,8 @@ void print(FILE *f); }; +typedef std::list<Attr> Attrs; + enum BoolType { Unknown, False, @@ -55,11 +61,17 @@ int type; int endLevel; std::string label; - std::list<Attr> attrs; - std::list<Element> elements; + Attrs attrs; + Elements elements; BoolType direction; BoolType city; + std::string countryName; + std::string regionName; + std::string cityName; + std::string streetName; + std::string houseName; + std::string filename; unsigned int line; @@ -67,12 +79,16 @@ void print(FILE *f, const ObjectProp &op, bool is6Digit); }; +typedef std::list<Rgn> Rgns; + class Level { public: int number; int zoom; }; +typedef std::vector<Level> Levels; + class Map { public: Map(); @@ -103,8 +119,8 @@ return false; } - std::list<Rgn> rgns; - std::vector<Level> levels; + Rgns rgns; + Levels levels; }; class MPParser { @@ -127,4 +143,6 @@ Tokenizer &t; }; +}; + #endif Index: parserImpl.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/parserImpl.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- parserImpl.cpp 24 Apr 2005 19:59:43 -0000 1.4 +++ parserImpl.cpp 28 Aug 2005 22:23:58 -0000 1.5 @@ -3,42 +3,9 @@ #include "pexcept.h" #include "mp_parser.h" -class AttrVar : public StringRVar { -public: - AttrVar(const std::string &_name) : name(_name) { - } - - virtual ~AttrVar() { - } - - virtual std::string getValue(const void *obj, const ObjectProp &) { - const Rgn *rgn = (const Rgn *)obj; - for (std::list<Attr>::const_iterator it = rgn->attrs.begin(); it != rgn->attrs.end(); it++) - if ((*it).name == name) - return (*it).value; - - std::string value; - return value; - } -protected: - std::string name; -}; - ConfigParserImpl::ConfigParserImpl(Tokenizer &_t) : ConfigParser(_t) { } -StringRVar *ConfigParserImpl::parseStringRVar(const std::string &varName) { - StringRVar *var = ConfigParser::parseStringRVar(varName); - if (var != NULL) - return var; - if (varName == "attr") { - if (t.nextToken() != TT_STRING) - throw ParserException("Attribute name expected", t.lineno()); - return new AttrVar(t.sval); - } - return NULL; -} - bool ConfigParserImpl::parseObject() { switch (t.nextToken()) { case TT_EOF: Index: parserImpl.h =================================================================== RCS file: /cvsroot/cmap/mp2mp/parserImpl.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- parserImpl.h 7 Nov 2004 13:58:57 -0000 1.1.1.1 +++ parserImpl.h 28 Aug 2005 22:23:58 -0000 1.2 @@ -7,7 +7,6 @@ public: ConfigParserImpl(Tokenizer &_t); - virtual StringRVar *parseStringRVar(const std::string &varName); virtual bool parseObject(); }; Index: object.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/object.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- object.cpp 12 Jun 2005 08:22:11 -0000 1.5 +++ object.cpp 28 Aug 2005 22:23:58 -0000 1.6 @@ -4,11 +4,10 @@ ObjectConfImpl *firstObj = NULL; void ObjectConfImpl::init(const void *obj, ObjectProp &o) { - const Rgn *rgn = (const Rgn *)obj; + const mp::Rgn *rgn = (const mp::Rgn *)obj; - o.index = false; - o.city = (rgn->city == True); - o.direction = (rgn->direction == True); + o.city = (rgn->city == mp::True); + o.direction = (rgn->direction == mp::True); o.garminType = rgn->type; o.layerMin = 0; @@ -16,6 +15,20 @@ o.label = rgn->label; o.kind = rgn->kind; + + o.countryName = rgn->countryName; + o.regionName = rgn->regionName; + o.cityName = rgn->cityName; + o.streetName = rgn->streetName; + o.house = rgn->houseName; + + for (mp::Attrs::const_iterator iAttr = rgn->attrs.begin (); iAttr != rgn->attrs.end (); ++iAttr) { + const mp::Attr &attr = *iAttr; + Attr a; + a.name = attr.name; + a.value = attr.value; + o.attrs.push_back(a); + } } void add(ObjectConfImpl *obj) { Index: mp_parser.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp_parser.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- mp_parser.cpp 30 Jun 2005 04:00:17 -0000 1.7 +++ mp_parser.cpp 28 Aug 2005 22:23:58 -0000 1.8 @@ -1,6 +1,8 @@ #include "mp_parser.h" #include "pexcept.h" +namespace mp { + Map::Map() : preprocess(Unknown), POIIndex(Unknown) { } @@ -58,7 +60,7 @@ void Rgn::print(FILE *f, const ObjectProp &op, bool is6Digit) { fprintf(f, "; LOC=%s:%u\n", filename.c_str(), line); - for (std::list<Attr>::iterator it = attrs.begin(); it != attrs.end(); it++) + for (::Attrs::const_iterator it = op.attrs.begin(); it != op.attrs.end(); it++) (*it).print(f); switch (op.kind) { @@ -75,18 +77,26 @@ fprintf(f, "Type=0x%x\n", op.garminType); - if (op.layerMax != 0) - fprintf(f, "EndLevel=%d\n", op.layerMax); +// if (op.layerMax != 0) +// fprintf(f, "EndLevel=%d\n", op.layerMax); if (op.label.length() > 0) fprintf(f, "Label=%s\n", op.label.c_str()); + if (op.countryName.length() > 0) + fprintf(f, "CountryName=%s\n", op.countryName.c_str()); + if (op.regionName.length() > 0) + fprintf(f, "RegionName=%s\n", op.regionName.c_str()); + if (op.cityName.length() > 0) + fprintf(f, "CityName=%s\n", op.cityName.c_str()); + if (op.streetName.length() > 0) + fprintf(f, "StreetDesc=%s\n", op.streetName.c_str()); + if (op.house.length() > 0) + fprintf(f, "HouseName=%s\n", op.house.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) - throw ParserException("Only polyline and Polygon to Point conversion is supported", 0); + if (kind != op.kind && op.kind == kind::Point) { for (std::list<Element>::iterator it2 = elements.begin(); it2 != elements.end(); it2++) { point_t pt; pt.x = 0.0; @@ -102,9 +112,12 @@ pt.x /= count; pt.y /= count; - fprintf(f, "Data%d=", op.layerMin); - pt.print(f, is6Digit); - fprintf(f, "\n"); + unsigned int layerMax = op.layerMax > 0 ? op.layerMax : op.layerMin; + for (unsigned int i = op.layerMin; i <= layerMax; i++) { + fprintf(f, "Data%d=", i); + pt.print(f, is6Digit); + fprintf(f, "\n"); + } } } else { for (std::list<Element>::iterator it2 = elements.begin(); it2 != elements.end(); it2++) @@ -157,13 +170,16 @@ } 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); + unsigned int layerMax = op.layerMax > 0 ? op.layerMax : op.layerMin; + for (unsigned int i = op.layerMin; i <= layerMax; i++) { + fprintf(f, "Data%d=", i); + 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"); } - fprintf(f, "\n"); } void point_t::print(FILE *f, bool is6Digits) { @@ -417,6 +433,21 @@ if (varName == "label") { t.nextToEOL(true); rgn.label = t.sval; + } else if (varName == "countryname") { + t.nextToEOL(true); + rgn.countryName = t.sval; + } else if (varName == "regionname") { + t.nextToEOL(true); + rgn.regionName = t.sval; + } else if (varName == "cityname") { + t.nextToEOL(true); + rgn.cityName = t.sval; + } else if (varName == "streetdesc") { + t.nextToEOL(true); + rgn.streetName = t.sval; + } else if (varName == "housename") { + t.nextToEOL(true); + rgn.houseName = t.sval; } else if (varName == "endlevel") rgn.endLevel = parseInt(); else if (varName == "type") @@ -449,3 +480,5 @@ // t.printToken(); return false; } + +}; |
From: Denis P. <dy...@us...> - 2005-08-26 03:45:17
|
Update of /cvsroot/cmap/cmap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24495 Modified Files: cmap.cpp Log Message: Change version to 2.0 beta Index: cmap.cpp =================================================================== RCS file: /cvsroot/cmap/cmap/cmap.cpp,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- cmap.cpp 31 Oct 2004 09:06:39 -0000 1.37 +++ cmap.cpp 26 Aug 2005 03:45:08 -0000 1.38 @@ -22,7 +22,7 @@ #include "IngitFile.h" #include "PolishFormat.h" -char cmapVersion[] = "cMap ver. 1.6b"; +char cmapVersion[] = "cMap v. 2.0 beta"; char cmapDescription[] = "Map data converter\n"; char FileMaps[256]; // |
From: Denis P. <dy...@us...> - 2005-08-26 03:35:57
|
Update of /cvsroot/cmap/cmap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23158 Modified Files: PolishFormat.cpp Log Message: Output attributes when -atr is specified in format understandable by mp2mp. Do not output DirIndicator for roads. Index: PolishFormat.cpp =================================================================== RCS file: /cvsroot/cmap/cmap/PolishFormat.cpp,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- PolishFormat.cpp 5 Nov 2004 05:09:42 -0000 1.39 +++ PolishFormat.cpp 26 Aug 2005 03:35:50 -0000 1.40 @@ -484,16 +484,15 @@ // Âûâîä àòðèáóòîâ if (comm_atr != 0) { - fprintf (outIMG, "; %s NUM_OBJ %i %s\n", - obj[NumObj].Cod, NumObj, FileIMG); - fprintf (outIMG, "; "); + fprintf (outIMG, "; CODE=%s\n", obj[NumObj].Cod); + fprintf (outIMG, "; NUM_OBJ=%i\n", NumObj); + fprintf (outIMG, "; FILE=%s\n", FileIMG); for (int i1 = 1; i1 < 100; i1++) { if (obj[NumObj].atr_cod[i1] != 0) { DosToWin(atr_name, (BYTE *)obj[NumObj].atr_cod[i1]); - fprintf (outIMG, "(%i) %s ", i1, atr_name); + fprintf (outIMG, "; X%i=%s\n", i1, atr_name); } } - fprintf (outIMG, "\n"); } if (comm_rus == 0) @@ -649,8 +648,8 @@ fprintf(outIMG, "Label=%s\n", eng_name); } } - if (Type_line >= 0x01 && Type_line <= 0x06) - fprintf (outIMG, "DirIndicator=1\n"); +// if (Type_line >= 0x01 && Type_line <= 0x06) +// fprintf (outIMG, "DirIndicator=1\n"); for (layer = img_Layer_min; layer <= img_Layer_max; layer++) { for (i = 0; i < num_array; i++) { pat_points++; // C÷èòàåì âûâåäåíûå òî÷êè |
From: Denis P. <dy...@us...> - 2005-08-26 03:33:49
|
Update of /cvsroot/cmap/cmap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22906 Modified Files: plan.conf Log Message: Add handling of attr3=T5108 Index: plan.conf =================================================================== RCS file: /cvsroot/cmap/cmap/plan.conf,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- plan.conf 27 May 2004 11:25:48 -0000 1.5 +++ plan.conf 26 Aug 2005 03:33:38 -0000 1.6 @@ -282,6 +282,12 @@ export = false; layer_min = 0; layer_max = 0; + case attr3 = "T5108" { + point = 0x2800; + kind = point; + label = attr1; + export = true; + } } // Âëîæåííàÿ êàðòà object "$C" { |
From: Denis P. <dy...@us...> - 2005-08-22 08:50:35
|
Update of /cvsroot/cmap/libs/eval In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23782 Modified Files: eval.cpp Log Message: Clear attrs on the handle Index: eval.cpp =================================================================== RCS file: /cvsroot/cmap/libs/eval/eval.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- eval.cpp 22 Aug 2005 08:09:43 -0000 1.4 +++ eval.cpp 22 Aug 2005 08:50:27 -0000 1.5 @@ -77,6 +77,7 @@ op.house = ""; op.layerMin = 0; op.layerMin = 0; + op.attrs.clear(); init(obj, op); |
From: Denis P. <dy...@us...> - 2005-08-22 08:49:57
|
Update of /cvsroot/cmap/libs/eval In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23586 Modified Files: evalImpl.h Log Message: Do not show unknown attr warning Index: evalImpl.h =================================================================== RCS file: /cvsroot/cmap/libs/eval/evalImpl.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- evalImpl.h 21 Aug 2005 07:15:18 -0000 1.7 +++ evalImpl.h 22 Aug 2005 08:49:50 -0000 1.8 @@ -102,7 +102,7 @@ if (attr.name == attrName) return attr.value; } - fprintf(stderr, "Unknown attribute: %s\n", attrName.c_str()); +// fprintf(stderr, "Unknown attribute: %s\n", attrName.c_str()); std::string value; return value; } |
From: Denis P. <dy...@us...> - 2005-08-22 08:09:53
|
Update of /cvsroot/cmap/libs/eval In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15076/eval Modified Files: eval.cpp Log Message: Fix ObjectProp init bug Index: eval.cpp =================================================================== RCS file: /cvsroot/cmap/libs/eval/eval.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- eval.cpp 24 Apr 2005 19:59:44 -0000 1.3 +++ eval.cpp 22 Aug 2005 08:09:43 -0000 1.4 @@ -66,6 +66,17 @@ op.typeLine = -1; op.typePoly = -1; op.doExport = true; + op.city = false; + op.direction = false; + op.index = false; + op.label = ""; + op.countryName = ""; + op.regionName = ""; + op.cityName = ""; + op.streetName = ""; + op.house = ""; + op.layerMin = 0; + op.layerMin = 0; init(obj, op); |
From: Denis P. <dy...@us...> - 2005-08-22 08:09:53
|
Update of /cvsroot/cmap/shp2mp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15076 Modified Files: object.cpp Log Message: Fix ObjectProp init bug Index: object.cpp =================================================================== RCS file: /cvsroot/cmap/shp2mp/object.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- object.cpp 19 Aug 2005 18:43:21 -0000 1.2 +++ object.cpp 22 Aug 2005 08:09:43 -0000 1.3 @@ -21,15 +21,10 @@ void ObjectConfImpl::init(const void *obj, ObjectProp &o) { const Object *object = (const Object *)obj; - o.index = false; o.doExport = false; - o.city = 0; o.garminType = 0; - o.layerMin = 0; - o.layerMax = 0; - //HACK until everything is cleaned out o.typePoint = 0; o.typeLine = 0; |