GISCup 2015
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
NewRoadAttrib.hpp
Go to the documentation of this file.
1 /* Copyright 2015 Martin Werner - <martin.werner@ifi.lmu.de>
2  *
3  * This program is free software: you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation, either version 3 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */#ifndef NewRoadAttrib_HPP_INC
16 #define NewRoadAttrib_HPP_INC
18 public:
19  long EDGEID;
20  long STARTID;
21  long ENDID;
22  double LENGTH;
23  double SPD;
24 static inline std::string fieldname(size_t id) {
25 switch(id){
26  case 0: return std::string("EDGEID");
27  case 1: return std::string("STARTID");
28  case 2: return std::string("ENDID");
29  case 3: return std::string("LENGTH");
30  case 4: return std::string("SPD");
31  default: return std::string("unknown fieldname");
32 }}; //fieldname
33 static bool assertCorrectFormat(DBFHandle hDBF)
34 {
35  size_t fields = DBFGetFieldCount(hDBF);
36  for (size_t i=0; i < fields; i++)
37  {
38  char name[20];
39  size_t type = DBFGetFieldInfo(hDBF,i,name, NULL, NULL);
40  if (fieldname(i) != name)
41  {
42  cout << "File DBF in wrong format" << endl;
43  cout << fieldname(i) << " expected. Found " << name << endl;
44  return false;
45  }
46  }
47  return true;
48 }
49 void readFromID(DBFHandle hDBF, size_t id) {
50  EDGEID = DBFReadIntegerAttribute(hDBF,id, 0);
51  STARTID = DBFReadIntegerAttribute(hDBF,id, 1);
52  ENDID = DBFReadIntegerAttribute(hDBF,id, 2);
53  LENGTH = _DBFReadDoubleAttribute(hDBF,id, 3);
54  SPD = _DBFReadDoubleAttribute(hDBF,id, 4);
55 };
56 void dump()
57 {
58  dump(cout);
59 }
60 template<typename stream> void dump(stream &o) {
61  o << "EDGEID" <<":\t" << EDGEID << std::endl;
62  o << "STARTID" <<":\t" << STARTID << std::endl;
63  o << "ENDID" <<":\t" << ENDID << std::endl;
64  o << "LENGTH" <<":\t" << LENGTH << std::endl;
65  o << "SPD" <<":\t" << SPD << std::endl;
66 };
67 };
68 #endif