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:
authorSergey Yershov <syershov@maps.me>2016-12-12 17:03:48 +0300
committerGitHub <noreply@github.com>2016-12-12 17:03:48 +0300
commit11c08c6c0f9097b9f01ceb2f88d04d3250aca1d3 (patch)
treec37b59ad8c5ea994f8d85a0f84d29a9d469a6175 /traffic
parentced9f3bb904916d378b935208a384cde87a72759 (diff)
parentd1a006315611088726874884ab9ab569a42e9605 (diff)
Merge pull request #4955 from mpimenov/traffic-python-fields
[traffic] Python bindings for struct fields.
Diffstat (limited to 'traffic')
-rw-r--r--traffic/pytraffic/bindings.cpp9
-rw-r--r--traffic/pytraffic/example.py7
-rw-r--r--traffic/traffic_info.hpp4
3 files changed, 19 insertions, 1 deletions
diff --git a/traffic/pytraffic/bindings.cpp b/traffic/pytraffic/bindings.cpp
index aacf206f95..e44256b2d2 100644
--- a/traffic/pytraffic/bindings.cpp
+++ b/traffic/pytraffic/bindings.cpp
@@ -153,10 +153,17 @@ BOOST_PYTHON_MODULE(pytraffic)
vector_uint8t_from_python_str();
class_<SegmentSpeeds>("SegmentSpeeds", init<double, double, double>())
- .def("__repr__", &SegmentSpeedsRepr);
+ .def("__repr__", &SegmentSpeedsRepr)
+ .def_readwrite("weighted_speed", &SegmentSpeeds::m_weightedSpeed)
+ .def_readwrite("weighted_ref_speed", &SegmentSpeeds::m_weightedRefSpeed)
+ .def_readwrite("weight", &SegmentSpeeds::m_weight)
+ ;
class_<traffic::TrafficInfo::RoadSegmentId>("RoadSegmentId", init<uint32_t, uint16_t, uint8_t>())
.def("__repr__", &RoadSegmentIdRepr)
+ .add_property("fid", &traffic::TrafficInfo::RoadSegmentId::GetFid)
+ .add_property("idx", &traffic::TrafficInfo::RoadSegmentId::GetIdx)
+ .add_property("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..87a8ff1d88 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].fid, keys[2].idx, keys[2].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.weighted_speed, seg_speeds.weighted_ref_speed, seg_speeds.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;