cmap-cvs Mailing List for cmap (Page 8)
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...> - 2005-08-21 07:15:26
|
Update of /cvsroot/cmap/libs/eval In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28949 Modified Files: eval.h evalImpl.h parser.cpp Log Message: Process address attributes Index: parser.cpp =================================================================== RCS file: /cvsroot/cmap/libs/eval/parser.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- parser.cpp 19 Aug 2005 18:42:23 -0000 1.7 +++ parser.cpp 21 Aug 2005 07:15:18 -0000 1.8 @@ -54,6 +54,16 @@ StringLVar *ConfigParser::parseStringLVar(const std::string &varName) { if (varName == "label") return new LabelLVar(); + if (varName == "countryname") + return new CountryNameLVar(); + if (varName == "regionname") + return new RegionNameLVar(); + if (varName == "cityname") + return new CityNameLVar(); + if (varName == "streetname") + return new StreetNameLVar(); + if (varName == "house") + return new HouseLVar(); 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.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- evalImpl.h 19 Aug 2005 18:42:23 -0000 1.6 +++ evalImpl.h 21 Aug 2005 07:15:18 -0000 1.7 @@ -38,6 +38,56 @@ } }; +class CountryNameLVar : public StringLVar { + virtual std::string getValue(const void *, const ObjectProp &op) { + return op.countryName; + } + + virtual void setValue(ObjectProp &op, const std::string &value) { + op.countryName = value; + } +}; + +class RegionNameLVar : public StringLVar { + virtual std::string getValue(const void *, const ObjectProp &op) { + return op.regionName; + } + + virtual void setValue(ObjectProp &op, const std::string &value) { + op.regionName = value; + } +}; + +class CityNameLVar : public StringLVar { + virtual std::string getValue(const void *, const ObjectProp &op) { + return op.cityName; + } + + virtual void setValue(ObjectProp &op, const std::string &value) { + op.cityName = value; + } +}; + +class StreetNameLVar : public StringLVar { + virtual std::string getValue(const void *, const ObjectProp &op) { + return op.streetName; + } + + virtual void setValue(ObjectProp &op, const std::string &value) { + op.streetName = value; + } +}; + +class HouseLVar : public StringLVar { + virtual std::string getValue(const void *, const ObjectProp &op) { + return op.house; + } + + virtual void setValue(ObjectProp &op, const std::string &value) { + op.house = value; + } +}; + class StringAttrVar : public StringLVar { public: StringAttrVar(const std::string &_attrName) : attrName(_attrName) { Index: eval.h =================================================================== RCS file: /cvsroot/cmap/libs/eval/eval.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- eval.h 19 Aug 2005 18:42:23 -0000 1.4 +++ eval.h 21 Aug 2005 07:15:18 -0000 1.5 @@ -44,6 +44,12 @@ std::string label; + std::string countryName; + std::string regionName; + std::string cityName; + std::string streetName; + std::string house; + Kind kind; //HACK until everything is cleaned out |
From: Denis P. <dy...@us...> - 2005-08-21 07:14:19
|
Update of /cvsroot/cmap/shp2mp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28648 Modified Files: shp2mp.cpp Log Message: Output new attrs Index: shp2mp.cpp =================================================================== RCS file: /cvsroot/cmap/shp2mp/shp2mp.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- shp2mp.cpp 19 Aug 2005 18:43:21 -0000 1.2 +++ shp2mp.cpp 21 Aug 2005 07:14:10 -0000 1.3 @@ -71,6 +71,16 @@ fprintf(f, "Type=0x%x\n", op.garminType); if (op.label.c_str() != NULL && *op.label.c_str() != 0) fprintf(f, "Label=%s\n", op.label.c_str()); + if (op.countryName.c_str() != NULL && *op.countryName.c_str() != 0) + fprintf(f, "CountryName=%s\n", op.countryName.c_str()); + if (op.regionName.c_str() != NULL && *op.regionName.c_str() != 0) + fprintf(f, "RegionName=%s\n", op.regionName.c_str()); + if (op.cityName.c_str() != NULL && *op.cityName.c_str() != 0) + fprintf(f, "CityName=%s\n", op.cityName.c_str()); + if (op.streetName.c_str() != NULL && *op.streetName.c_str() != 0) + fprintf(f, "StreetDesc=%s\n", op.streetName.c_str()); + if (op.house.c_str() != NULL && *op.house.c_str() != 0) + fprintf(f, "HouseNumber=%s\n", op.house.c_str()); if (op.layerMax > op.layerMin) fprintf(f, "EndLevel=%d\n", op.layerMax); fprintf(f, "Data%d=", op.layerMin); @@ -116,6 +126,16 @@ fprintf(f, "Type=0x%x\n", op.garminType); if (op.label.c_str() != NULL && *op.label.c_str() != 0) fprintf(f, "Label=%s\n", op.label.c_str()); + if (op.countryName.c_str() != NULL && *op.countryName.c_str() != 0) + fprintf(f, "CountryName=%s\n", op.countryName.c_str()); + if (op.regionName.c_str() != NULL && *op.regionName.c_str() != 0) + fprintf(f, "RegionName=%s\n", op.regionName.c_str()); + if (op.cityName.c_str() != NULL && *op.cityName.c_str() != 0) + fprintf(f, "CityName=%s\n", op.cityName.c_str()); + if (op.streetName.c_str() != NULL && *op.streetName.c_str() != 0) + fprintf(f, "StreetDesc=%s\n", op.streetName.c_str()); + if (op.house.c_str() != NULL && *op.house.c_str() != 0) + fprintf(f, "HouseNumber=%s\n", op.house.c_str()); if (op.layerMax > op.layerMin) fprintf(f, "EndLevel=%d\n", op.layerMax); @@ -370,6 +390,16 @@ fprintf(f, "Type=0x%x\n", op.garminType); if (op.label.c_str() != NULL && *op.label.c_str() != 0) fprintf(f, "Label=%s\n", op.label.c_str()); + if (op.countryName.c_str() != NULL && *op.countryName.c_str() != 0) + fprintf(f, "CountryName=%s\n", op.countryName.c_str()); + if (op.regionName.c_str() != NULL && *op.regionName.c_str() != 0) + fprintf(f, "RegionName=%s\n", op.regionName.c_str()); + if (op.cityName.c_str() != NULL && *op.cityName.c_str() != 0) + fprintf(f, "CityName=%s\n", op.cityName.c_str()); + if (op.streetName.c_str() != NULL && *op.streetName.c_str() != 0) + fprintf(f, "StreetDesc=%s\n", op.streetName.c_str()); + if (op.house.c_str() != NULL && *op.house.c_str() != 0) + fprintf(f, "HouseNumber=%s\n", op.house.c_str()); if (op.layerMax > op.layerMin) fprintf(f, "EndLevel=%d\n", op.layerMax); fprintf(f, "Data%d=", op.layerMin); @@ -397,6 +427,16 @@ fprintf(f, "Type=0x%x\n", op.garminType); if (op.label.c_str() != NULL && *op.label.c_str() != 0) fprintf(f, "Label=%s\n", op.label.c_str()); + if (op.countryName.c_str() != NULL && *op.countryName.c_str() != 0) + fprintf(f, "CountryName=%s\n", op.countryName.c_str()); + if (op.regionName.c_str() != NULL && *op.regionName.c_str() != 0) + fprintf(f, "RegionName=%s\n", op.regionName.c_str()); + if (op.cityName.c_str() != NULL && *op.cityName.c_str() != 0) + fprintf(f, "CityName=%s\n", op.cityName.c_str()); + if (op.streetName.c_str() != NULL && *op.streetName.c_str() != 0) + fprintf(f, "StreetDesc=%s\n", op.streetName.c_str()); + if (op.house.c_str() != NULL && *op.house.c_str() != 0) + fprintf(f, "HouseNumber=%s\n", op.house.c_str()); if (op.layerMax > op.layerMin) fprintf(f, "EndLevel=%d\n", op.layerMax); |
From: Denis P. <dy...@us...> - 2005-08-19 18:46:06
|
Update of /cvsroot/cmap/shp2mp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1875 Added Files: tr.h tr.cpp Log Message: Add projection conversion code --- NEW FILE: tr.h --- #ifndef __TR_H__ #define __TR_H__ const double c_PI = 3.14159265358979; class dpoint_t { public: dpoint_t () : x(0.0), y(0.0) {}; dpoint_t (double _x, double _y) : x(_x), y(_y) {}; double x; double y; }; struct CEllipsoid { const char *strName; // The semi-major axis. const double a; // The flattening. const double f; // The eccentricity^2. const double e2; const double e1, ee2; CEllipsoid (const char *_strName, double _a, double _f); }; class CTransformationBase { public: virtual void ApplyTo (dpoint_t & _point) const = 0; }; class CMolodensky_To_WGS84 : public CTransformationBase { public: CMolodensky_To_WGS84 (const CEllipsoid & _SourceEllipsoid, double _fDX, double _fDY, double _fDZ, double _fElevation = 0); virtual void ApplyTo (dpoint_t & _point) const; protected: // The source ellipsoid. const CEllipsoid e; // The linear shifts, in meters. const double dx, dy, dz; // The average and difference of semin-major axes. const double a, da; // The average and difference of eccentricities. const double e2, de2; const double fElevation; }; class CHelmert_To_WGS84 : public CMolodensky_To_WGS84 { public: CHelmert_To_WGS84 ( const CEllipsoid & _SourceEllipsoid, double _fDX, double _fDY, double _fDZ, double _fWX, double _fWY, double _fWZ, double _fMS, double _fElevation = 0 ); virtual void ApplyTo (dpoint_t & _point) const; protected: // The angles between axis, in arc seconds. const double wx, wy, wz; // The scales difference. const double ms; }; class CPulkovo42_To_WGS84 : public CHelmert_To_WGS84 { public: CPulkovo42_To_WGS84 (double _fElevation = 0); }; class CTransverseMercator : public CTransformationBase { public: CTransverseMercator (const CEllipsoid & _e, double _k0, double _FE, double _FN, double _x0, double _y0); virtual void ApplyTo (dpoint_t & _point) const; private: const CEllipsoid m_Ellipsoid; // The scale factor. const double m_k0; // False Easting & Northing. const double m_FE, m_FN; // Longitude of the natural origin. const double m_x0; // Some parameter depending on the latitude of the natural origin. const double m_M0; }; extern const CEllipsoid c_eKrasovsky1940; extern const CEllipsoid c_eWGS84; #endif --- NEW FILE: tr.cpp --- #include <math.h> #include "tr.h" // Arc seconds per radian. const double c_ro = 206264.8062; const CEllipsoid c_eKrasovsky1940 ("Krasovsky 1940", 6378245.0, 1/298.3); const CEllipsoid c_eWGS84 ("WGS 84", 6378137.0, 1/298.257223563); CEllipsoid::CEllipsoid (const char *_strName, double _a, double _f) : strName (_strName), a (_a), f (_f), e2 (2*_f - _f*_f), e1 ((1 - ::sqrt (1 - e2))/(1 + ::sqrt (1 - e2))), ee2 (e2/(1 - e2)) {} CMolodensky_To_WGS84::CMolodensky_To_WGS84 ( const CEllipsoid & _SourceEllipsoid, double _fDX, double _fDY, double _fDZ, double _fElevation ) : e (_SourceEllipsoid), dx (_fDX), dy (_fDY), dz (_fDZ), fElevation (_fElevation), a ((_SourceEllipsoid.a + c_eWGS84.a)/2), e2 ((_SourceEllipsoid.e2 + c_eWGS84.e2)/2), da (c_eWGS84.a - _SourceEllipsoid.a), de2 (c_eWGS84.e2 - _SourceEllipsoid.e2) { } void CMolodensky_To_WGS84::ApplyTo (dpoint_t & _point) const { const double & Ld = _point.x; const double & Bd = _point.y; const double B = Bd*c_PI/180; const double L = Ld*c_PI/180; const double fSinB = ::sin (B); const double fCosB = ::cos (B); const double fSinL = ::sin (L); const double fCosL = ::cos (L); const double fNu = 1 - e2*fSinB*fSinB; const double fSqrtNu = ::sqrt (fNu); const double M = a*(1 - e2)/(fNu*fSqrtNu); const double N = a/fSqrtNu; // // Latitude. // const double dB = c_ro/(M + fElevation)*( N/a*e2*fSinB*fCosB*da + (N*N/(a*a) + 1)*N*fSinB*fCosB*de2/2 - (dx*fCosL + dy*fSinL)*fSinB + dz*fCosB ); const double fWGS84Lat = Bd + dB/3600; // // Longitude. // const double dL = c_ro/((N + fElevation)*fCosB)*(-dx*fSinL + dy*fCosL); const double fWGS84Long = Ld + dL/3600; _point.x = fWGS84Long; _point.y = fWGS84Lat; } /////////////////////////////////////////////////////// CHelmert_To_WGS84::CHelmert_To_WGS84 ( const CEllipsoid & _SourceEllipsoid, double _fDX, double _fDY, double _fDZ, double _fWX, double _fWY, double _fWZ, double _fMS, double _fElevation ) : CMolodensky_To_WGS84 (_SourceEllipsoid, _fDX, _fDY, _fDZ, _fElevation), wx (_fWX), wy (_fWY), wz (_fWZ), ms (_fMS) {} void CHelmert_To_WGS84::ApplyTo (dpoint_t & _point) const { const double & Ld = _point.x; const double & Bd = _point.y; const double B = Bd*c_PI/180; const double L = Ld*c_PI/180; const double fSinB = ::sin (B); const double fCosB = ::cos (B); const double fTanB = fSinB/fCosB; const double fCos2B = 2*fCosB*fCosB - 1; const double fSinL = ::sin (L); const double fCosL = ::cos (L); const double fNu = 1 - e2*fSinB*fSinB; const double fSqrtNu = ::sqrt (fNu); const double M = a*(1 - e2)/(fNu*fSqrtNu); const double N = a/fSqrtNu; // // Latitude. // const double dB = c_ro/(M + fElevation)*( N/a*e2*fSinB*fCosB*da + (N*N/(a*a) + 1)*N*fSinB*fCosB*de2/2 - (dx*fCosL + dy*fSinL)*fSinB + dz*fCosB ) - wx*fSinL*(1 + e2*fCos2B) + wy*fCosL*(1 + e2*fCos2B) - c_ro*ms*e2*fSinB*fCosB; const double fWGS84Lat = Bd + dB/3600; // // Longitude. // const double dL = c_ro/((N + fElevation)*fCosB)*(-dx*fSinL + dy*fCosL) + fTanB*(1 - e2)*(wx*fCosL + wy*fSinL) - wz; const double fWGS84Long = Ld + dL/3600; /* // // Elevation. // const double dH = -a/N*da + N*fSinB*fSinB*c_de2/2 + (dx*fCosL + dy*fSinL)*fCosB + dz*fSinB - N*e2*fSinB*fCosB*(wx/c_ro*fSinL - wy/c_ro*fCosL) + (a*a/N + _fElevation)*ms; const double fWGS84Elevation = fElevation + dH; */ _point.x = fWGS84Long; _point.y = fWGS84Lat; } /////////////////////////////////////////////// // Based on the GOST R 51794-2001 of Russian Federation CPulkovo42_To_WGS84::CPulkovo42_To_WGS84 (double _fElevation) : CHelmert_To_WGS84 ( c_eKrasovsky1940, 23.92f, -141.27f, -80.9f, 0, -0.35f, -0.82f, -0.12e-6f, _fElevation ) {} // // Translate from TM grid (meters) to latitude/longitude degrees. // The formula is given from http://posc.org/Epicentre.2_2/DataModel/ExamplesofUsage/eu_cs34h.html // static void TM2LL (const CEllipsoid & _e, double _k0, double _FE, double _FN, double _x0, double _M0, double _x, double _y, dpoint_t & _p) { const double M1 = _M0 + (_y - _FN)/_k0; const double mu1 = M1/(_e.a*(1 - _e.e2*(1./4 + _e.e2*(3./64 + 5./256*_e.e2)))); const double fSin2Mu1 = ::sin (2*mu1); const double fCos2Mu1 = ::cos (2*mu1); const double e1_2 = _e.e1*_e.e1; const double e1_3 = e1_2*_e.e1; const double fi1 = mu1 + _e.e1*fSin2Mu1*( ( 3./2 - 27./32*e1_2) + (21./16*_e.e1 - 55./32*e1_3)*2*fCos2Mu1 + ( 151./96*e1_2)*(3 - 4*fSin2Mu1*fSin2Mu1) + ( 1097./512*e1_3)*4*fCos2Mu1*(1 - 2*fSin2Mu1*fSin2Mu1) ); const double fSinFi1 = ::sin (fi1); const double fCosFi1 = ::cos (fi1); const double fTanFi1 = fSinFi1/fCosFi1; const double fEFi = 1 - _e.e2*fSinFi1*fSinFi1; const double fSqrtEFi2 = ::sqrt (fEFi); const double D = (_x - _FE)*fSqrtEFi2/(_e.a*_k0); const double D2 = D*D; const double T1 = fTanFi1*fTanFi1; const double C1 = _e.ee2*fCosFi1*fCosFi1; const double fLat = fi1 - fEFi*fTanFi1/(1 - _e.e2)*D2*( 1./2 + D2*( - (5 + 3*T1 + C1*(10 - 4*C1) - 9*_e.ee2)/24 + (61 + T1*(90 + 45*T1) + C1*(298 - 3*C1) - 252*_e.ee2)*D2/720 ) ); const double fLon = D*( 1 + D2*( - (1 + 2*T1 + C1)/6 + (5 - C1*(2 + 3*C1) + T1*(28 + 24*T1) + 8*_e.ee2)*D2/120 ) )/fCosFi1; _p.y = fLat*(180/c_PI); _p.x = fLon*(180/c_PI) + _x0; } static double GetM0 (const CEllipsoid & _e, double _y0) { const double fi = _y0*c_PI/180; return _e.a*( (1 - _e.e2/4 - 3*_e.e2*_e.e2/64 - 5*_e.e2*_e.e2*_e.e2/256)*fi - ( 3*_e.e2/8 + 3*_e.e2*_e.e2/32 + 45*_e.e2*_e.e2*_e.e2/1024)*::sin (2*fi) + ( 15*_e.e2*_e.e2/256 + 45*_e.e2*_e.e2*_e.e2/1024)*::sin (4*fi) - ( 35*_e.e2*_e.e2*_e.e2/3072)*::sin (6*fi) ); } CTransverseMercator::CTransverseMercator (const CEllipsoid & _e, double _k0, double _FE, double _FN, double _x0, double _y0) : m_Ellipsoid (_e), m_k0 (_k0), m_FE (_FE), m_FN (_FN), m_x0 (_x0), m_M0 (GetM0 (_e, _y0)) {} void CTransverseMercator::ApplyTo (dpoint_t & _point) const { TM2LL (m_Ellipsoid, m_k0, m_FE, m_FN, m_x0, m_M0, _point.x, _point.y, _point); } |
From: Denis P. <dy...@us...> - 2005-08-19 18:43:30
|
Update of /cvsroot/cmap/shp2mp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1214 Modified Files: object.cpp object.h shp2mp.cpp shp2mp.dsp split.cpp Log Message: Update code for the latest eval. Honor projection. Allow to set attrs. Index: split.cpp =================================================================== RCS file: /cvsroot/cmap/shp2mp/split.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- split.cpp 7 Nov 2004 14:06:46 -0000 1.1.1.1 +++ split.cpp 19 Aug 2005 18:43:21 -0000 1.2 @@ -16,9 +16,13 @@ FILE *prepareFile(int X, int Y) { int zone = 30 + X / 2 + 1; int line = Y / 2; + struct stat st; + if (::stat("cvs", &st) != 0) { + mkdir("cvs"); + } + char dirName[1024]; sprintf(dirName, "cvs\\%c-%d-%d", 'A' + line, zone, X % 2 + ((Y + 1) % 2) * 2 + 1); - struct stat st; if (::stat(dirName, &st) != 0) { mkdir(dirName); } @@ -31,6 +35,10 @@ FILE *fo = fopen(name, "rt"); if (fo == NULL) { fo = fopen(name, "wt"); + if (fo == NULL) { + fprintf(stderr, "Can not open file '%s'\n", name); + exit(1); + } FILE *inHead = fopen("header.txt", "r"); int buf_header; assert(inHead != NULL); @@ -63,7 +71,7 @@ printf("; isHole = %s\n", (*it2).isHole ? "true" : "false"); for (points_t::iterator it3 = orig.begin(); it3 != orig.end(); it3++) { point_t p2 = *it3; - printf("; %.5f, %.5f\n", p2.y, p2.x); + printf("; %.6f, %.6f\n", p2.y, p2.x); } printf("; }\n"); } @@ -77,7 +85,7 @@ printf("; %s\n", msg); for (points_t::iterator it2 = p.begin(); it2 != p.end(); it2++) { point_t p2 = *it2; - printf("; %.5f, %.5f\n", p2.y, p2.x); + printf("; %.6f, %.6f\n", p2.y, p2.x); } #endif } @@ -85,7 +93,7 @@ void printPoint(point_t &p, const char *msg) { #ifdef DEBUG printf("; %s\n", msg); - printf("; (%.5f, %.5f)\n", p.y, p.x); + printf("; (%.6f, %.6f)\n", p.y, p.x); #endif } @@ -109,9 +117,9 @@ for (points_t::iterator it3 = orig.begin(); it3 != orig.end(); it3++) { point_t p2 = *it3; if (it3 == orig.begin()) - fprintf(f, "(%.5f, %.5f)", p2.y, p2.x); + fprintf(f, "(%.6f,%.6f)", p2.y, p2.x); else - fprintf(f, ",(%.5f, %.5f)", p2.y, p2.x); + fprintf(f, ",(%.6f,%.6f)", p2.y, p2.x); } fprintf(f, "\n"); } @@ -199,7 +207,7 @@ polygons_t::iterator pe = result.end(); float X = i * fXStep; #ifdef DEBUG - printf("; CutX = %.5f, i = %d\n", X, i); + printf("; CutX = %.6f, i = %d\n", X, i); #endif for (polygons_t::iterator inIt = in.begin(); inIt != in.end(); inIt++) { #ifdef DEBUG @@ -500,7 +508,7 @@ polygons_t::iterator pe = result.end(); float Y = i * fYStep; #ifdef DEBUG - printf("; CutY = %.5f, i = %d\n", Y, i); + printf("; CutY = %.6f, i = %d\n", Y, i); #endif for (polygons_t::iterator inIt = in.begin(); inIt != in.end(); inIt++) { #ifdef DEBUG @@ -850,7 +858,7 @@ polygons_t::iterator pe = result.end(); float X = i * fXStep; #ifdef DEBUG - printf("; CutX = %.5f, i = %d\n", X, i); + printf("; CutX = %.6f, i = %d\n", X, i); #endif for (polygons_t::iterator inIt = in.begin(); inIt != in.end(); inIt++) { rgn_t &rgn = *inIt; @@ -961,7 +969,7 @@ polygons_t::iterator pe = result.end(); float Y = i * fYStep; #ifdef DEBUG - printf("; CutY = %.5f, i = %d\n", Y, i); + printf("; CutY = %.6f, i = %d\n", Y, i); #endif for (polygons_t::iterator inIt = in.begin(); inIt != in.end(); inIt++) { rgn_t &rgn = *inIt; @@ -1209,7 +1217,7 @@ fprintf(f, "Type=0x%x\n", op.garminType); if (op.label.c_str() != NULL && *op.label.c_str() != 0) fprintf(f, "Label=%s\n", op.label.c_str()); - fprintf(f, "Data0=(%.5f, %.5f)\n", y, x); + fprintf(f, "Data0=(%.6f,%.6f)\n", y, x); fprintf(f, "[END]\n"); fprintf(f, "\n"); } @@ -1222,4 +1230,3 @@ outputPoint(fo, x, y, o, op); fclose(fo); } - Index: object.cpp =================================================================== RCS file: /cvsroot/cmap/shp2mp/object.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- object.cpp 7 Nov 2004 14:06:42 -0000 1.1.1.1 +++ object.cpp 19 Aug 2005 18:43:21 -0000 1.2 @@ -1,3 +1,5 @@ +#include <math.h> + #include "object.h" /* @@ -19,6 +21,20 @@ 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; + o.typePoly = 0; + switch (object->shpType) { case shpNull: assert(false); @@ -46,4 +62,63 @@ default: assert(false); } + + o.attrs.clear(); + + size_t fieldCount = object->dbf->GetFields(); + for (size_t i = 0; i < fieldCount; i++) { + const char *lStart = object->dbf->GetRawField(object->cRecordCounter, i); + size_t lLen = object->dbf->GetFieldLength(i); + while (*lStart == ' ' && lLen > 0) { + lStart++; + lLen--; + } + while (lStart[lLen - 1] == ' ' && lLen > 0) + lLen--; + Attr a; + a.name = object->dbf->GetFieldName(i); + a.value = std::string(lStart, lLen); + o.attrs.push_back(a); + } } + +void ObjectConfImpl::setProjection(const std::string &_projection) { + projection = _projection; + const CEllipsoid *Ellipsoid; + if (projection.substr(0, 2) == "GK") { + Ellipsoid = &c_eKrasovsky1940; + int zone = strtol(projection.substr(2).c_str(), NULL, 10); + double fCustomX = zone * 6 - 3; + double fFE = zone * 1000000 + 500000.0; + double fFN = 0.0; + + tr1 = new CTransverseMercator (*Ellipsoid, 1, fFE, fFN, fCustomX, 0); + tr2 = new CPulkovo42_To_WGS84(0); + } else if (projection == "WGS84") { + Ellipsoid = &c_eWGS84; + tr1 = NULL; + tr2 = NULL; + } else if (projection == "Pulkovo1942") { + Ellipsoid = &c_eKrasovsky1940; + tr1 = NULL; + tr2 = new CPulkovo42_To_WGS84(0); + } else { + fprintf(stderr, "Unknown projection: %s\nAssuming WGS84\n", projection.c_str()); + projection = "WGS84"; + Ellipsoid = &c_eWGS84; + tr1 = NULL; + tr2 = NULL; + } +} + +void ObjectConfImpl::printPoint(FILE *f, double y, double x) { + dpoint_t pt; + pt.x = x; + pt.y = y; + if (tr1 != NULL) + tr1->ApplyTo(pt); + if (tr2 != NULL) + tr2->ApplyTo(pt); + fprintf(f, "(%.6f,%.6f)", pt.y, pt.x); +} + Index: object.h =================================================================== RCS file: /cvsroot/cmap/shp2mp/object.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- object.h 7 Nov 2004 14:06:42 -0000 1.1.1.1 +++ object.h 19 Aug 2005 18:43:21 -0000 1.2 @@ -8,6 +8,7 @@ #include "ShpFile.h" #include "DbfFile.h" +#include "tr.h" class Object { public: @@ -33,9 +34,15 @@ void ParseMultiPatch (const CShpMultiPatch * const _pMultiPatch); void createPOI(FILE *f, const CShpPolygon * const _pPolygon, Object &o, const ObjectProp &op); - void printHoles(FILE *f, const CShpPolygon * const _pPolygon, const CShpPointData * const pPoints1, const size_t cPoints1); + void printHoles(FILE *f, const CShpPolygon * const _pPolygon, const CShpPointData * const pPoints1, const size_t cPoints1, const ObjectProp &op); + void printPoint(FILE *f, double y, double x); + + void setProjection(const std::string &_projection); protected: std::string filename; + std::string projection; + CTransformationBase *tr1; + CTransformationBase *tr2; }; #endif Index: shp2mp.dsp =================================================================== RCS file: /cvsroot/cmap/shp2mp/shp2mp.dsp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- shp2mp.dsp 7 Nov 2004 14:06:45 -0000 1.1.1.1 +++ shp2mp.dsp 19 Aug 2005 18:43:21 -0000 1.2 @@ -105,6 +105,10 @@ # End Source File # Begin Source File +SOURCE=.\eval\pexcept.cpp +# End Source File +# Begin Source File + SOURCE=.\shp2mp.cpp # End Source File # Begin Source File @@ -115,6 +119,10 @@ SOURCE=.\eval\tokenizer.cpp # End Source File +# Begin Source File + +SOURCE=.\tr.cpp +# End Source File # End Group # Begin Group "Header Files" @@ -145,6 +153,10 @@ # End Source File # Begin Source File +SOURCE=.\eval\pexcept.h +# End Source File +# Begin Source File + SOURCE=.\ShpFile.h # End Source File # Begin Source File @@ -161,6 +173,10 @@ # End Source File # Begin Source File +SOURCE=.\tr.h +# End Source File +# Begin Source File + SOURCE=.\Wrappers.h # End Source File # End Group Index: shp2mp.cpp =================================================================== RCS file: /cvsroot/cmap/shp2mp/shp2mp.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- shp2mp.cpp 7 Nov 2004 14:06:45 -0000 1.1.1.1 +++ shp2mp.cpp 19 Aug 2005 18:43:21 -0000 1.2 @@ -8,6 +8,7 @@ #include "DbfFile.h" #include "tokenizer.h" #include "parser.h" +#include "pexcept.h" #include "object.h" #include "split.h" @@ -16,8 +17,8 @@ // Convert big-endian DWORD to low-endian one. inline DWORD Big2LowEndian (DWORD _dw) { - const BYTE * const ba = reinterpret_cast<BYTE *> (& _dw); - return (ba [0] << 24) + (ba [1] << 16) + (ba [2] << 8) + ba [3]; + const BYTE * const ba = reinterpret_cast<BYTE *> (& _dw); + return (ba [0] << 24) + (ba [1] << 16) + (ba [2] << 8) + ba [3]; } ObjectConfImpl *firstObj = NULL; @@ -70,7 +71,11 @@ fprintf(f, "Type=0x%x\n", op.garminType); if (op.label.c_str() != NULL && *op.label.c_str() != 0) fprintf(f, "Label=%s\n", op.label.c_str()); - fprintf(f, "Data0=(%.5f,%.5f)\n", _pPoint->point.dY, _pPoint->point.dX); + if (op.layerMax > op.layerMin) + fprintf(f, "EndLevel=%d\n", op.layerMax); + fprintf(f, "Data%d=", op.layerMin); + printPoint(f, _pPoint->point.dY, _pPoint->point.dX); + fprintf(f, "\n"); fprintf(f, "[END]\n"); fprintf(f, "\n"); } @@ -111,6 +116,8 @@ fprintf(f, "Type=0x%x\n", op.garminType); if (op.label.c_str() != NULL && *op.label.c_str() != 0) fprintf(f, "Label=%s\n", op.label.c_str()); + if (op.layerMax > op.layerMin) + fprintf(f, "EndLevel=%d\n", op.layerMax); size_t cPointIndex = 0; const CShpPointData * const pPoints = reinterpret_cast<const CShpPointData *> (_pPolyline->dwaParts + _pPolyline->dwNumParts); @@ -121,11 +128,11 @@ const size_t cPoints = cElement < cElements - 1 ? _pPolyline->dwaParts [cElement + 1] - _pPolyline->dwaParts [cElement] : _pPolyline->dwNumPoints - _pPolyline->dwaParts [cElement]; - for (size_t cPoint = 0; cPoint < cPoints; ++ cPoint, ++ cPointIndex) - if (cPoint == 0) - fprintf(f, "(%.5f,%.5f)", static_cast<float> (pPoints [cPointIndex].dY), static_cast<float> (pPoints [cPointIndex].dX)); - else - fprintf(f, ",(%.5f,%.5f)", static_cast<float> (pPoints [cPointIndex].dY), static_cast<float> (pPoints [cPointIndex].dX)); + for (size_t cPoint = 0; cPoint < cPoints; ++ cPoint, ++ cPointIndex) { + if (cPoint != 0) + fprintf(f, ","); + printPoint(f, static_cast<float> (pPoints [cPointIndex].dY), static_cast<float> (pPoints [cPointIndex].dX)); + } fprintf(f, "\n"); } assert (cPointIndex == _pPolyline->dwNumPoints); @@ -171,14 +178,14 @@ size_t cPoint0 = cPoint - 1; while (cPoint0 >= cPoints) cPoint0 -= cPoints; - float y0 = static_cast<float> (pPoints [cPoint0].dY); - float x0 = static_cast<float> (pPoints [cPoint0].dX); + float y0 = static_cast<float> (pPoints [cPoint0].dY); + float x0 = static_cast<float> (pPoints [cPoint0].dX); // Get the second point of chain. while (cPoint >= cPoints) cPoint -= cPoints; - float y1 = static_cast<float> (pPoints [cPoint].dY); - float x1 = static_cast<float> (pPoints [cPoint].dX); + float y1 = static_cast<float> (pPoints [cPoint].dY); + float x1 = static_cast<float> (pPoints [cPoint].dX); if (x0 == x1 && y0 == y1) { // Infinite loop protection. @@ -288,16 +295,16 @@ _pPolygon->dwaParts [cElement + 1] - _pPolygon->dwaParts [cElement] - 1: _pPolygon->dwNumPoints - _pPolygon->dwaParts [cElement] - 1; - if (pPoints1 != (pPoints + cPointIndex)) - if (isHoleOf(pPoints1, cPoints1, pPoints + cPointIndex, cPoints)) - return true; - cPointIndex += cPoints; - cPointIndex++; + if (pPoints1 != (pPoints + cPointIndex)) + if (isHoleOf(pPoints1, cPoints1, pPoints + cPointIndex, cPoints)) + return true; + cPointIndex += cPoints; + cPointIndex++; } - return false; + return false; } -void ObjectConfImpl::printHoles(FILE *f, const CShpPolygon * const _pPolygon, const CShpPointData * const pPoints1, const size_t cPoints1) { +void ObjectConfImpl::printHoles(FILE *f, const CShpPolygon * const _pPolygon, const CShpPointData * const pPoints1, const size_t cPoints1, const ObjectProp &op) { size_t cPointIndex = 0; const CShpPointData * const pPoints = reinterpret_cast<const CShpPointData *> (_pPolygon->dwaParts + _pPolygon->dwNumParts); @@ -310,12 +317,12 @@ if (pPoints1 != (pPoints + cPointIndex)) if (isHoleOf(pPoints + cPointIndex, cPoints, pPoints1, cPoints1)) { - fprintf(f, "Data0="); - for (size_t cPoint = 0; cPoint < cPoints; ++ cPoint, ++ cPointIndex) - if (cPoint == 0) - fprintf(f, "(%.5f,%.5f)", static_cast<float> (pPoints [cPointIndex].dY), static_cast<float> (pPoints [cPointIndex].dX)); - else - fprintf(f, ",(%.5f,%.5f)", static_cast<float> (pPoints [cPointIndex].dY), static_cast<float> (pPoints [cPointIndex].dX)); + fprintf(f, "Data%d=", op.layerMin); + for (size_t cPoint = 0; cPoint < cPoints; ++ cPoint, ++ cPointIndex) { + if (cPoint != 0) + fprintf(f, ","); + printPoint(f, static_cast<float> (pPoints [cPointIndex].dY), static_cast<float> (pPoints [cPointIndex].dX)); + } fprintf(f, "\n"); cPointIndex++; continue; @@ -363,7 +370,11 @@ fprintf(f, "Type=0x%x\n", op.garminType); if (op.label.c_str() != NULL && *op.label.c_str() != 0) fprintf(f, "Label=%s\n", op.label.c_str()); - fprintf(f, "Data0=(%.5f,%.5f)\n", y, x); + if (op.layerMax > op.layerMin) + fprintf(f, "EndLevel=%d\n", op.layerMax); + fprintf(f, "Data%d=", op.layerMin); + printPoint(f, y, x); + fprintf(f, "\n"); fprintf(f, "[END]\n"); fprintf(f, "\n"); } @@ -386,6 +397,8 @@ fprintf(f, "Type=0x%x\n", op.garminType); if (op.label.c_str() != NULL && *op.label.c_str() != 0) fprintf(f, "Label=%s\n", op.label.c_str()); + if (op.layerMax > op.layerMin) + fprintf(f, "EndLevel=%d\n", op.layerMax); size_t cPointIndex = 0; const CShpPointData * const pPoints = reinterpret_cast<const CShpPointData *> (_pPolygon->dwaParts + _pPolygon->dwNumParts); @@ -409,14 +422,14 @@ size_t cPointIndexOld = cPointIndex; - fprintf(f, "Data0="); - for (size_t cPoint = 0; cPoint < cPoints; ++ cPoint, ++ cPointIndex) - if (cPoint == 0) - fprintf(f, "(%.5f,%.5f)", static_cast<float> (pPoints [cPointIndex].dY), static_cast<float> (pPoints [cPointIndex].dX)); - else - fprintf(f, ",(%.5f,%.5f)", static_cast<float> (pPoints [cPointIndex].dY), static_cast<float> (pPoints [cPointIndex].dX)); + fprintf(f, "Data%d=", op.layerMin); + for (size_t cPoint = 0; cPoint < cPoints; ++ cPoint, ++ cPointIndex) { + if (cPoint != 0) + fprintf(f, ","); + printPoint(f, static_cast<float> (pPoints [cPointIndex].dY), static_cast<float> (pPoints [cPointIndex].dX)); + } fprintf(f, "\n"); - printHoles(f, _pPolygon, pPoints + cPointIndexOld, cPoints); + printHoles(f, _pPolygon, pPoints + cPointIndexOld, cPoints, op); // Omit last point. ++ cPointIndex; } @@ -529,6 +542,8 @@ size_t len = dbf.GetFieldLength(i); while (*p == ' ' && len > 0) p++, len--; + while (p[len - 1] == ' ' && len > 0) + len--; char type = dbf.GetFieldType(i); if (type == 'N') { char *s = (char *)malloc(len + 1); @@ -559,10 +574,6 @@ free(shpFile); - fseek(fShp, 0, SEEK_END); - size_t fileSize = ftell(fShp); - fseek(fShp, 0, SEEK_SET); - char *dbfFile = (char *)malloc(filename.length() + 5); strcpy(dbfFile, filename.c_str()); strcat(dbfFile, ".dbf"); @@ -580,6 +591,7 @@ CShpHdr pHdr; fread(&pHdr, sizeof(pHdr), 1, fShp); + size_t fileSize = Big2LowEndian(pHdr.dwFileLen) * sizeof(WORD); const char *strShpKind; switch (pHdr.dwType) { @@ -664,7 +676,8 @@ } else if (handle(&o, op, 0)) { // } else if (check(&o) && handle(&o, op, 0)) { if (f != NULL) - outputAttrs(f, dbf, o.cRecordCounter); + op.print(f); +// outputAttrs(f, dbf, o.cRecordCounter); switch (pRecHdr.dwType) { case shpNull: break; @@ -698,99 +711,24 @@ fclose(fShp); } -class StringFieldVar : public StringRVar { -public: - StringFieldVar(const std::string &_fieldName) : fieldName(_fieldName) { - } - - virtual ~StringFieldVar() { - } - - virtual std::string getValue(const void *obj, const ObjectProp &) { - const Object *object = (const Object *)obj; - size_t fieldNo = object->dbf->GetFieldNum(fieldName.c_str()); - if (fieldNo != (size_t)(-1)) { - const char *lStart = object->dbf->GetRawField(object->cRecordCounter, fieldNo); - size_t lLen = object->dbf->GetFieldLength(fieldNo); - while (*lStart == ' ' && lLen > 0) { - lStart++; - lLen--; - } - std::string value(lStart, lLen); - return value; - } - fprintf(stderr, "Unknown field: %s\n", fieldName.c_str()); - std::string value; - return value; - } -protected: - std::string fieldName; -}; - -class IntFieldVar : public IntRVar { -public: - IntFieldVar(const std::string &_fieldName) : fieldName(_fieldName) { - } - - virtual ~IntFieldVar() { - } - - virtual int getValue(const void *obj, const ObjectProp &, int) { - const Object *object = (const Object *)obj; - size_t fieldNo = object->dbf->GetFieldNum(fieldName.c_str()); - if (fieldNo == (size_t)(-1)) { - fprintf(stderr, "Unknown field: %s\n", fieldName.c_str()); - return 0; - } - return object->dbf->GetFieldN(object->cRecordCounter, fieldNo); - } -protected: - std::string fieldName; -}; - class ConfigParserImpl : public ConfigParser { public: ConfigParserImpl(Tokenizer &_t) : ConfigParser(_t) { } - virtual IntRVar *parseIntRVar(const std::string &varName) { - IntRVar *var = ConfigParser::parseIntRVar(varName); - if (var != NULL) - return var; - if (varName == "intfield") { - if (t.nextToken() != TT_STRING) - throw ParserException("Field name expected"); - return new IntFieldVar(t.sval); - } - return NULL; - } - - virtual StringRVar *parseStringRVar(const std::string &varName) { - StringRVar *var = ConfigParser::parseStringRVar(varName); - if (var != NULL) - return var; - if (varName == "field") { - if (t.nextToken() != TT_STRING) - throw ParserException("Field name expected"); - return new StringFieldVar(t.sval); - } - return NULL; - } - virtual void parseBlockStart(ObjectConf *obj) { -/* + ObjectConfImpl *o = (ObjectConfImpl *)obj; if (t.nextToken() != TT_WORD) - throw ParserException("Expected 'code'"); - if (t.sval != "code") - throw ParserException("Expected 'code'"); + throw ParserException("Expected 'projection'", t.lineno()); + if (t.sval != "projection") + throw ParserException("Expected 'projection'", t.lineno()); if (t.nextToken() != '=') - throw ParserException("Expected '='"); + throw ParserException("Expected '='", t.lineno()); if (t.nextToken() != TT_STRING) - throw ParserException("Expected code"); - obj->object_cod = t.sval; + throw ParserException("Expected code", t.lineno()); + o->setProjection(t.sval); if (t.nextToken() != ';') - throw ParserException("Expected ';'"); -*/ + throw ParserException("Expected ';'", t.lineno()); } virtual bool parseObject() { @@ -800,14 +738,14 @@ case TT_WORD: break; default: - throw ParserException("Expected 'file'"); + throw ParserException("Expected 'file'", t.lineno()); } if (t.sval != "file") - throw ParserException("Expected 'file'"); + throw ParserException("Expected 'file'", t.lineno()); if (t.nextToken() != TT_STRING) - throw ParserException("Expected file name"); + throw ParserException("Expected file name", t.lineno()); ObjectConfImpl *obj = new ObjectConfImpl(t.sval.c_str()); |
From: Denis P. <dy...@us...> - 2005-08-19 18:42:32
|
Update of /cvsroot/cmap/libs/eval In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1047 Modified Files: eval.h evalImpl.h parser.cpp Log Message: Add attributes to main ObjectProp Index: parser.cpp =================================================================== RCS file: /cvsroot/cmap/libs/eval/parser.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- parser.cpp 12 Jun 2005 08:27:13 -0000 1.6 +++ parser.cpp 19 Aug 2005 18:42:23 -0000 1.7 @@ -39,6 +39,11 @@ return new LayerMinVar(); if (varName == "layer_max") return new LayerMaxVar(); + if (varName == "intattr") { + if (t.nextToken() != TT_STRING) + throw ParserException("Attr name expected", t.lineno()); + return new IntAttrVar(t.sval); + } return NULL; } @@ -49,6 +54,11 @@ StringLVar *ConfigParser::parseStringLVar(const std::string &varName) { if (varName == "label") return new LabelLVar(); + if (varName == "attr") { + if (t.nextToken() != TT_STRING) + throw ParserException("Attr name expected", t.lineno()); + return new StringAttrVar(t.sval); + } return NULL; } Index: evalImpl.h =================================================================== RCS file: /cvsroot/cmap/libs/eval/evalImpl.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- evalImpl.h 12 Jun 2005 08:27:13 -0000 1.5 +++ evalImpl.h 19 Aug 2005 18:42:23 -0000 1.6 @@ -38,6 +38,42 @@ } }; +class StringAttrVar : public StringLVar { +public: + StringAttrVar(const std::string &_attrName) : attrName(_attrName) { + } + + virtual ~StringAttrVar() { + } + + virtual std::string getValue(const void *, const ObjectProp &o) { + for (Attrs::const_iterator iAttr = o.attrs.begin (); iAttr != o.attrs.end (); ++iAttr) { + const Attr &attr = *iAttr; + if (attr.name == attrName) + return attr.value; + } + fprintf(stderr, "Unknown attribute: %s\n", attrName.c_str()); + std::string value; + return value; + } + + virtual void setValue(ObjectProp &o, const std::string &value) { + for (Attrs::iterator iAttr = o.attrs.begin (); iAttr != o.attrs.end (); ++iAttr) { + Attr &attr = *iAttr; + if (attr.name == attrName) { + attr.value = value; + return; + } + } + Attr attr; + attr.name = attrName; + attr.value = value; + o.attrs.push_back(attr); + } +protected: + std::string attrName; +}; + class StringConst : public StringExpr { public: StringConst(const std::string &_value) : value(_value) { @@ -130,6 +166,44 @@ } }; + +class IntAttrVar : public IntLVar { +public: + IntAttrVar(const std::string &_attrName) : attrName(_attrName) { + } + + virtual ~IntAttrVar() { + } + + virtual int getValue(const void *obj, const ObjectProp &o, int) { + for (Attrs::const_iterator iAttr = o.attrs.begin (); iAttr != o.attrs.end (); ++iAttr) { + const Attr &attr = *iAttr; + if (attr.name == attrName) + return strtol(attr.value.c_str(), NULL, 10); + } + fprintf(stderr, "Unknown attribute: %s\n", attrName.c_str()); + return 0; + } + + virtual void setValue(ObjectProp &o, int value) { + char s[20]; + ::sprintf(s, "%d", value); + for (Attrs::iterator iAttr = o.attrs.begin (); iAttr != o.attrs.end (); ++iAttr) { + Attr &attr = *iAttr; + if (attr.name == attrName) { + attr.value = s; + return; + } + } + Attr attr; + attr.name = attrName; + attr.value = s; + o.attrs.push_back(attr); + } +protected: + std::string attrName; +}; + class IntRVar : public IntExpr { }; Index: eval.h =================================================================== RCS file: /cvsroot/cmap/libs/eval/eval.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- eval.h 12 Jun 2005 08:21:44 -0000 1.3 +++ eval.h 19 Aug 2005 18:42:23 -0000 1.4 @@ -4,6 +4,7 @@ #define __EVAL_EVAL_H__ #include <string> +#include <list> namespace kind { @@ -17,6 +18,19 @@ typedef kind::Kind Kind; +class Attr { +public: + std::string name; + std::string value; + + void print(FILE *f) const { + if (!value.empty()) + fprintf(f, "; %s=%s\n", name.c_str(), value.c_str()); + } +}; + +typedef std::list<Attr> Attrs; + typedef struct { bool index; bool doExport; @@ -36,6 +50,15 @@ int typePoint; int typeLine; int typePoly; + + Attrs attrs; + + void print(FILE *f) const { + for (Attrs::const_iterator iAttr = attrs.begin (); iAttr != attrs.end (); ++iAttr) { + const Attr &attr = *iAttr; + attr.print(f); + } + } } ObjectProp; #endif |
From: Denis P. <dy...@us...> - 2005-06-30 04:00:26
|
Update of /cvsroot/cmap/mp2mp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25974 Modified Files: mp2mp.cpp mp_parser.cpp mp_parser.h Log Message: Specify filename in errors. Index: mp2mp.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp2mp.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- mp2mp.cpp 29 Apr 2005 17:25:57 -0000 1.5 +++ mp2mp.cpp 30 Jun 2005 04:00:17 -0000 1.6 @@ -60,7 +60,7 @@ Tokenizer t(f); - MPParser p(t); + MPParser p(t, filename); try { while (p.parseObject()) Index: mp_parser.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp_parser.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- mp_parser.cpp 12 Jun 2005 08:22:11 -0000 1.6 +++ mp_parser.cpp 30 Jun 2005 04:00:17 -0000 1.7 @@ -57,6 +57,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++) (*it).print(f); @@ -172,7 +173,7 @@ fprintf(f, "(%.5f,%.5f)", y, x); } -MPParser::MPParser(Tokenizer &_t) : t(_t) { +MPParser::MPParser(Tokenizer &_t, const std::string &_filename) : t(_t), filename(_filename) { t.lowerCaseMode(true); t.quoteChar('"'); t.wordChars('a', 'z'); @@ -347,6 +348,9 @@ bool MPParser::parseRgn(Map &map) { Rgn rgn; int ttype; + rgn.line = t.lineno(); + rgn.filename = filename; + // Process comments for (;;) { ttype = t.nextToken(); Index: mp_parser.h =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp_parser.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- mp_parser.h 12 Jun 2005 08:22:11 -0000 1.5 +++ mp_parser.h 30 Jun 2005 04:00:17 -0000 1.6 @@ -60,6 +60,9 @@ BoolType direction; BoolType city; + std::string filename; + unsigned int line; + void print(FILE *f, bool is6Digit); void print(FILE *f, const ObjectProp &op, bool is6Digit); }; @@ -106,7 +109,7 @@ class MPParser { public: - MPParser(Tokenizer &t); + MPParser(Tokenizer &t, const std::string &_filename); void parseHeader(Map &map); bool parseRgn(Map &map); void parseElement(Element &e); |
From: Denis P. <dy...@us...> - 2005-06-12 08:27:22
|
Update of /cvsroot/cmap/libs/eval In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13611 Modified Files: evalImpl.h parser.cpp Log Message: Add direction support (was omited in prev commit) Index: parser.cpp =================================================================== RCS file: /cvsroot/cmap/libs/eval/parser.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- parser.cpp 12 Jun 2005 08:21:44 -0000 1.5 +++ parser.cpp 12 Jun 2005 08:27:13 -0000 1.6 @@ -13,6 +13,8 @@ return new IndexVar(); if (varName == "city") return new CityVar(); + if (varName == "direction") + return new DirectionVar(); return NULL; } Index: evalImpl.h =================================================================== RCS file: /cvsroot/cmap/libs/eval/evalImpl.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- evalImpl.h 12 Jun 2005 08:21:44 -0000 1.4 +++ evalImpl.h 12 Jun 2005 08:27:13 -0000 1.5 @@ -262,6 +262,16 @@ } }; +class DirectionVar : public BoolLVar { + virtual bool getValue(const void *, const ObjectProp &op, int) { + return op.direction; + } + + virtual void setValue(ObjectProp &op, bool value) { + op.direction = value; + } +}; + class NotExpr : public BoolExpr { public: NotExpr(BoolExpr *_expr) : expr(_expr) { |
From: Denis P. <dy...@us...> - 2005-06-12 08:22:20
|
Update of /cvsroot/cmap/mp2mp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12166 Modified Files: mp_parser.cpp mp_parser.h object.cpp Log Message: Support DirIndicator and City Index: object.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/object.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- object.cpp 25 Apr 2005 13:29:55 -0000 1.4 +++ object.cpp 12 Jun 2005 08:22:11 -0000 1.5 @@ -7,7 +7,8 @@ const Rgn *rgn = (const Rgn *)obj; o.index = false; - o.city = 0; + o.city = (rgn->city == True); + o.direction = (rgn->direction == True); o.garminType = rgn->type; o.layerMin = 0; Index: mp_parser.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp_parser.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- mp_parser.cpp 24 Apr 2005 19:59:43 -0000 1.5 +++ mp_parser.cpp 12 Jun 2005 08:22:11 -0000 1.6 @@ -1,7 +1,7 @@ #include "mp_parser.h" #include "pexcept.h" -Map::Map() { +Map::Map() : preprocess(Unknown), POIIndex(Unknown) { } void Map::printHeader(FILE *f) { @@ -18,7 +18,8 @@ break; } - fprintf(f, "Preprocess=%s\n", preprocess ? "T" : "F"); + if (preprocess != Unknown) + fprintf(f, "Preprocess=%s\n", preprocess == True ? "T" : "F"); fprintf(f, "CodePage=%d\n", codePage); fprintf(f, "LblCoding=%d\n", lblCoding); fprintf(f, "TreSize=%d\n", treSize); @@ -27,7 +28,8 @@ else fprintf(f, "TreMargin=%.5f\n", treMargin); fprintf(f, "RgnLimit=%d\n", rgnLimit); - fprintf(f, "POIIndex=%s\n", POIIndex ? "Y" : "N"); + if (POIIndex != Unknown) + fprintf(f, "POIIndex=%s\n", POIIndex == True ? "Y" : "N"); fprintf(f, "Levels=%d\n", levels.size()); size_t i; for (i = 0; i < levels.size(); i++) @@ -51,7 +53,7 @@ fprintf(f, "; %s=%s\n", name.c_str(), value.c_str()); } -Rgn::Rgn() : kind(kind::Point), type(0), endLevel(0) { +Rgn::Rgn() : kind(kind::Point), type(0), endLevel(0), direction(Unknown), city(Unknown) { } void Rgn::print(FILE *f, const ObjectProp &op, bool is6Digit) { @@ -76,6 +78,10 @@ fprintf(f, "EndLevel=%d\n", op.layerMax); if (op.label.length() > 0) fprintf(f, "Label=%s\n", op.label.c_str()); + if (op.direction) + fprintf(f, "DirIndicator=1\n"); + if (op.city) + fprintf(f, "City=Y\n"); if (kind != op.kind) { if (kind == kind::Point || op.kind != kind::Point) @@ -182,15 +188,27 @@ t.commentChar(';'); } -bool MPParser::parseBool(const std::string &sval) { +BoolType MPParser::parseBool() { + if (t.nextToken() == TT_NUMBER) + return (t.nval != 0) ? True : False; + if (t.ttype != TT_WORD) + throw ParserException("Boolean expected", t.lineno()); + return parseBool(t.sval); +} + +BoolType MPParser::parseBool(const std::string &sval) { if (sval == "T") - return true; + return True; if (sval == "F") - return false; + return False; if (sval == "Y") - return true; + return True; if (sval == "N") - return false; + return False; + if (sval == "y") + return True; + if (sval == "n") + return False; else throw ParserException("Unknown boolean value", t.lineno()); } @@ -397,9 +415,13 @@ rgn.label = t.sval; } else if (varName == "endlevel") rgn.endLevel = parseInt(); - else if (varName == "type") { + else if (varName == "type") rgn.type = parseInt(); - } else if (varName.substr(0, 4) == "data") { + else if (varName == "dirindicator") + rgn.direction = parseBool(); + else if (varName == "city") + rgn.city = parseBool(); + else if (varName.substr(0, 4) == "data") { Element e(parseInt(varName.substr(4))); parseElement(e); rgn.elements.push_back(e); Index: mp_parser.h =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp_parser.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- mp_parser.h 24 Apr 2005 19:59:43 -0000 1.4 +++ mp_parser.h 12 Jun 2005 08:22:11 -0000 1.5 @@ -33,6 +33,12 @@ void print(FILE *f); }; +enum BoolType { + Unknown, + False, + True +}; + class Rgn { public: /* @@ -51,6 +57,8 @@ std::string label; std::list<Attr> attrs; std::list<Element> elements; + BoolType direction; + BoolType city; void print(FILE *f, bool is6Digit); void print(FILE *f, const ObjectProp &op, bool is6Digit); @@ -75,13 +83,13 @@ std::string name; std::string typeSet; enum ElevationType elevation; - bool preprocess; + BoolType preprocess; int codePage; int lblCoding; int treSize; float treMargin; int rgnLimit; - bool POIIndex; + BoolType POIIndex; // void print(FILE *f); void printHeader(FILE *f); @@ -106,7 +114,8 @@ Map map; private: - bool parseBool(const std::string &sval); + BoolType parseBool(); + BoolType parseBool(const std::string &sval); int parseInt(); int parseInt(const std::string &sval); float parseFloat(const std::string &sval); |
From: Denis P. <dy...@us...> - 2005-06-12 08:21:53
|
Update of /cvsroot/cmap/libs/eval In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11874 Modified Files: eval.h evalImpl.h parser.cpp Log Message: Support direction and city Index: parser.cpp =================================================================== RCS file: /cvsroot/cmap/libs/eval/parser.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- parser.cpp 24 Apr 2005 19:59:51 -0000 1.4 +++ parser.cpp 12 Jun 2005 08:21:44 -0000 1.5 @@ -11,6 +11,8 @@ return new ExportVar(); if (varName == "index") return new IndexVar(); + if (varName == "city") + return new CityVar(); return NULL; } @@ -35,8 +37,6 @@ return new LayerMinVar(); if (varName == "layer_max") return new LayerMaxVar(); - if (varName == "city") - return new CityVar(); return NULL; } Index: evalImpl.h =================================================================== RCS file: /cvsroot/cmap/libs/eval/evalImpl.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- evalImpl.h 24 Apr 2005 19:59:51 -0000 1.3 +++ evalImpl.h 12 Jun 2005 08:21:44 -0000 1.4 @@ -252,12 +252,12 @@ } }; -class CityVar : public IntLVar { - virtual int getValue(const void *, const ObjectProp &op, int) { +class CityVar : public BoolLVar { + virtual bool getValue(const void *, const ObjectProp &op, int) { return op.city; } - virtual void setValue(ObjectProp &op, int value) { + virtual void setValue(ObjectProp &op, bool value) { op.city = value; } }; Index: eval.h =================================================================== RCS file: /cvsroot/cmap/libs/eval/eval.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- eval.h 24 Apr 2005 19:59:51 -0000 1.2 +++ eval.h 12 Jun 2005 08:21:44 -0000 1.3 @@ -20,7 +20,8 @@ typedef struct { bool index; bool doExport; - int city; + bool city; + bool direction; int garminType; |
From: Denis P. <dy...@us...> - 2005-06-12 07:01:52
|
Update of /cvsroot/cmap/mp2mp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8414 Modified Files: mpsplit.dsp Log Message: Add pexcept.h Index: mpsplit.dsp =================================================================== RCS file: /cvsroot/cmap/mp2mp/mpsplit.dsp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- mpsplit.dsp 24 Apr 2005 19:59:43 -0000 1.1 +++ mpsplit.dsp 12 Jun 2005 07:01:39 -0000 1.2 @@ -123,6 +123,10 @@ # End Source File # Begin Source File +SOURCE=.\eval\pexcept.h +# End Source File +# Begin Source File + SOURCE=.\splitObject.h # End Source File # Begin Source File |
From: Denis P. <dy...@us...> - 2005-06-12 06:58:41
|
Update of /cvsroot/cmap/mp2mp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7087 Modified Files: mpmerge.cpp Log Message: Handle file not found correctly Index: mpmerge.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/mpmerge.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- mpmerge.cpp 24 Apr 2005 19:59:43 -0000 1.1 +++ mpmerge.cpp 12 Jun 2005 06:58:32 -0000 1.2 @@ -13,14 +13,35 @@ void process(FILE *fo, const char *filename, bool copyHeader); }; +class FileNotFoundException : public std::exception { +public: + FileNotFoundException(const char *_filename) : filename(_filename){ + } + + virtual ~FileNotFoundException() throw () { + } + + static void raise(const char *_filename) { + throw FileNotFoundException(_filename); + } + + virtual const char *name() const throw() { + return "FileNotFoundException"; + } + + virtual const char *what() const throw() { + return ("File not found: " + filename).c_str(); + } +public: + std::string filename; +}; + void Converter::process(FILE *fo, const char *filename, bool copyHeader) { fprintf(stderr, "Processing: %s\n", filename); FILE *f = fopen(filename, "rt"); - if (f == NULL) { - fprintf(stderr, "File not found: %s\n", filename); - exit(1); - } + if (f == NULL) + throw FileNotFoundException(filename); Tokenizer t(f); @@ -40,7 +61,7 @@ p.map.printHeader(fo); for (std::list<Rgn>::iterator it = p.map.rgns.begin(); it != p.map.rgns.end(); it++) { Rgn &rgn = *it; - rgn.print(fo); + rgn.print(fo, true); } fclose(f); @@ -81,12 +102,14 @@ return 1; } - try { - for (int i = firstArg; i < argc; i++) + for (int i = firstArg; i < argc; i++) + try { c.process(f, argv[i], i == firstArg); - } catch (ParserException &x) { - fprintf(stderr, "%d: %s\n", x.lineno(), x.what()); - } + } catch (ParserException &x) { + fprintf(stderr, "%d: %s\n", x.lineno(), x.what()); + } catch (FileNotFoundException &x) { + fprintf(stderr, "File not found: %s\n", x.filename.c_str()); + } fclose(f); return 0; |
From: Denis P. <dy...@us...> - 2005-04-29 17:26:08
|
Update of /cvsroot/cmap/mp2mp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6274 Modified Files: mp2mp.cpp Log Message: Continue processing when file not found. Index: mp2mp.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp2mp.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- mp2mp.cpp 24 Apr 2005 19:59:43 -0000 1.4 +++ mp2mp.cpp 29 Apr 2005 17:25:57 -0000 1.5 @@ -54,7 +54,8 @@ FILE *f = fopen(filename.c_str(), "rt"); if (f == NULL) { fprintf(stderr, "File not found: %s\n", filename.c_str()); - exit(1); + return; +// exit(1); } Tokenizer t(f); |
From: Denis P. <dy...@us...> - 2005-04-25 13:30:07
|
Update of /cvsroot/cmap/mp2mp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24635 Modified Files: object.cpp Log Message: Do not do memset when there are string objects Index: object.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/object.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- object.cpp 24 Apr 2005 19:59:43 -0000 1.3 +++ object.cpp 25 Apr 2005 13:29:55 -0000 1.4 @@ -6,8 +6,6 @@ void ObjectConfImpl::init(const void *obj, ObjectProp &o) { const Rgn *rgn = (const Rgn *)obj; - memset(&o, 0, sizeof(o)); - o.index = false; o.city = 0; |
From: Denis P. <dy...@us...> - 2005-04-24 20:05:20
|
Update of /cvsroot/cmap/mp2mp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13894 Modified Files: .cvsignore Added Files: Makefile Log Message: Add Linux support Index: .cvsignore =================================================================== RCS file: /cvsroot/cmap/mp2mp/.cvsignore,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- .cvsignore 24 Apr 2005 19:59:43 -0000 1.1 +++ .cvsignore 24 Apr 2005 20:05:12 -0000 1.2 @@ -3,3 +3,6 @@ *.ncb Debug Release +mp2mp +mpsplit +mpmerge --- NEW FILE: Makefile --- SOURCES = eval/eval.cpp eval/parser.cpp eval/tokenizer.cpp eval/pexcept.cpp \ mp2mp.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 mp2mp: $(SOURCES) $(HEADERS) $(CXX) -g3 -o mp2mp -I. -Ieval $(SOURCES) -lm |
From: Denis P. <dy...@us...> - 2005-04-24 20:00:26
|
Update of /cvsroot/cmap/mp2mp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10096 Modified Files: mp2mp.cpp mp2mp.dsp mp2mp.dsw mp_parser.cpp mp_parser.h object.cpp parserImpl.cpp Added Files: .cvsignore mpmerge.cpp mpmerge.dsp mpsplit.cpp mpsplit.dsp parserSplitImpl.cpp parserSplitImpl.h splitObject.cpp splitObject.h Log Message: Add mpsplit & mpmerge Correct kind= work. Make min_layer working. Index: mp2mp.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp2mp.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- mp2mp.cpp 23 Feb 2005 11:19:21 -0000 1.3 +++ mp2mp.cpp 24 Apr 2005 19:59:43 -0000 1.4 @@ -1,11 +1,9 @@ -// shp2mp.cpp : Defines the entry point for the console application. -// - #include <stdio.h> #include <math.h> #include <list> #include "tokenizer.h" #include "parserImpl.h" +#include "pexcept.h" #include "object.h" #include "mp_parser.h" @@ -78,7 +76,7 @@ for (std::list<Rgn>::iterator it = p.map.rgns.begin(); it != p.map.rgns.end(); it++) { Rgn &rgn = *it; if (handle(&rgn, op, 0)) - rgn.print(fo, op); + rgn.print(fo, op, true); } fclose(f); --- NEW FILE: mpmerge.dsp --- # Microsoft Developer Studio Project File - Name="mpmerge" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=mpmerge - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "mpmerge.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "mpmerge.mak" CFG="mpmerge - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "mpmerge - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "mpmerge - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "mpmerge - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /W3 /GX /O2 /I "eval" /I "." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x419 /d "NDEBUG" # ADD RSC /l 0x419 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "mpmerge - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "eval" /I "." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c # ADD BASE RSC /l 0x419 /d "_DEBUG" # ADD RSC /l 0x419 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "mpmerge - Win32 Release" # Name "mpmerge - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\eval\eval.cpp # End Source File # Begin Source File SOURCE=.\mp_parser.cpp # End Source File # Begin Source File SOURCE=.\mpmerge.cpp # End Source File # Begin Source File SOURCE=.\eval\pexcept.cpp # End Source File # Begin Source File SOURCE=.\eval\tokenizer.cpp # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\mp_parser.h # End Source File # Begin Source File SOURCE=.\eval\pexcept.h # End Source File # Begin Source File SOURCE=.\eval\tokenizer.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project --- NEW FILE: mpmerge.cpp --- #include <stdio.h> #include <math.h> #include <list> #include "tokenizer.h" #include "pexcept.h" #include "mp_parser.h" class Converter { public: Converter() { } void process(FILE *fo, const char *filename, bool copyHeader); }; void Converter::process(FILE *fo, const char *filename, bool copyHeader) { fprintf(stderr, "Processing: %s\n", filename); FILE *f = fopen(filename, "rt"); if (f == NULL) { fprintf(stderr, "File not found: %s\n", filename); exit(1); } Tokenizer t(f); MPParser p(t); try { while (p.parseObject()) ; } catch (ParserException &) { fprintf(stderr, "Error in file: '%s'\n", filename); t.printToken(); fclose(f); throw; } if (copyHeader) p.map.printHeader(fo); for (std::list<Rgn>::iterator it = p.map.rgns.begin(); it != p.map.rgns.end(); it++) { Rgn &rgn = *it; rgn.print(fo); } fclose(f); } static void printUsage(const char *name) { fprintf(stderr, "Usage: %s -o <outfile> <file1> ...\n", name); } int main(int argc, char* argv[]) { int firstArg = 1; const char *outFileName; if (argc >= 2 && strcmp(argv[firstArg], "-o") == 0) { if (argc < firstArg + 2) { printUsage(argv[0]); return 1; } outFileName = argv[firstArg + 1]; firstArg += 2; } else { printUsage(argv[0]); return 1; } if (argc < firstArg + 1) { printUsage(argv[0]); return 1; } Converter c; FILE *f = fopen(outFileName, "wt"); if (f == NULL) { fprintf(stderr, "Error opening file: %s\n", outFileName); return 1; } try { for (int i = firstArg; i < argc; i++) c.process(f, argv[i], i == firstArg); } catch (ParserException &x) { fprintf(stderr, "%d: %s\n", x.lineno(), x.what()); } fclose(f); return 0; } --- NEW FILE: .cvsignore --- *.plg *.opt *.ncb Debug Release Index: mp_parser.h =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp_parser.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- mp_parser.h 23 Feb 2005 11:19:22 -0000 1.3 +++ mp_parser.h 24 Apr 2005 19:59:43 -0000 1.4 @@ -4,14 +4,15 @@ #include <string> #include <list> #include "tokenizer.h" -#include "parser.h" +#include "pexcept.h" +#include "object.h" class point_t { public: double x; double y; - void print(FILE *f); + void print(FILE *f, bool is6Digits); }; class Element { @@ -20,7 +21,8 @@ int level; std::list<point_t> points; - void print(FILE *f); + void print(FILE *f, bool is6Digit); + void print(FILE *f, const ObjectProp &op, bool is6Digit); }; class Attr { @@ -33,22 +35,31 @@ class Rgn { public: +/* enum RgnType { POI, Polyline, Polygon }; +*/ Rgn(); - enum RgnType rgnType; + Kind kind; int type; int endLevel; std::string label; std::list<Attr> attrs; std::list<Element> elements; - void print(FILE *f, const ObjectProp &op); + void print(FILE *f, bool is6Digit); + void print(FILE *f, const ObjectProp &op, bool is6Digit); +}; + +class Level { +public: + int number; + int zoom; }; class Map { @@ -74,8 +85,15 @@ // void print(FILE *f); void printHeader(FILE *f); + bool is6Digit() { + for (size_t i = 0; i < levels.size(); i++) + if (levels[i].number > 24) + return true; + return false; + } std::list<Rgn> rgns; + std::vector<Level> levels; }; class MPParser { --- NEW FILE: splitObject.cpp --- #include "splitObject.h" SplitObj *firstSplitObj = NULL; void addSplitObj(SplitObj *obj) { obj->next = firstSplitObj; firstSplitObj = obj; } Index: parserImpl.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/parserImpl.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- parserImpl.cpp 23 Feb 2005 11:19:22 -0000 1.3 +++ parserImpl.cpp 24 Apr 2005 19:59:43 -0000 1.4 @@ -1,5 +1,6 @@ #include "parserImpl.h" #include "object.h" +#include "pexcept.h" #include "mp_parser.h" class AttrVar : public StringRVar { Index: object.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/object.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- object.cpp 14 Nov 2004 15:00:57 -0000 1.2 +++ object.cpp 24 Apr 2005 19:59:43 -0000 1.3 @@ -6,24 +6,17 @@ void ObjectConfImpl::init(const void *obj, ObjectProp &o) { const Rgn *rgn = (const Rgn *)obj; + memset(&o, 0, sizeof(o)); + o.index = false; o.city = 0; o.garminType = rgn->type; + o.layerMin = 0; o.layerMax = rgn->endLevel; o.label = rgn->label; - switch (rgn->rgnType) { - case Rgn::POI: - o.kind = kind::Point; - break; - case Rgn::Polyline: - o.kind = kind::Line; - break; - case Rgn::Polygon: - o.kind = kind::Polygon; - break; - } + o.kind = rgn->kind; } void add(ObjectConfImpl *obj) { --- NEW FILE: splitObject.h --- #ifndef __SPLITOBJECT_H__ #define __SPLITOBJECT_H__ #include <string> class SplitObj { public: SplitObj(const std::string &_code) : code(_code), next(NULL) { } std::string code; std::string file; SplitObj *next; }; extern SplitObj *firstSplitObj; void addSplitObj(SplitObj *obj); #endif --- NEW FILE: mpsplit.cpp --- #include <direct.h> #include <stdio.h> #include <math.h> #include <list> #include "tokenizer.h" #include "parserSplitImpl.h" #include "pexcept.h" #include "splitObject.h" #include "mp_parser.h" std::string headerFileName; std::string mapID; std::string mapName; class Converter { public: Converter() { } void process(FILE *f); void readConfig(const char *filename); }; class FileInfo { public: std::string filename; FILE *f; }; std::list<FileInfo> files; FILE *isCreated(std::string filename) { for (std::list<FileInfo>::iterator iFile = files.begin(); iFile != files.end(); iFile++) if (iFile->filename == filename) return iFile->f; return NULL; } void copyFile(const std::string &inFile, const std::string &outFile) { FILE *fi = fopen(inFile.c_str(), "rb"); if (fi == NULL) { fprintf(stderr, "Can not open file '%s'\n", inFile.c_str()); exit(1); } FILE *fo = fopen(outFile.c_str(), "wb"); if (fo == NULL) { fprintf(stderr, "Can not open file '%s'\n", outFile.c_str()); exit(1); } unsigned char buf[1024]; for (;;) { int n = fread(buf, 1, 1024, fi); if (n > 0) fwrite(buf, 1, n, fo); if (n < 1024) break; } fclose(fo); fclose(fi); } std::string outDir; void checkFile(const std::string &inFile, const std::string &outFile) { FILE *fi = fopen(inFile.c_str(), "rb"); if (fi == NULL) { fprintf(stderr, "Can not open file '%s'\n", inFile.c_str()); exit(1); } FILE *fo = fopen(outFile.c_str(), "rb"); if (fo == NULL) { fclose(fi); fprintf(stderr, "%s: new\n", outFile.c_str()); copyFile(inFile, outFile); return; } unsigned char bufIn[1024]; unsigned char bufOut[1024]; bool good = false; for (;;) { int ni = fread(bufIn, 1, 1024, fi); int no = fread(bufOut, 1, 1024, fo); if (ni != no) break; if (memcmp(bufIn, bufOut, ni) != 0) break; if (ni < 1024) { good = true; break; } } fclose(fo); fclose(fi); if (good) return; fprintf(stderr, "%s: changed\n", outFile.c_str()); copyFile(inFile, outFile); } void Converter::process(FILE *f) { Tokenizer t(f); MPParser p(t); while (p.parseObject()) ; mkdir("split_tmp"); for (std::list<Rgn>::iterator iRgn = p.map.rgns.begin(); iRgn != p.map.rgns.end(); iRgn++) { std::string code; for (std::list<Attr>::iterator iAttr = iRgn->attrs.begin(); iAttr != iRgn->attrs.end(); iAttr++) if (iAttr->name == "CODE") code = iAttr->value; if (code.empty()) continue; for (SplitObj *file = firstSplitObj; file != NULL; file = (SplitObj *)(file->next)) { if (file->code == code) { if (file->file.empty()) { fprintf(stderr, "No file section for code %s\n", code.c_str()); exit(1); } FILE *fo; if ((fo = isCreated(file->file)) == NULL) { fo = fopen(("split_tmp\\" + file->file).c_str(), "wt"); if (fo == NULL) { fprintf(stderr, "Can not open file '%s'\n", file->file.c_str()); exit(1); } FileInfo fi; fi.filename = file->file; fi.f = fo; files.push_back(fi); p.map.printHeader(fo); } iRgn->print(fo, p.map.is6Digit()); break; } } } std::list<FileInfo>::iterator iFile; for (iFile = files.begin(); iFile != files.end(); iFile++) fclose(iFile->f); for (iFile = files.begin(); iFile != files.end(); iFile++) checkFile("split_tmp\\" + iFile->filename, outDir + iFile->filename); for (iFile = files.begin(); iFile != files.end(); iFile++) unlink(("split_tmp\\" + iFile->filename).c_str()); rmdir("split_tmp"); } void Converter::readConfig(const char *filename) { FILE *f = fopen(filename, "rt"); if (f == NULL) { fprintf(stderr, "File not found: %s\n", filename); exit(1); } Tokenizer t(f); t.lowerCaseMode(true); t.quoteChar('"'); t.wordChars('a', 'z'); t.wordChars('A', 'Z'); t.wordChar('_'); t.parseNumbers(); t.whitespaceChar(' '); t.whitespaceChar('\n'); t.whitespaceChar('\r'); t.whitespaceChar('\t'); t.slashSlashComments(true); t.slashStarComments(true); ConfigParser p(t); try { while (p.parseObject()) ; } catch (ParserException &) { t.printToken(); fclose(f); throw; } fclose(f); } static void printUsage(const char *name) { fprintf(stderr, "Usage: %s <config> -o <outdir> <config> <input>\n", name); } static std::string convertMapID(const char *s) { std::string id = "111"; id += (s[0] - 'A') / 10 + '0'; id += (s[0] - 'A') % 10 + '0'; id += s[2]; id += s[3]; id += s[5]; return id; } int main(int argc, char* argv[]) { bool doSplit = false; int firstArg = 1; if (argc > firstArg + 1) { if (strcmp(argv[firstArg], "-o") == 0) { outDir = argv[firstArg + 1]; if (outDir[outDir.length() - 1] != '\\') outDir += '\\'; firstArg += 2; } } if (argc < firstArg + 2) { printUsage(argv[0]); return 1; } const char *configFile = argv[firstArg]; Converter c; try { c.readConfig(configFile); } catch (ParserException &x) { fprintf(stderr, "%s\n", x.what()); return 1; } const char *inFile = argv[firstArg + 1]; FILE *f = fopen(inFile, "rt"); if (f == NULL) { fprintf(stderr, "Error opening file: %s\n", inFile); return 1; } try { c.process(f); } catch (ParserException &x) { fprintf(stderr, "%s:%d: %s\n", inFile, x.lineno(), x.what()); } fclose(f); return 0; } --- NEW FILE: parserSplitImpl.h --- #ifndef __PARSERIMPL_H__ #define __PARSERIMPL_H__ #include <tokenizer.h> #include "splitObject.h" class ConfigParser { public: ConfigParser(Tokenizer &_t); void parseStringLVar(const std::string &varName, SplitObj *obj); void parseAssign(const std::string &varName, SplitObj *obj); void parseBlock(SplitObj *obj); bool parseObject(); protected: Tokenizer &t; }; #endif --- NEW FILE: mpsplit.dsp --- # Microsoft Developer Studio Project File - Name="mpsplit" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=mpsplit - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "mpsplit.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "mpsplit.mak" CFG="mpsplit - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "mpsplit - Win32 Release" (based on "Win32 (x86) Console Application") !MESSAGE "mpsplit - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "mpsplit - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /W3 /GX /O2 /I "eval" /I "." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x419 /d "NDEBUG" # ADD RSC /l 0x419 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "mpsplit - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "eval" /I "." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c # ADD BASE RSC /l 0x419 /d "_DEBUG" # ADD RSC /l 0x419 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept !ENDIF # Begin Target # Name "mpsplit - Win32 Release" # Name "mpsplit - Win32 Debug" # Begin Group "Source Files" # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File SOURCE=.\mp_parser.cpp # End Source File # Begin Source File SOURCE=.\mpsplit.cpp # End Source File # Begin Source File SOURCE=.\parserSplitImpl.cpp # End Source File # Begin Source File SOURCE=.\eval\pexcept.cpp # End Source File # Begin Source File SOURCE=.\splitObject.cpp # End Source File # Begin Source File SOURCE=.\eval\tokenizer.cpp # End Source File # End Group # Begin Group "Header Files" # PROP Default_Filter "h;hpp;hxx;hm;inl" # Begin Source File SOURCE=.\mp_parser.h # End Source File # Begin Source File SOURCE=.\parserSplitImpl.h # End Source File # Begin Source File SOURCE=.\splitObject.h # End Source File # Begin Source File SOURCE=.\eval\tokenizer.h # End Source File # End Group # Begin Group "Resource Files" # PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" # End Group # End Target # End Project Index: mp_parser.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp_parser.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- mp_parser.cpp 23 Feb 2005 11:36:53 -0000 1.4 +++ mp_parser.cpp 24 Apr 2005 19:59:43 -0000 1.5 @@ -1,29 +1,41 @@ #include "mp_parser.h" +#include "pexcept.h" Map::Map() { } void Map::printHeader(FILE *f) { - fprintf(f, "id = %s\n", id.c_str()); - fprintf(f, "name = %s\n", name.c_str()); - fprintf(f, "typeSet = %s\n", typeSet.c_str()); + fprintf(f, "[IMG ID]\n"); + fprintf(f, "ID=%s\n", id.c_str()); + fprintf(f, "Name=%s\n", name.c_str()); + fprintf(f, "TypeSet=%s\n", typeSet.c_str()); switch (elevation) { case Feets: - fprintf(f, "elevation = feets\n"); + fprintf(f, "Elevation=F\n"); break; case Meters: - fprintf(f, "elevation = meters\n"); + fprintf(f, "Elevation=M\n"); break; } - fprintf(f, "preprocess = %s\n", preprocess ? "true" : "false"); - fprintf(f, "codePage = %d\n", codePage); - fprintf(f, "LBLCoding = %d\n", lblCoding); - fprintf(f, "treSize = %d\n", treSize); - fprintf(f, "treMargin = %f\n", treMargin); - fprintf(f, "RGNLimit = %d\n", rgnLimit); - fprintf(f, "POIIndex = %s\n", POIIndex ? "true" : "false"); + fprintf(f, "Preprocess=%s\n", preprocess ? "T" : "F"); + fprintf(f, "CodePage=%d\n", codePage); + fprintf(f, "LblCoding=%d\n", lblCoding); + fprintf(f, "TreSize=%d\n", treSize); + if (is6Digit()) + fprintf(f, "TreMargin=%.6f\n", treMargin); + else + fprintf(f, "TreMargin=%.5f\n", treMargin); + fprintf(f, "RgnLimit=%d\n", rgnLimit); + fprintf(f, "POIIndex=%s\n", POIIndex ? "Y" : "N"); + fprintf(f, "Levels=%d\n", levels.size()); + size_t i; + for (i = 0; i < levels.size(); i++) + fprintf(f, "Level%d=%d\n", i, levels[i].number); + for (i = 0; i < levels.size(); i++) + fprintf(f, "Zoom%d=%d\n", i, levels[i].zoom); + fprintf(f, "[END-IMG ID]\n"); fprintf(f, "\n"); } @@ -39,21 +51,21 @@ fprintf(f, "; %s=%s\n", name.c_str(), value.c_str()); } -Rgn::Rgn() : rgnType(POI), type(0), endLevel(0) { +Rgn::Rgn() : kind(kind::Point), type(0), endLevel(0) { } -void Rgn::print(FILE *f, const ObjectProp &op) { +void Rgn::print(FILE *f, const ObjectProp &op, bool is6Digit) { for (std::list<Attr>::iterator it = attrs.begin(); it != attrs.end(); it++) (*it).print(f); - switch (rgnType) { - case POI: + switch (op.kind) { + case kind::Point: fprintf(f, "[POI]\n"); break; - case Polyline: + case kind::Line: fprintf(f, "[POLYLINE]\n"); break; - case Polygon: + case kind::Polygon: fprintf(f, "[POLYGON]\n"); break; }; @@ -65,8 +77,61 @@ if (op.label.length() > 0) fprintf(f, "Label=%s\n", op.label.c_str()); + if (kind != op.kind) { + if (kind == kind::Point || op.kind != kind::Point) + throw ParserException("Only polyline and Polygon to Point conversion is supported", 0); + for (std::list<Element>::iterator it2 = elements.begin(); it2 != elements.end(); it2++) { + point_t pt; + pt.x = 0.0; + pt.y = 0.0; + double count = 0.0; + + for (std::list<point_t>::iterator it3 = (*it2).points.begin(); it3 != (*it2).points.end(); it3++) { + pt.x += (*it3).x; + pt.y += (*it3).y; + count += 1.0; + } + + pt.x /= count; + pt.y /= count; + + fprintf(f, "Data%d=", op.layerMin); + pt.print(f, is6Digit); + fprintf(f, "\n"); + } + } else { + for (std::list<Element>::iterator it2 = elements.begin(); it2 != elements.end(); it2++) + (*it2).print(f, op, is6Digit); + } + fprintf(f, "[END]\n"); + fprintf(f, "\n"); +} + +void Rgn::print(FILE *f, bool is6Digit) { + for (std::list<Attr>::iterator it = attrs.begin(); it != attrs.end(); it++) + (*it).print(f); + + switch (kind) { + case kind::Point: + fprintf(f, "[POI]\n"); + break; + case kind::Line: + fprintf(f, "[POLYLINE]\n"); + break; + case kind::Polygon: + fprintf(f, "[POLYGON]\n"); + break; + }; + + fprintf(f, "Type=0x%x\n", type); + + if (endLevel != 0) + fprintf(f, "EndLevel=%d\n", endLevel); + if (label.length() > 0) + fprintf(f, "Label=%s\n", label.c_str()); + for (std::list<Element>::iterator it2 = elements.begin(); it2 != elements.end(); it2++) - (*it2).print(f); + (*it2).print(f, is6Digit); fprintf(f, "[END]\n"); fprintf(f, "\n"); } @@ -74,18 +139,31 @@ Element::Element(int _level) : level(_level) { } -void Element::print(FILE *f) { +void Element::print(FILE *f, bool is6Digit) { fprintf(f, "Data%d=", level); for (std::list<point_t>::iterator it = points.begin(); it != points.end(); it++) { if (it != points.begin()) fprintf(f, ","); - (*it).print(f); + (*it).print(f, is6Digit); } fprintf(f, "\n"); } -void point_t::print(FILE *f) { - fprintf(f, "(%.6f,%.6f)", y, x); +void Element::print(FILE *f, const ObjectProp &op, bool is6Digit) { + fprintf(f, "Data%d=", op.layerMin); + for (std::list<point_t>::iterator it = points.begin(); it != points.end(); it++) { + if (it != points.begin()) + fprintf(f, ","); + (*it).print(f, is6Digit); + } + fprintf(f, "\n"); +} + +void point_t::print(FILE *f, bool is6Digits) { + if (is6Digits) + fprintf(f, "(%.6f,%.6f)", y, x); + else + fprintf(f, "(%.5f,%.5f)", y, x); } MPParser::MPParser(Tokenizer &_t) : t(_t) { @@ -195,8 +273,18 @@ map.rgnLimit = parseInt(t.sval); else if (varName == "poiindex") map.POIIndex = parseBool(t.sval); - else if (varName.substr(0, 5) == "level") { + else if (varName == "levels") { + int levelsCount = parseInt(t.sval); + for (int i = 0; i < levelsCount; i++) + map.levels.push_back(Level()); + } else if (varName.substr(0, 5) == "level") { + int levelNum = parseInt(varName.substr(5, 2)); + int levelValue = parseInt(t.sval); + map.levels[levelNum].number = levelValue; } else if (varName.substr(0, 4) == "zoom") { + int levelNum = parseInt(varName.substr(4, 2)); + int levelZoom = parseInt(t.sval); + map.levels[levelNum].zoom = levelZoom; } else throw ParserException(("Unknown variable: " + varName).c_str(), t.lineno()); } @@ -277,18 +365,18 @@ throw ParserException("'[' expected", t.lineno()); if (t.nextToken() != TT_WORD || (t.sval != "polyline" && t.sval != "polygon" && t.sval != "poi")) throw ParserException("'polyline', 'polygon' or 'poi' expected", t.lineno()); - enum Rgn::RgnType rgnType; + Kind kind; if (t.sval == "polyline") - rgnType = Rgn::Polyline; + kind = kind::Line; else if (t.sval == "polygon") - rgnType = Rgn::Polygon; + kind = kind::Polygon; else if (t.sval == "poi") - rgnType = Rgn::POI; + kind = kind::Point; if (t.nextToken() != ']') throw ParserException("']' expected", t.lineno()); - rgn.rgnType = rgnType; + rgn.kind = kind; for (;;) { ttype = t.nextToken(); if (ttype == '[') { Index: mp2mp.dsp =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp2mp.dsp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- mp2mp.dsp 14 Nov 2004 15:00:57 -0000 1.2 +++ mp2mp.dsp 24 Apr 2005 19:59:43 -0000 1.3 @@ -111,6 +111,10 @@ # End Source File # Begin Source File +SOURCE=.\eval\pexcept.cpp +# End Source File +# Begin Source File + SOURCE=.\eval\tokenizer.cpp # End Source File # End Group @@ -143,6 +147,10 @@ # End Source File # Begin Source File +SOURCE=.\eval\pexcept.h +# End Source File +# Begin Source File + SOURCE=.\eval\tokenizer.h # End Source File # End Group --- NEW FILE: parserSplitImpl.cpp --- #include "parserSplitImpl.h" #include "splitObject.h" #include "pexcept.h" #include "mp_parser.h" ConfigParser::ConfigParser(Tokenizer &_t) : t(_t) { } void ConfigParser::parseStringLVar(const std::string &varName, SplitObj *obj) { if (varName != "file") return; if (t.nextToken() != '=') throw ParserException("Expected '='", t.lineno()); if (t.nextToken() != TT_STRING) throw ParserException("Expected file value", t.lineno()); obj->file = t.sval; } void ConfigParser::parseAssign(const std::string &varName, SplitObj *obj) { parseStringLVar(varName, obj); } void ConfigParser::parseBlock(SplitObj *obj) { if (t.nextToken() != '{') throw ParserException("Expected '{'", t.lineno()); std::string varName; for (;;) { if (t.nextToken() == '}') break; if (t.ttype != TT_WORD) throw ParserException("Expected variable name or '}'", t.lineno()); varName = t.sval; parseAssign(varName, obj); if (t.nextToken() != ';') throw ParserException("Expected ';'", t.lineno()); } } bool ConfigParser::parseObject() { switch (t.nextToken()) { case TT_EOF: return false; case TT_WORD: break; default: throw ParserException("Expected 'code'", t.lineno()); } if (t.sval != "code") throw ParserException("Expected 'code'", t.lineno()); if (t.nextToken() != TT_STRING) throw ParserException("Expected code value", t.lineno()); SplitObj *obj = new SplitObj(t.sval.c_str()); parseBlock(obj); addSplitObj(obj); return true; }; Index: mp2mp.dsw =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp2mp.dsw,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- mp2mp.dsw 7 Nov 2004 13:58:57 -0000 1.1.1.1 +++ mp2mp.dsw 24 Apr 2005 19:59:43 -0000 1.2 @@ -15,6 +15,30 @@ ############################################################################### +Project: "mpmerge"=.\mpmerge.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "mpsplit"=.\mpsplit.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + Global: Package=<5> |
From: Denis P. <dy...@us...> - 2005-04-24 20:00:02
|
Update of /cvsroot/cmap/libs/eval In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10096/eval Modified Files: eval.cpp eval.h evalImpl.h parser.cpp parser.h tokenizer.cpp tokenizer.h Added Files: pexcept.cpp pexcept.h Log Message: Add mpsplit & mpmerge Correct kind= work. Make min_layer working. Index: parser.cpp =================================================================== RCS file: /cvsroot/cmap/libs/eval/parser.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- parser.cpp 23 Feb 2005 11:10:12 -0000 1.3 +++ parser.cpp 24 Apr 2005 19:59:51 -0000 1.4 @@ -1,25 +1,10 @@ +// Copyright Denis Perchine <dy...@pe...>, 2004, 2005 + #include <stdio.h> #include "object.h" #include "parser.h" - -ParserException::ParserException(const char *_msg, int _line) : msg(_msg), line(_line) { -} - -ParserException::~ParserException() throw () { -} - -void ParserException::raise(const char *_msg, int _lineno) { - throw ParserException(_msg, _lineno); -} - -const char *ParserException::name() const throw() { - return "ParserException"; -} - -const char *ParserException::what() const throw() { - return msg.c_str(); -} +#include "pexcept.h" BoolLVar *ConfigParser::parseBoolLVar(const std::string &varName) { if (varName == "export") Index: eval.cpp =================================================================== RCS file: /cvsroot/cmap/libs/eval/eval.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- eval.cpp 31 Oct 2004 09:06:40 -0000 1.2 +++ eval.cpp 24 Apr 2005 19:59:44 -0000 1.3 @@ -1,3 +1,5 @@ +// Copyright Denis Perchine <dy...@pe...>, 2004, 2005 + #include <string.h> #include <stdlib.h> --- NEW FILE: pexcept.cpp --- // Copyright Denis Perchine <dy...@pe...>, 2004, 2005 #include <stdio.h> #include "pexcept.h" ParserException::ParserException(const char *_msg, int _line) : msg(_msg), line(_line) { } ParserException::~ParserException() throw () { } void ParserException::raise(const char *_msg, int _lineno) { throw ParserException(_msg, _lineno); } const char *ParserException::name() const throw() { return "ParserException"; } const char *ParserException::what() const throw() { return msg.c_str(); } Index: eval.h =================================================================== RCS file: /cvsroot/cmap/libs/eval/eval.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- eval.h 31 Oct 2004 06:03:32 -0000 1.1.1.1 +++ eval.h 24 Apr 2005 19:59:51 -0000 1.2 @@ -1,5 +1,7 @@ -#ifndef __CMAP_EVAL_H__ -#define __CMAP_EVAL_H__ +// Copyright Denis Perchine <dy...@pe...>, 2004, 2005 + +#ifndef __EVAL_EVAL_H__ +#define __EVAL_EVAL_H__ #include <string> @@ -36,5 +38,4 @@ } ObjectProp; #endif -// __CMAP_EVAL_H__ - +// __EVAL_EVAL_H__ Index: tokenizer.cpp =================================================================== RCS file: /cvsroot/cmap/libs/eval/tokenizer.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- tokenizer.cpp 24 Feb 2005 11:13:15 -0000 1.7 +++ tokenizer.cpp 24 Apr 2005 19:59:51 -0000 1.8 @@ -1,3 +1,5 @@ +// Copyright Denis Perchine <dy...@pe...>, 2004, 2005 + #include <stdlib.h> #include <stdio.h> #include <string.h> Index: evalImpl.h =================================================================== RCS file: /cvsroot/cmap/libs/eval/evalImpl.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- evalImpl.h 31 Oct 2004 09:06:40 -0000 1.2 +++ evalImpl.h 24 Apr 2005 19:59:51 -0000 1.3 @@ -1,5 +1,7 @@ -#ifndef __CMAP_EVALIMPL_H__ -#define __CMAP_EVALIMPL_H__ +// Copyright Denis Perchine <dy...@pe...>, 2004, 2005 + +#ifndef __EVAL_EVALIMPL_H__ +#define __EVAL_EVALIMPL_H__ #include <string> #include <vector> @@ -584,4 +586,4 @@ }; #endif -// __CMAP_EVALIMPL_H__ +// __EVAL_EVALIMPL_H__ Index: tokenizer.h =================================================================== RCS file: /cvsroot/cmap/libs/eval/tokenizer.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- tokenizer.h 24 Feb 2005 11:11:59 -0000 1.4 +++ tokenizer.h 24 Apr 2005 19:59:51 -0000 1.5 @@ -1,7 +1,7 @@ -// Copyright Denis Perchine <dy...@pe...>, 2004 +// Copyright Denis Perchine <dy...@pe...>, 2004, 2005 -#ifndef __CMAP_TOKENIZER_H__ -#define __CMAP_TOKENIZER_H__ +#ifndef __EVAL_TOKENIZER_H__ +#define __EVAL_TOKENIZER_H__ #include <string> #include <exception> @@ -101,4 +101,4 @@ }; #endif -//__CMAP_TOKENIZER_H__ +//__EVAL_TOKENIZER_H__ Index: parser.h =================================================================== RCS file: /cvsroot/cmap/libs/eval/parser.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- parser.h 23 Feb 2005 11:10:12 -0000 1.4 +++ parser.h 24 Apr 2005 19:59:51 -0000 1.5 @@ -1,24 +1,12 @@ -#ifndef __CMAP_PARSER_H__ -#define __CMAP_PARSER_H__ +// Copyright Denis Perchine <dy...@pe...>, 2004, 2005 + +#ifndef __EVAL_PARSER_H__ +#define __EVAL_PARSER_H__ -#include <exception> #include <string> #include "tokenizer.h" #include "evalImpl.h" -class ParserException : public std::exception { -public: - ParserException(const char *_msg, int _lineno); - virtual ~ParserException() throw (); - static void raise(const char *_msg, int _lineno); - virtual const char *name() const throw(); - virtual const char *what() const throw(); - int lineno() const { return line; } -private: - std::string msg; - int line; -}; - class ConfigParser { public: ConfigParser(Tokenizer &_t) : t(_t) { @@ -34,7 +22,7 @@ IntExpr *parseIntVar(const std::string &varName); IntExpr *parseIntExpr(); - StringLVar *parseStringLVar(const std::string &varName); + virtual StringLVar *parseStringLVar(const std::string &varName); virtual StringRVar *parseStringRVar(const std::string &varName); StringExpr *parseStringVar(const std::string &varName); StringExpr *parseStringExpr(); @@ -55,4 +43,4 @@ }; #endif -// __CMAP_PARSER_H__ +// __EVAL_PARSER_H__ --- NEW FILE: pexcept.h --- // Copyright Denis Perchine <dy...@pe...>, 2004, 2005 #ifndef __EVAL_PEXCEPT_H__ #define __EVAL_PEXCEPT_H__ #include <exception> #include <string> class ParserException : public std::exception { public: ParserException(const char *_msg, int _lineno); virtual ~ParserException() throw (); static void raise(const char *_msg, int _lineno); virtual const char *name() const throw(); virtual const char *what() const throw(); int lineno() const { return line; } private: std::string msg; int line; }; #endif // __EVAL_PEXCEPT_H__ |
From: Denis P. <dy...@us...> - 2005-02-24 11:13:38
|
Update of /cvsroot/cmap/libs/eval In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16894 Modified Files: tokenizer.cpp Log Message: Format Index: tokenizer.cpp =================================================================== RCS file: /cvsroot/cmap/libs/eval/tokenizer.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- tokenizer.cpp 24 Feb 2005 11:11:59 -0000 1.6 +++ tokenizer.cpp 24 Feb 2005 11:13:15 -0000 1.7 @@ -50,7 +50,7 @@ forceLower = false; LINENO = 0; pushedBack = false; - produceCommentsP = false; + produceCommentsP = false; } void Tokenizer::printToken() const { |
From: Denis P. <dy...@us...> - 2005-02-24 11:12:24
|
Update of /cvsroot/cmap/libs/eval In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16620 Modified Files: tokenizer.cpp tokenizer.h Log Message: Format Index: tokenizer.h =================================================================== RCS file: /cvsroot/cmap/libs/eval/tokenizer.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- tokenizer.h 23 Feb 2005 11:10:13 -0000 1.3 +++ tokenizer.h 24 Feb 2005 11:11:59 -0000 1.4 @@ -54,8 +54,8 @@ void commentChar(char c); void produceComments(bool b) { - produceCommentsP = b; - } + produceCommentsP = b; + } void eolIsSignificant(bool b); long lineno() const; void lowerCaseMode(bool b); @@ -88,7 +88,7 @@ bool forceLower; bool pushedBack; bool isParseFloats; - bool produceCommentsP; + bool produceCommentsP; short ctype[256]; int peekc; Index: tokenizer.cpp =================================================================== RCS file: /cvsroot/cmap/libs/eval/tokenizer.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- tokenizer.cpp 23 Feb 2005 11:17:06 -0000 1.5 +++ tokenizer.cpp 24 Feb 2005 11:11:59 -0000 1.6 @@ -492,4 +492,3 @@ void Tokenizer::slashStarComments(bool b) { slashStarCommentsP = b; } - |
From: Denis P. <dy...@us...> - 2005-02-23 11:37:05
|
Update of /cvsroot/cmap/mp2mp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25424 Modified Files: mp_parser.cpp Log Message: Output 6 decimal points. Index: mp_parser.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp_parser.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- mp_parser.cpp 23 Feb 2005 11:19:22 -0000 1.3 +++ mp_parser.cpp 23 Feb 2005 11:36:53 -0000 1.4 @@ -85,7 +85,7 @@ } void point_t::print(FILE *f) { - fprintf(f, "(%.5f,%.5f)", y, x); + fprintf(f, "(%.6f,%.6f)", y, x); } MPParser::MPParser(Tokenizer &_t) : t(_t) { |
From: Denis P. <dy...@us...> - 2005-02-23 11:19:30
|
Update of /cvsroot/cmap/mp2mp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21650 Modified Files: mp2mp.cpp mp_parser.cpp mp_parser.h parserImpl.cpp Log Message: Comments are handled on tokenizer level. All exceptions contains line number. Index: parserImpl.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/parserImpl.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- parserImpl.cpp 14 Nov 2004 15:00:57 -0000 1.2 +++ parserImpl.cpp 23 Feb 2005 11:19:22 -0000 1.3 @@ -32,7 +32,7 @@ return var; if (varName == "attr") { if (t.nextToken() != TT_STRING) - throw ParserException("Attribute name expected"); + throw ParserException("Attribute name expected", t.lineno()); return new AttrVar(t.sval); } return NULL; @@ -45,14 +45,14 @@ case TT_WORD: break; default: - throw ParserException("Expected 'file'"); + throw ParserException("Expected 'file'", t.lineno()); } if (t.sval != "file") - throw ParserException("Expected 'file'"); + throw ParserException("Expected 'file'", t.lineno()); if (t.nextToken() != TT_STRING) - throw ParserException("Expected file name"); + throw ParserException("Expected file name", t.lineno()); ObjectConfImpl *obj = new ObjectConfImpl(t.sval.c_str()); Index: mp2mp.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp2mp.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- mp2mp.cpp 14 Nov 2004 15:00:57 -0000 1.2 +++ mp2mp.cpp 23 Feb 2005 11:19:21 -0000 1.3 @@ -9,6 +9,10 @@ #include "object.h" #include "mp_parser.h" +std::string headerFileName; +std::string mapID; +std::string mapName; + class Converter { public: Converter() { @@ -20,14 +24,19 @@ void Converter::process(FILE *f) { if (f != NULL) { - FILE *inHead = fopen("header.txt", "r"); + const char *fileName = headerFileName.empty() ? "header.txt" : headerFileName.c_str(); + const char *realMapID = mapID.empty() ? "11111111" : mapID.c_str(); + const char *realMapName = mapName.empty() ? "M" : mapName.c_str(); + FILE *inHead = fopen(fileName, "r"); int buf_header; if (!inHead) { - fprintf(stderr, "header.txt: File not found.\n"); + fprintf(stderr, "%s: File not found.\n", fileName); } else { while ((buf_header = fgetc(inHead)) != EOF) if (buf_header == '%') - fprintf(f, "%s", "11111111"); + fprintf(f, "%s", realMapID); + else if (buf_header == '$') + fprintf(f, "%s", realMapName); else fprintf (f, "%c", (unsigned char)buf_header); fprintf (f, "\n\n"); @@ -58,6 +67,7 @@ while (p.parseObject()) ; } catch (ParserException &) { + fprintf(stderr, "Error in file: '%s'\n", filename.c_str()); t.printToken(); fclose(f); throw; @@ -108,13 +118,47 @@ fclose(f); } +static void printUsage(const char *name) { + fprintf(stderr, "Usage: %s [-h header_file] <config> [<output>]\n", name); +} + +static std::string convertMapID(const char *s) { + std::string id = "111"; + id += (s[0] - 'A') / 10 + '0'; + id += (s[0] - 'A') % 10 + '0'; + id += s[2]; + id += s[3]; + id += s[5]; + + return id; +} + int main(int argc, char* argv[]) { bool doSplit = false; int firstArg = 1; + if (argc >= 2 && strcmp(argv[firstArg], "-h") == 0) { + if (argc < 3) { + printUsage(argv[0]); + return 1; + } + headerFileName = argv[firstArg + 1]; + firstArg += 2; + } + + if (argc >= firstArg + 1 && strcmp(argv[firstArg], "-m") == 0) { + if (argc < firstArg + 2) { + printUsage(argv[0]); + return 1; + } + mapName = argv[firstArg + 1]; + mapID = convertMapID(argv[firstArg + 1]); + firstArg += 2; + } + if (argc < firstArg + 1) { - fprintf(stderr, "Usage: %s <config> [<output>]\n", argv[0]); + printUsage(argv[0]); return 1; } const char *configFile = argv[firstArg]; Index: mp_parser.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp_parser.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- mp_parser.cpp 14 Nov 2004 15:00:57 -0000 1.2 +++ mp_parser.cpp 23 Feb 2005 11:19:22 -0000 1.3 @@ -85,7 +85,7 @@ } void point_t::print(FILE *f) { - fprintf(f, "(%.5f, %.5f)", y, x); + fprintf(f, "(%.5f,%.5f)", y, x); } MPParser::MPParser(Tokenizer &_t) : t(_t) { @@ -100,9 +100,11 @@ t.whitespaceChar('\n'); t.whitespaceChar('\r'); t.whitespaceChar('\t'); + t.produceComments(false); + t.commentChar(';'); } -static bool parseBool(const std::string &sval) { +bool MPParser::parseBool(const std::string &sval) { if (sval == "T") return true; if (sval == "F") @@ -112,56 +114,56 @@ if (sval == "N") return false; else - throw ParserException("Unknown boolean value"); + throw ParserException("Unknown boolean value", t.lineno()); } -static int parseInt(Tokenizer &t) { +int MPParser::parseInt() { if (t.nextToken() != TT_NUMBER) throw ParserException("Number expected", t.lineno()); return t.nval; } -static int parseInt(const std::string &sval) { +int MPParser::parseInt(const std::string &sval) { char *err = NULL; long res = strtol(sval.c_str(), &err, 10); if (err != NULL && *err != 0) - throw ParserException("Invalid number"); + throw ParserException("Invalid number", t.lineno()); return res; } -static float parseFloat(const std::string &sval) { +float MPParser::parseFloat(const std::string &sval) { char *err = NULL; float res = strtod(sval.c_str(), &err); if (err != NULL && *err != 0) - throw ParserException("Invalid float number"); + throw ParserException("Invalid float number", t.lineno()); return res; } void MPParser::parseHeader(Map &map) { if (t.nextToken() != '[') - throw ParserException("'[' expected"); + throw ParserException("'[' expected", t.lineno()); if (t.nextToken() != TT_WORD || t.sval != "img") - throw ParserException("'img' expected"); + throw ParserException("'img' expected", t.lineno()); if (t.nextToken() != TT_WORD || t.sval != "id") - throw ParserException("'id' expected"); + throw ParserException("'id' expected", t.lineno()); if (t.nextToken() != ']') - throw ParserException("']' expected"); + throw ParserException("']' expected", t.lineno()); for (;;) { int ttype = t.nextToken(); if (ttype == '[') { if (t.nextToken() != TT_WORD || t.sval != "end-img") - throw ParserException("'end-img' expected"); + throw ParserException("'end-img' expected", t.lineno()); if (t.nextToken() != TT_WORD || t.sval != "id") - throw ParserException("'id' expected"); + throw ParserException("'id' expected", t.lineno()); if (t.nextToken() != ']') - throw ParserException("']' expected"); + throw ParserException("']' expected", t.lineno()); break; } std::string varName = t.sval; if (ttype != TT_WORD) - throw ParserException("word expected"); + throw ParserException("word expected", t.lineno()); if (t.nextToken() != '=') throw ParserException("'=' expected", t.lineno()); t.nextToEOL(true); @@ -178,7 +180,7 @@ else if (t.sval == "F") map.elevation = Map::Feets; else - throw ParserException("Unknown elevation type"); + throw ParserException("Unknown elevation type", t.lineno()); } else if (varName == "preprocess") map.preprocess = parseBool(t.sval); else if (varName == "codepage") @@ -196,7 +198,7 @@ else if (varName.substr(0, 5) == "level") { } else if (varName.substr(0, 4) == "zoom") { } else - throw ParserException(("Unknown variable: " + varName).c_str()); + throw ParserException(("Unknown variable: " + varName).c_str(), t.lineno()); } } @@ -242,21 +244,23 @@ // Process comments for (;;) { ttype = t.nextToken(); - if (ttype != ';') + if (ttype != TT_COMMENT) break; - t.nextToEOL(true); size_t p; if ((p = t.sval.find('=')) == std::string::npos) continue; if (p == 0) continue; + size_t ns = 0; + while (ns < t.sval.length() && t.sval[ns] == ' ') + ns++; size_t np = p - 1; while (np > 0 && t.sval[np] == ' ') np--; if (np == 0) continue; Attr a; - a.name = t.sval.substr(0, np + 1); + a.name = t.sval.substr(ns, np + 1 - ns); size_t ep = p + 1; while (ep < t.sval.length() && t.sval[ep] == ' ') ep++; @@ -265,14 +269,14 @@ size_t ee = t.sval.length() - 1; while (ee > 0 && t.sval[ee] == ' ') ee--; - a.value = t.sval.substr(ep, ee); + a.value = t.sval.substr(ep, ee - ep + 1); rgn.attrs.push_back(a); } // Process region if (ttype != '[') - throw ParserException("'[' expected"); + throw ParserException("'[' expected", t.lineno()); if (t.nextToken() != TT_WORD || (t.sval != "polyline" && t.sval != "polygon" && t.sval != "poi")) - throw ParserException("'polyline', 'polygon' or 'poi' expected"); + throw ParserException("'polyline', 'polygon' or 'poi' expected", t.lineno()); enum Rgn::RgnType rgnType; if (t.sval == "polyline") rgnType = Rgn::Polyline; @@ -282,37 +286,37 @@ rgnType = Rgn::POI; if (t.nextToken() != ']') - throw ParserException("']' expected"); + throw ParserException("']' expected", t.lineno()); rgn.rgnType = rgnType; for (;;) { ttype = t.nextToken(); if (ttype == '[') { if (t.nextToken() != TT_WORD || t.sval != "end") - throw ParserException("'end' expected"); + throw ParserException("'end' expected", t.lineno()); if (t.nextToken() != ']') - throw ParserException("']' expected"); + throw ParserException("']' expected", t.lineno()); break; } std::string varName = t.sval; if (ttype != TT_WORD) - throw ParserException("word expected"); + throw ParserException("word expected", t.lineno()); if (t.nextToken() != '=') throw ParserException("'=' expected", t.lineno()); if (varName == "label") { t.nextToEOL(true); rgn.label = t.sval; } else if (varName == "endlevel") - rgn.endLevel = parseInt(t); + rgn.endLevel = parseInt(); else if (varName == "type") { - rgn.type = parseInt(t); + rgn.type = parseInt(); } else if (varName.substr(0, 4) == "data") { Element e(parseInt(varName.substr(4))); parseElement(e); rgn.elements.push_back(e); } else - throw ParserException(("Unknown variable: " + varName).c_str()); + throw ParserException(("Unknown variable: " + varName).c_str(), t.lineno()); } map.rgns.push_back(rgn); @@ -324,6 +328,7 @@ bool MPParser::parseObject() { parseHeader(map); + t.produceComments(true); while (parseRgn(map)) ; // while (t.nextToken() != TT_EOF) Index: mp_parser.h =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp_parser.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- mp_parser.h 14 Nov 2004 15:00:57 -0000 1.2 +++ mp_parser.h 23 Feb 2005 11:19:22 -0000 1.3 @@ -88,8 +88,13 @@ Map map; private: + bool parseBool(const std::string &sval); + int parseInt(); + int parseInt(const std::string &sval); + float parseFloat(const std::string &sval); + std::string filename; - Tokenizer t; + Tokenizer &t; }; #endif |
From: Denis P. <dy...@us...> - 2005-02-23 11:17:26
|
Update of /cvsroot/cmap/libs/eval In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21149 Modified Files: tokenizer.cpp Log Message: Fix TT_COMMENT handling. Index: tokenizer.cpp =================================================================== RCS file: /cvsroot/cmap/libs/eval/tokenizer.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- tokenizer.cpp 23 Feb 2005 11:10:12 -0000 1.4 +++ tokenizer.cpp 23 Feb 2005 11:17:06 -0000 1.5 @@ -222,7 +222,7 @@ while ((c = read()) != '\n' && c != '\r' && c >= 0) sval += (unsigned char)c; peekc = (char)c; - return TT_COMMENT; + return ttype = TT_COMMENT; } while ((c = read()) != '\n' && c != '\r' && c >= 0); peekc = (char)c; |
From: Denis P. <dy...@us...> - 2005-02-23 11:10:29
|
Update of /cvsroot/cmap/libs/eval In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19842 Modified Files: parser.cpp parser.h tokenizer.cpp tokenizer.h Log Message: Pass line number to all exceptions. This allows to print correct line number in error messages. Index: tokenizer.h =================================================================== RCS file: /cvsroot/cmap/libs/eval/tokenizer.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- tokenizer.h 7 Nov 2004 14:00:34 -0000 1.2 +++ tokenizer.h 23 Feb 2005 11:10:13 -0000 1.3 @@ -35,6 +35,7 @@ const int TT_FLOAT = -4; const int TT_WORD = -5; const int TT_STRING = -6; +const int TT_COMMENT = -7; const short CT_WHITESPACE = 1; const short CT_DIGIT = 2; @@ -52,6 +53,9 @@ Tokenizer(FILE *_f); void commentChar(char c); + void produceComments(bool b) { + produceCommentsP = b; + } void eolIsSignificant(bool b); long lineno() const; void lowerCaseMode(bool b); @@ -84,6 +88,7 @@ bool forceLower; bool pushedBack; bool isParseFloats; + bool produceCommentsP; short ctype[256]; int peekc; Index: parser.h =================================================================== RCS file: /cvsroot/cmap/libs/eval/parser.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- parser.h 7 Nov 2004 14:01:23 -0000 1.3 +++ parser.h 23 Feb 2005 11:10:12 -0000 1.4 @@ -8,9 +8,9 @@ class ParserException : public std::exception { public: - ParserException(const char *_msg, int lineno = 0); + ParserException(const char *_msg, int _lineno); virtual ~ParserException() throw (); - static void raise(const char *_msg); + static void raise(const char *_msg, int _lineno); virtual const char *name() const throw(); virtual const char *what() const throw(); int lineno() const { return line; } Index: parser.cpp =================================================================== RCS file: /cvsroot/cmap/libs/eval/parser.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- parser.cpp 7 Nov 2004 14:01:23 -0000 1.2 +++ parser.cpp 23 Feb 2005 11:10:12 -0000 1.3 @@ -9,8 +9,8 @@ ParserException::~ParserException() throw () { } -void ParserException::raise(const char *_msg) { - throw ParserException(_msg); +void ParserException::raise(const char *_msg, int _lineno) { + throw ParserException(_msg, _lineno); } const char *ParserException::name() const throw() { @@ -119,10 +119,10 @@ return e; if ((e = parseIntRVar(t.sval)) != NULL) return e; - throw ParserException(("Unknown variable: " + t.sval).c_str()); + throw ParserException(("Unknown variable: " + t.sval).c_str(), t.lineno()); } default: - throw ParserException("Integer expression expected"); + throw ParserException("Integer expression expected", t.lineno()); } } @@ -135,10 +135,10 @@ StringExpr *e = parseStringVar(t.sval); if (e != NULL) return e; - throw ParserException(("Unknown variable: " + t.sval).c_str()); + throw ParserException(("Unknown variable: " + t.sval).c_str(), t.lineno()); } default: - throw ParserException("String expression expected"); + throw ParserException("String expression expected", t.lineno()); } } @@ -152,15 +152,15 @@ else if (t.sval == "polygon") return new KindConst(kind::Polygon); else - throw ParserException("Type constant expected (point, line or polygon)"); + throw ParserException("Type constant expected (point, line or polygon)", t.lineno()); { KindExpr *e = parseKindLVar(t.sval); if (e != NULL) return e; - throw ParserException(("Unknown variable: " + t.sval).c_str()); + throw ParserException(("Unknown variable: " + t.sval).c_str(), t.lineno()); } default: - throw ParserException("Kind expression expected"); + throw ParserException("Kind expression expected", t.lineno()); } } @@ -173,7 +173,7 @@ return new NotExpr(parseBoolExpr()); if (t.ttype != TT_WORD) - throw ParserException("Boolean expression expected"); + throw ParserException("Boolean expression expected", t.lineno()); BoolExpr *e = parseBoolConst(t.sval); @@ -194,7 +194,7 @@ return new EQIntExpr(ie, parseIntExpr()); case '!': if (t.nextToken() != '=') - throw ParserException("Expect !="); + throw ParserException("Expect !=", t.lineno()); return new NEIntExpr(ie, parseIntExpr()); case '>': if (t.nextToken() != '=') { @@ -209,7 +209,7 @@ } else return new LEIntExpr(ie, parseIntExpr()); default: - throw ParserException("Expect =, !=, >, <, >=, <="); + throw ParserException("Expect =, !=, >, <, >=, <=", t.lineno()); }; } else if ((se = parseStringVar(t.sval)) != NULL) { switch (t.nextToken()) { @@ -217,10 +217,10 @@ return new EQStringExpr(se, parseStringExpr()); case '!': if (t.nextToken() != '=') - throw ParserException("Expect !="); + throw ParserException("Expect !=", t.lineno()); return new NEStringExpr(se, parseStringExpr()); default: - throw ParserException("Expected = or !="); + throw ParserException("Expected = or !=", t.lineno()); } } else if ((sv = parseSetVar(t.sval)) != NULL) { switch (t.nextToken()) { @@ -228,10 +228,10 @@ return new InExpr(sv, parseIntExpr()); case '!': if (t.nextToken() != '=') - throw ParserException("Expect !="); + throw ParserException("Expect !=", t.lineno()); return new NotInExpr(sv, parseIntExpr()); default: - throw ParserException("Expected = or !="); + throw ParserException("Expected = or !=", t.lineno()); } } else if ((kv = parseKindLVar(t.sval)) != NULL) { switch (t.nextToken()) { @@ -239,13 +239,13 @@ return new EQKindExpr(kv, parseKindExpr()); case '!': if (t.nextToken() != '=') - throw ParserException("Expect !="); + throw ParserException("Expect !=", t.lineno()); return new NEKindExpr(kv, parseKindExpr()); default: - throw ParserException("Expected = or !="); + throw ParserException("Expected = or !=", t.lineno()); } } else - throw ParserException(("Unknown variable: " + t.sval).c_str()); + throw ParserException(("Unknown variable: " + t.sval).c_str(), t.lineno()); } void ConfigParser::parseAssign(Block *b, const std::string &varName) { @@ -253,12 +253,12 @@ if (bVar != NULL) { // boolean vars if (t.nextToken() != '=') - throw ParserException("Expected '='"); + throw ParserException("Expected '='", t.lineno()); BoolAssign *a = new BoolAssign(); a->lvalue = bVar; a->rvalue = parseBoolExpr(); if (a->rvalue == NULL) - throw ParserException("Boolean expression expected"); + throw ParserException("Boolean expression expected", t.lineno()); b->addAssign(a); return; @@ -274,17 +274,17 @@ break; case '+': if (t.nextToken() != '=') - throw ParserException("Expected '+='"); + throw ParserException("Expected '+='", t.lineno()); a = new IntPlusAssign(); break; default: - throw ParserException("Expected '=' or '+='"); + throw ParserException("Expected '=' or '+='", t.lineno()); } a->rvalue = parseIntExpr(); a->lvalue = iVar; if (a->rvalue == NULL) - throw ParserException("Integer expression expected"); + throw ParserException("Integer expression expected", t.lineno()); b->addAssign(a); return; @@ -300,17 +300,17 @@ break; case '+': if (t.nextToken() != '=') - throw ParserException("Expected '+='"); + throw ParserException("Expected '+='", t.lineno()); a = new StringPlusAssign(); break; default: - throw ParserException("Expected '=' or '+='"); + throw ParserException("Expected '=' or '+='", t.lineno()); } a->rvalue = parseStringExpr(); a->lvalue = sVar; if (a->rvalue == NULL) - throw ParserException("String expression expected"); + throw ParserException("String expression expected", t.lineno()); b->addAssign(a); return; @@ -319,7 +319,7 @@ KindLVar *kVar = parseKindLVar(varName); if (kVar == NULL) - throw ParserException(("Unknown variable: " + varName).c_str()); + throw ParserException(("Unknown variable: " + varName).c_str(), t.lineno()); KindAssign *a; switch (t.nextToken()) { @@ -327,20 +327,20 @@ a = new KindAssign(); break; default: - throw ParserException("Expected '='"); + throw ParserException("Expected '='", t.lineno()); } a->rvalue = parseKindExpr(); a->lvalue = kVar; if (a->rvalue == NULL) - throw ParserException("Kind expression expected"); + throw ParserException("Kind expression expected", t.lineno()); b->addAssign(a); } void ConfigParser::parseBlock(Block *b, ObjectConf *obj) { if (t.nextToken() != '{') - throw ParserException("Expected '{'"); + throw ParserException("Expected '{'", t.lineno()); if (obj != NULL) parseBlockStart(obj); @@ -351,7 +351,7 @@ if (t.nextToken() == '}') break; if (t.ttype != TT_WORD) - throw ParserException("Expected variable name or '}'"); + throw ParserException("Expected variable name or '}'", t.lineno()); if (t.sval == "case") { Case *c = new Case(parseBoolExpr()); parseBlock(c); @@ -360,7 +360,7 @@ varName = t.sval; parseAssign(b, varName); if (t.nextToken() != ';') - throw ParserException("Expected ';'"); + throw ParserException("Expected ';'", t.lineno()); } } } Index: tokenizer.cpp =================================================================== RCS file: /cvsroot/cmap/libs/eval/tokenizer.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- tokenizer.cpp 20 Nov 2004 04:59:19 -0000 1.3 +++ tokenizer.cpp 23 Feb 2005 11:10:12 -0000 1.4 @@ -50,6 +50,7 @@ forceLower = false; LINENO = 0; pushedBack = false; + produceCommentsP = false; } void Tokenizer::printToken() const { @@ -72,6 +73,9 @@ case TT_STRING: printf("%ld: string: %s\n", lineno(), sval.c_str()); break; + case TT_COMMENT: + printf("%ld: comment: %s\n", lineno(), sval.c_str()); + break; default: printf("%ld: char: %c\n", lineno(), (unsigned char)ttype); break; @@ -213,8 +217,16 @@ } if ((_ctype & CT_COMMENT) != 0) { + if (produceCommentsP) { + sval = ""; + while ((c = read()) != '\n' && c != '\r' && c >= 0) + sval += (unsigned char)c; + peekc = (char)c; + return TT_COMMENT; + } while ((c = read()) != '\n' && c != '\r' && c >= 0); peekc = (char)c; + return nextToken(); } |
From: Denis P. <dy...@us...> - 2005-02-05 12:12:49
|
Update of /cvsroot/cmap/cmap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18748 Modified Files: parserImpl.h object.h cmap.dsp Log Message: Fix compilation with the latest MS SDK. Index: parserImpl.h =================================================================== RCS file: /cvsroot/cmap/cmap/parserImpl.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- parserImpl.h 31 Oct 2004 09:06:40 -0000 1.1 +++ parserImpl.h 5 Feb 2005 12:12:27 -0000 1.2 @@ -1,7 +1,7 @@ #ifndef __CMAP_PARSERIMPL_H__ #define __CMAP_PARSERIMPL_H__ -#include "parser.h" +#include <eval/parser.h> #include "IngitFile.h" class ConfigParserImpl : public ConfigParser { Index: object.h =================================================================== RCS file: /cvsroot/cmap/cmap/object.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- object.h 31 Oct 2004 09:06:39 -0000 1.1 +++ object.h 5 Feb 2005 12:12:27 -0000 1.2 @@ -1,7 +1,7 @@ #ifndef __OBJECT_H__ #define __OBJECT_H__ -#include "evalImpl.h" +#include <eval/evalImpl.h> class ObjectConfImpl : public ObjectConf { public: Index: cmap.dsp =================================================================== RCS file: /cvsroot/cmap/cmap/cmap.dsp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- cmap.dsp 31 Oct 2004 09:06:39 -0000 1.8 +++ cmap.dsp 5 Feb 2005 12:12:27 -0000 1.9 @@ -41,7 +41,7 @@ # 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 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /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 |
From: Denis P. <dy...@us...> - 2004-11-20 04:59:29
|
Update of /cvsroot/cmap/libs/eval In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7802 Modified Files: tokenizer.cpp Log Message: Fix infinite loop when striping. Index: tokenizer.cpp =================================================================== RCS file: /cvsroot/cmap/libs/eval/tokenizer.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- tokenizer.cpp 7 Nov 2004 14:00:34 -0000 1.2 +++ tokenizer.cpp 20 Nov 2004 04:59:19 -0000 1.3 @@ -374,7 +374,7 @@ break; if ((ctype[(int)(unsigned char)sval[(unsigned int)len - 1]] & CT_WHITESPACE) == 0) break; - sval.resize(len); + sval.resize(len - 1); } } } |
From: Denis P. <dy...@us...> - 2004-11-14 15:01:11
|
Update of /cvsroot/cmap/mp2mp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11758 Modified Files: mp2mp.cpp mp2mp.dsp mp_parser.cpp mp_parser.h object.cpp parserImpl.cpp Log Message: Implement attributes handling First working version with converting. Index: mp2mp.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp2mp.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- mp2mp.cpp 7 Nov 2004 13:58:57 -0000 1.1.1.1 +++ mp2mp.cpp 14 Nov 2004 15:00:57 -0000 1.2 @@ -39,8 +39,10 @@ file->process(f); } +const char *outFile; + void ObjectConfImpl::process(FILE *fo) { - printf("Processing: %s\n", filename.c_str()); + fprintf(stderr, "Processing: %s\n", filename.c_str()); FILE *f = fopen(filename.c_str(), "rt"); if (f == NULL) { @@ -61,6 +63,14 @@ throw; } +// 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; + if (handle(&rgn, op, 0)) + rgn.print(fo, op); + } + fclose(f); } @@ -98,8 +108,6 @@ fclose(f); } -const char *outFile; - int main(int argc, char* argv[]) { bool doSplit = false; Index: object.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/object.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- object.cpp 7 Nov 2004 13:58:57 -0000 1.1.1.1 +++ object.cpp 14 Nov 2004 15:00:57 -0000 1.2 @@ -1,8 +1,29 @@ #include "object.h" +#include "mp_parser.h" ObjectConfImpl *firstObj = NULL; void ObjectConfImpl::init(const void *obj, ObjectProp &o) { + const Rgn *rgn = (const Rgn *)obj; + + o.index = false; + o.city = 0; + + o.garminType = rgn->type; + o.layerMax = rgn->endLevel; + o.label = rgn->label; + + switch (rgn->rgnType) { + case Rgn::POI: + o.kind = kind::Point; + break; + case Rgn::Polyline: + o.kind = kind::Line; + break; + case Rgn::Polygon: + o.kind = kind::Polygon; + break; + } } void add(ObjectConfImpl *obj) { Index: mp_parser.h =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp_parser.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- mp_parser.h 7 Nov 2004 13:58:57 -0000 1.1.1.1 +++ mp_parser.h 14 Nov 2004 15:00:57 -0000 1.2 @@ -48,7 +48,7 @@ std::list<Attr> attrs; std::list<Element> elements; - void print(FILE *f); + void print(FILE *f, const ObjectProp &op); }; class Map { @@ -72,7 +72,8 @@ int rgnLimit; bool POIIndex; - void print(FILE *f); +// void print(FILE *f); + void printHeader(FILE *f); std::list<Rgn> rgns; }; @@ -84,6 +85,8 @@ bool parseRgn(Map &map); void parseElement(Element &e); bool parseObject(); + + Map map; private: std::string filename; Tokenizer t; Index: parserImpl.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/parserImpl.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- parserImpl.cpp 7 Nov 2004 13:58:57 -0000 1.1.1.1 +++ parserImpl.cpp 14 Nov 2004 15:00:57 -0000 1.2 @@ -1,5 +1,6 @@ #include "parserImpl.h" #include "object.h" +#include "mp_parser.h" class AttrVar : public StringRVar { public: @@ -10,6 +11,11 @@ } 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; } Index: mp2mp.dsp =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp2mp.dsp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- mp2mp.dsp 7 Nov 2004 13:58:57 -0000 1.1.1.1 +++ mp2mp.dsp 14 Nov 2004 15:00:57 -0000 1.2 @@ -49,8 +49,8 @@ # 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 +# 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)" == "mp2mp - Win32 Debug" @@ -65,16 +65,16 @@ # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "eval" /I "." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "eval" /I "." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /GZ /c # ADD BASE RSC /l 0x419 /d "_DEBUG" # ADD RSC /l 0x419 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# 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 Index: mp_parser.cpp =================================================================== RCS file: /cvsroot/cmap/mp2mp/mp_parser.cpp,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- mp_parser.cpp 7 Nov 2004 13:58:57 -0000 1.1.1.1 +++ mp_parser.cpp 14 Nov 2004 15:00:57 -0000 1.2 @@ -3,7 +3,7 @@ Map::Map() { } -void Map::print(FILE *f) { +void Map::printHeader(FILE *f) { fprintf(f, "id = %s\n", id.c_str()); fprintf(f, "name = %s\n", name.c_str()); fprintf(f, "typeSet = %s\n", typeSet.c_str()); @@ -25,10 +25,15 @@ fprintf(f, "POIIndex = %s\n", POIIndex ? "true" : "false"); fprintf(f, "\n"); +} +/* +void Map::print(FILE *f) { + printHeader(f); for (std::list<Rgn>::iterator it = rgns.begin(); it != rgns.end(); it++) (*it).print(f); } +*/ void Attr::print(FILE *f) { fprintf(f, "; %s=%s\n", name.c_str(), value.c_str()); @@ -37,7 +42,7 @@ Rgn::Rgn() : rgnType(POI), type(0), endLevel(0) { } -void Rgn::print(FILE *f) { +void Rgn::print(FILE *f, const ObjectProp &op) { for (std::list<Attr>::iterator it = attrs.begin(); it != attrs.end(); it++) (*it).print(f); @@ -53,13 +58,12 @@ break; }; - if (type != 0) - fprintf(f, "Type=0x%x\n", type); + fprintf(f, "Type=0x%x\n", op.garminType); - if (endLevel != 0) - fprintf(f, "EndLevel=%d\n", endLevel); - if (label.length() > 0) - fprintf(f, "Label=%s\n", label.c_str()); + 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()); for (std::list<Element>::iterator it2 = elements.begin(); it2 != elements.end(); it2++) (*it2).print(f); @@ -319,11 +323,9 @@ } bool MPParser::parseObject() { - Map map; parseHeader(map); while (parseRgn(map)) ; - map.print(stdout); // while (t.nextToken() != TT_EOF) // t.printToken(); return false; |