Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Pimenov <m@maps.me>2016-12-12 14:25:39 +0300
committerMaxim Pimenov <m@maps.me>2016-12-12 14:25:39 +0300
commit9bfa0ab864d251b00356b1e0d83f9e15b27b72ef (patch)
tree4e03a0c03e9f2a23eca3ccb164cb6f6abc83a586 /traffic
parente86e847c42c9e04d1daef8084ebf28e3df6cfa13 (diff)
[traffic] Python bindings for struct fields.
Diffstat (limited to 'traffic')
-rw-r--r--traffic/pytraffic/bindings.cpp13
-rw-r--r--traffic/pytraffic/example.py7
-rw-r--r--traffic/traffic_info.hpp4
3 files changed, 23 insertions, 1 deletions
diff --git a/traffic/pytraffic/bindings.cpp b/traffic/pytraffic/bindings.cpp
index aacf206f95..8cee3ca28c 100644
--- a/traffic/pytraffic/bindings.cpp
+++ b/traffic/pytraffic/bindings.cpp
@@ -34,6 +34,10 @@ struct SegmentSpeeds
{
}
+ double GetWeightedSpeed() const { return m_weightedSpeed; }
+ double GetWeightedRefSpeed() const { return m_weightedRefSpeed; }
+ double GetWeight() const { return m_weight; }
+
double m_weightedSpeed = 0;
double m_weightedRefSpeed = 0;
double m_weight = 0;
@@ -153,10 +157,17 @@ BOOST_PYTHON_MODULE(pytraffic)
vector_uint8t_from_python_str();
class_<SegmentSpeeds>("SegmentSpeeds", init<double, double, double>())
- .def("__repr__", &SegmentSpeedsRepr);
+ .def("__repr__", &SegmentSpeedsRepr)
+ .def("get_weighted_speed", &SegmentSpeeds::GetWeightedSpeed)
+ .def("get_weighted_ref_speed", &SegmentSpeeds::GetWeightedRefSpeed)
+ .def("get_weight", &SegmentSpeeds::GetWeight)
+ ;
class_<traffic::TrafficInfo::RoadSegmentId>("RoadSegmentId", init<uint32_t, uint16_t, uint8_t>())
.def("__repr__", &RoadSegmentIdRepr)
+ .def("get_fid", &traffic::TrafficInfo::RoadSegmentId::GetFid)
+ .def("get_idx", &traffic::TrafficInfo::RoadSegmentId::GetIdx)
+ .def("get_dir", &traffic::TrafficInfo::RoadSegmentId::GetDir)
;
class_<std::vector<traffic::TrafficInfo::RoadSegmentId>>("RoadSegmentIdVec")
diff --git a/traffic/pytraffic/example.py b/traffic/pytraffic/example.py
index 79c2e8ff73..05b751d950 100644
--- a/traffic/pytraffic/example.py
+++ b/traffic/pytraffic/example.py
@@ -18,8 +18,15 @@ keys = [
RoadSegmentId(1, 0, 1),
]
+fid, idx, dir = keys[2].get_fid(), keys[2].get_idx(), keys[2].get_dir()
+print fid, idx, dir
+
keys_from_mwm = generate_traffic_keys(options.path_to_mwm)
+seg_speeds = SegmentSpeeds(1.0, 2.0, 3.0)
+ws, wrs, w = seg_speeds.get_weighted_speed(), seg_speeds.get_weighted_ref_speed(), seg_speeds.get_weight()
+print ws, wrs, w
+
mapping = {
RoadSegmentId(0, 0, 0):SegmentSpeeds(1.0, 2.0, 3.0),
RoadSegmentId(1, 0, 1):SegmentSpeeds(4.0, 5.0, 6.0),
diff --git a/traffic/traffic_info.hpp b/traffic/traffic_info.hpp
index b687ab2a6e..0dd75cb946 100644
--- a/traffic/traffic_info.hpp
+++ b/traffic/traffic_info.hpp
@@ -58,6 +58,10 @@ public:
return m_dir < o.m_dir;
}
+ uint32_t GetFid() const { return m_fid; }
+ uint16_t GetIdx() const { return m_idx; }
+ uint8_t GetDir() const { return m_dir; }
+
// The ordinal number of feature this segment belongs to.
uint32_t m_fid;