refactoring

This commit is contained in:
Patrick Brosi 2018-08-01 14:25:54 +02:00
parent 04e87c1d9c
commit 64b83f569c
24 changed files with 186 additions and 310 deletions

View file

@ -108,11 +108,12 @@ const util::geo::FLine* EdgePL::getGeom() const { return _l; }
util::geo::FLine* EdgePL::getGeom() { return _l; }
// _____________________________________________________________________________
void EdgePL::getAttrs(std::map<std::string, std::string>* obj) const {
(*obj)["m_length"] = std::to_string(_length);
(*obj)["oneway"] = std::to_string(static_cast<int>(_oneWay));
(*obj)["level"] = std::to_string(_lvl);
(*obj)["restriction"] = isRestricted() ? "yes" : "no";
util::json::Dict EdgePL::getAttrs() const {
util::json::Dict obj;
obj["m_length"] = std::to_string(_length);
obj["oneway"] = std::to_string(static_cast<int>(_oneWay));
obj["level"] = std::to_string(_lvl);
obj["restriction"] = isRestricted() ? "yes" : "no";
std::stringstream ss;
bool first = false;
@ -127,7 +128,8 @@ void EdgePL::getAttrs(std::map<std::string, std::string>* obj) const {
first = true;
}
(*obj)["lines"] = ss.str();
obj["lines"] = ss.str();
return obj;
}
// _____________________________________________________________________________

View file

@ -57,7 +57,7 @@ class EdgePL : public GeoEdgePL<float> {
void addPoint(const util::geo::FPoint& p);
// Fill obj with k/v pairs describing the parameters of this payload.
void getAttrs(std::map<std::string, std::string>* obj) const;
util::json::Dict getAttrs() const;
// Return the length in meters stored for this edge payload
double getLength() const;

View file

@ -114,18 +114,19 @@ const util::geo::FPoint* NodePL::getGeom() const { return &_geom; }
void NodePL::setGeom(const util::geo::FPoint& geom) { _geom = geom; }
// _____________________________________________________________________________
void NodePL::getAttrs(std::map<std::string, std::string>* obj) const {
(*obj)["component"] = std::to_string(reinterpret_cast<size_t>(_component));
util::json::Dict NodePL::getAttrs() const {
util::json::Dict obj;
obj["component"] = std::to_string(reinterpret_cast<size_t>(_component));
#ifdef PFAEDLE_DBG
(*obj)["dijkstra_vis"] = _vis ? "yes" : "no";
obj["dijkstra_vis"] = _vis ? "yes" : "no";
#endif
if (getSI()) {
(*obj)["station_info_ptr"] = util::toString(_si);
(*obj)["station_name"] = _si->getName();
(*obj)["station_alt_names"] = util::implode(_si->getAltNames(), ",");
(*obj)["from_osm"] = _si->isFromOsm() ? "yes" : "no";
(*obj)["station_platform"] = _si->getTrack();
(*obj)["station_group"] =
obj["station_info_ptr"] = util::toString(_si);
obj["station_name"] = _si->getName();
obj["station_alt_names"] = util::implode(_si->getAltNames(), ",");
obj["from_osm"] = _si->isFromOsm() ? "yes" : "no";
obj["station_platform"] = _si->getTrack();
obj["station_group"] =
std::to_string(reinterpret_cast<size_t>(_si->getGroup()));
std::stringstream gtfsIds;
@ -135,8 +136,9 @@ void NodePL::getAttrs(std::map<std::string, std::string>* obj) const {
}
}
(*obj)["station_group_stops"] = gtfsIds.str();
obj["station_group_stops"] = gtfsIds.str();
}
return obj;
}
// _____________________________________________________________________________

View file

@ -37,7 +37,7 @@ class NodePL : public GeoNodePL<float> {
void setGeom(const util::geo::FPoint& geom);
// Fill obj with k/v pairs describing the parameters of this payload.
void getAttrs(std::map<std::string, std::string>* attrs) const;
util::json::Dict getAttrs() const;
// Set the station info for this node
void setSI(const StatInfo& si);