In this Chapter, we are going to setup a Histraffic Server
https://rethinkdb.com/docs/install/ This link provides very straight forward insturctions on how to setup RethinkDB server. Simply follow those steps and you will be ok.
Our program uses Rethinkdb Python Client. Follow the instructions on https://rethinkdb.com/docs/install-drivers/python/ and install it.
First clone the source code
git clone..
python setup.py install
Run the file in interactive shell
In [ ]:
from streettraffic import tools
from streettraffic.map_resource import ultil
from streettraffic.database import TrafficData
from streettraffic.server import TrafficServer
# use a geojson polygon encoded area of interest
atlanta_downtown_polygon = ultil.read_geojson_polygon('{ "type": "FeatureCollection", "features": [ { "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ [ [ -84.3980884552002, 33.75988300332898 ], [ -84.38375473022461, 33.7645924612227 ], [ -84.37156677246094, 33.75495920249714 ], [ -84.38263893127441, 33.74404020060446 ], [ -84.40718650817871, 33.747109080164385 ], [ -84.3980884552002, 33.75988300332898 ] ] ] }, "properties": {} } ] }')
traffic_matrix_list = [ultil.get_area_tile_matrix_url("traffic_json", atlanta_downtown_polygon, 14, True)]
# set up your HERE app_id, app_code, map_tile_base_url, and json_tile_base_url
settings = {
'app_id': 'F8aPRXcW3MmyUvQ8Z3J9',
'app_code' : 'IVp1_zoGHdLdz0GvD_Eqsw',
'map_tile_base_url': 'https://1.traffic.maps.cit.api.here.com/maptile/2.1/traffictile/newest/normal.day/',
'json_tile_base_url': 'https://traffic.cit.api.here.com/traffic/6.2/flow.json?'
}
# initialize the histraffic server
# if this is your first time, running, histraffic_server will automatically create a *database_name*
# database for you
streettraffic_server = TestTrafficServer(database_name= "Traffic", database_ip = "localhost")
streettraffic_server.traffic_matrix_list = traffic_matrix_list
streettraffic_server.start()