help cntraveltime

Title

cntraveltime --
This Stata module helps to extract the travel distance and travel time between two locations from Baidu Map API(http://api.map.baidu.com).

Syntax

cntraveltime, baidukey(string) start_lat(varname) start_long(varname) end_lat(varname) end_long(varname) [options]

Description

Baidu Map is widely used in China.
cntraveltime use Baidu Map API to extract the travel time and distance from one location to another.To be close to the real world,cntraveltime can calculate result with respect to different mode of transportation (car-driving, public transport and cycling) and perference of transportation (less walk, as quickly as possible ,etc). Forthermore, it can also extract the description of the traveling route.Before using this command, a Baidu key from Baidu Map API is needed.A typical Baidu key is an alphanumeric string. You can get a secret key from Baidu Map's open platform (http://lbsyun.baidu.com).The process normally will take few minutes after you submit your application online.

cntraveltime requires Stata version 14 or higher.

options for cntraveltime

Credentials(required)

baidukey(string) is required before using this command. A typical Baidu Map API key is an alphanumeric string. Suppose the user already has a Baidu Map API key, which is, say, CH8eakl6UTlEb1OakeWYvofh;then, the baidukey() option must be specified as baidukey(CH8eakl6UTlEb1OakeWYvofh).

start_lat(varname) & start_long(varname) specify the longitude and latitude of the origin location.

end_lat(varname) & end_long(varname) specify the longitude and latitude of the destination location.

Search options

detail: If the user needs a detail information on the route chosen by cntraveltime , option detail helps. The default is not to show this information.

mode(string) allows the user to choose different travel modes. It can be car, public or bike. The default choice is public transport. Baidu Map will calculate the travel distance and travel time between two specified locations upon your choice of transport mode, as the route for bicycle may be different from a car driving route. There will be an error message if users specify a transit mode other than car, public or bike, for example, subway

route_option(real) can choose the detail preference when the given locations in the same cities. Please note that for different transport mode, the effective range and meaning of the route_option are also different. Enter the number in the option and the preferences represented by different numbers as follows.

public 0: default, recommendation

public 1: less transit

public 2: less walk

public 3: no subway

public 4: as quickly as possible

public 5: subway

car 0: default

car 3: avoid high speed

car 4: high speed priority

car 5: avoid congested sections

car 6: avoiding toll stations

car 7: both 4 and 5

car 8: both 3 and 4

car 9: both 4 and 6

car 10: both 6 and 8

car 11: both 3 and 6

bike 0: default, common

bike 1: electric bicycle

intercitytype(real) can choose a more specific cross-city public transport. When the two locations are in different cities, the program will calculate the travel distance and travel time according to the selected transportation. If the two locations are in the same city, this option will not work. It should be noted that this option is only valid when the content of the mode () option is "public". This option accepts a number as a parameter, and the default is 0, the number specifies the mode of transportation where

0	: train

1	: plane

2	: bus

intercity_route_option(real) represents the priority requirement for cross-city public transportation, the default is 0, the preferences represented by different numbers are as follows.

0	: as quickly as possible

1	: start as early as possible

2	: as cheap as possible

Example

Input the address

`"clear"'

`"input double startlat double startlng double endlat double endlng"'

`"28.18561 112.95033 39.99775 116.31616"'

`"43.85427 125.30057 28.18561 112.95033"'

`"31.85925 117.21600 33.01379 119.36848"'

`"end"'

Extracts the detail information of drving between the two place.

`"cntraveltime, baidukey(your secret key) start_lat(startlat) start_long(startlng) end_lat(endlat) end_long(endlng) mode("car") detail route_option(4)"'

`"list duration distance "'

Extracts the detail information by bus between the two place.

`"cntraveltime, baidukey(your secret key) start_lat(startlat) start_long(startlng) end_lat(endlat) end_long(endlng) mode("public") detail route_option(4) intercitytype(1) intercity_route_option(1)"'

`"list duration distance "'

Author

Chuntao LI

China Stata Club(爬虫俱乐部)

Wuhan, China

chtl@henu.edu.cn

Yuan Xue

China Stata Club(爬虫俱乐部)

Wuhan, China

xueyuan19920310@163.com

Xueren Zhang

China Stata Club(爬虫俱乐部)

Wuhan, China

snowmanzhang@whu.edu.cn