SdOsmMapParser.cpp 3 KB
Newer Older
oscar's avatar
oscar committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96

// #include "SdOsmMapParser.h"

// #include <iostream>
// #include <map>

// #include "CoordSys.h"
// #include "Log.h"
// #include "Utils.h"

// using namespace jf;

// SdNode SdSsmParser::readXmlNode(TiXmlElement *element) {
//     SdNode n;
//     uint64_t osmNodeId = std::stoull(element->Attribute(PARAM_ID));
//     n.id_p.p.dLon = std::stod(element->Attribute(PARAM_LON));
//     n.id_p.p.dLat = std::stod(element->Attribute(PARAM_LAT));

//     // 将osm的id做成由lon和lat计算出的。
//     nodeIdMap.insert(std::make_pair(osmNodeId, n.id_p));

//     const char *big = element->Attribute(PARAM_SPEEDLIMITED_TYPE1);
//     if (big) {
//         n.speed_limit_big = std::stod(big);
//         if (n.speed_limit_big == 0) {
//             // jf_log_error("big_speed {}", n.lValue);
//         }
//     } else {
//         // jf_log_error("big_speed {}", n.lValue);
//     }
//     const char *small = element->Attribute(PARAM_SPEEDLIMITED_TYPE0);
//     if (small) {
//         n.speed_limit_small = std::stod(small);
//         if (n.speed_limit_small == 0) {
//             // jf_log_error("small_speed {}", n.lValue);
//         }
//     } else {
//         // jf_log_error("small_speed {}", n.lValue);
//     }

//     TiXmlElement *pTag = element->FirstChildElement(TAG);

//     // if (pTag != nullptr)
//     //  n.tags = readXmlTags(pTag);

//     return n;
// }

// std::map<std::string, std::string> SdSsmParser::readXmlTags(TiXmlElement *element) {
//     std::map<std::string, std::string> ret;
//     do {
//         std::string key = element->Attribute(TAG_KEY);
//         std::string val = element->Attribute(TAG_VALUE);

//         ret[key] = val;
//     } while ((element = element->NextSiblingElement(TAG)) != nullptr);
//     return ret;
// }

// BaseWay SdSsmParser::readXmlWay(TiXmlElement *element) {
//     BaseWay w;
//     std::string s = element->Attribute(PARAM_ID);
//     w.id = std::stoull(s);

//     element = element->FirstChildElement();
//     do {
//         if (!strcmp(element->Value(), TAG)) {
//             std::map<std::string, std::string> tags = readXmlTags(element);

//             std::string l;
//             std::string ltag("level");
//             if (Utils::MapValue(tags, ltag, l)) {
//                 w.level = std::stod(l);
//             }
//             continue;
//         }

//         if (!strcmp(element->Value(), ND)) {
//             uint64_t osmNodeId = std::stoull(element->Attribute(ND_REF));
//             SdNodeId node_ref_id = nodeIdMap[osmNodeId];
//             w.nodes.push_back(node_ref_id);
//         }
//     } while ((element = element->NextSiblingElement()) != nullptr);
//     return w;
// }

// /*
// osmBound SdSsmParser::readXmlBounds(TiXmlElement *element)
// {
//   double minlon = atof(element->Attribute(BOUND_MIN_LON));
//   double minlat = atof(element->Attribute(BOUND_MIN_LAT));
//   double maxlon = atof(element->Attribute(BOUND_MAX_LON));
//   double maxlat = atof(element->Attribute(BOUND_MAX_LAT));
//   return osmBound(minlon, minlat, maxlon, maxlat);
// }
// */