osrm-backend/traffic_updater/README.md
Xun(Perry) Liu cbd192c52e feat: Implement logic to generate way-2-nodes mapping and convert traffic result to nodes-2-speed (#28)
* feat: Implement logic to generate way-2-nodes mapping and convert from way-2-speed to nodes-2-speed for OSRM

Issue: https://github.com/Telenav/osrm-backend/issues/22

* fix:Comments and typo in traffic generator.

* fix: Fix the issue of protocal and refine function names

* fix: Remove suffix of "100" for telenav wayids

* feat: Add unit test for generatespeedtable

* fix: Avoid upload test pbf into git

* feat: Handle traffic flow and add related unit test

* Update Readme

* fix: enable real function

(cherry picked from commit 81015b9977847ffe61c7e8793e1cecb229727a07)

* docs: fix a typo
2019-06-28 11:10:54 +08:00

56 lines
2.3 KiB
Markdown

# OSRM Traffic Updater
The **OSRM Traffic Updater** is designed for pull traffic data from **Traffic Proxy(Telenav)** then dump to OSRM required `traffic.csv`. Refer to [OSRM with Telenav Traffic Design](../docs/design/osrm-with-telenav-traffic.md) and [OSRM Traffic](https://github.com/Project-OSRM/osrm-backend/wiki/Traffic) for more details.
We have implemented both `Python` and `Go` version. Both of them have same function(pull data then dump to csv), but the `Go` implementation is about **23 times** faster than `Python` implementation. So strongly recommended to use `Go` implementation as preference.
- E.g. `6727490` lines traffic of NA region
- `Go` Implementation: about `9 seconds`
- `Python` Implementation: about `210 seconds`
## RPC Protocol
See [proxy.thrift](proxy.thrift) for details.
## Python Implementation
The `python` based implementation has been deprecated due to bad performance. See [Deprecated Python Implementation Codes](https://github.com/Telenav/osrm-backend/blob/b4eb73f2d307fd4dbd8b8610bbc2a68c3b6ab1ae/traffic_updater/python/osrm_traffic_updater.py#L57) if you'd like to see code details.
## Go Implementation
### Requirements
- `go version go1.12.5 linux/amd64`
- `thrift 0.12.0`
- clone `thrift` from `github.com/apache/thrift`, then checkout branch `0.12.0`
- change `thrift` imports in generated codes `gen-go/proxy`
- `git.apache.org/thrift.git/lib/go/thrift` -> `github.com/apache/thrift/lib/go/thrift`
### Usage
```bash
$ cd $GOPATH
$ go install github.com/Telenav/osrm-backend/traffic_updater/go/osrm_traffic_updater
$ ./bin/osrm_traffic_updater -h
Usage of ./bin/osrm_traffic_updater:
-c string
traffic proxy ip address (default "127.0.0.1")
-d use high precision speeds, i.e. decimal. (default false)
-f string
OSRM traffic csv file (default "traffic.csv")
-m string
OSRM way id to node ids mapping table (default "wayid2nodeids.csv")
-p int
traffic proxy listening port (default 6666)
```
# wayid2nodeids_extractor
Extract wayid to nodeids mapping from PBF
### Usage
```bash
$ cd $GOPATH
$ go install github.com/Telenav/osrm-backend/traffic_updater/go/wayid2nodeid_extractor
$ ./bin/wayid2nodeid_extractor -h
Usage of ./bin/wayid2nodeid_extractor:
-b Is pbf generated by telenav internally
-i string
Input pbf file.
-o string
Output csv file
```