

/**
* 为一个Entity上传一个轨迹点
*/
@Test
public void testEntityAddpoint(){
String url="https://yingyan.baidu.com/api/v3/track/addpoint";
String body = HttpRequest.post(url)
.form("ak", ak)
.form("service_id", 233936)
.form("entity_name","route_1_1002")
.form("latitude","31.041452")//纬度
.form("longitude","121.618723")//经度
.form("loc_time",System.currentTimeMillis()/1000)//定位时间戳,精确到秒
.form("coord_type_input","bd09ll")//坐标类型
.form("speed",10.23)//速度
.form("direction",15)//方向
.execute().body();
System.out.println(body);
}

重新选择地址定位,再运行一次
/**
* 为一个Entity上传一个轨迹点
*/
@Test
public void testEntityAddpoint(){
String url="https://yingyan.baidu.com/api/v3/track/addpoint";
String body = HttpRequest.post(url)
.form("ak", ak)
.form("service_id", 233936)
.form("entity_name","route_1_1002")
.form("latitude","31.095648")//纬度
.form("longitude","121.513256")//经度
.form("loc_time",System.currentTimeMillis()/1000)//定位时间戳,精确到秒
.form("coord_type_input","bd09ll")//坐标类型
.form("speed",10.23)//速度
.form("direction",15)//方向,
.execute().body();
System.out.println(body);
}
可以查看行驶轨迹

/**
* 为一个Entity上传一个轨迹点
*/
@Test
public void testEntityAddpoints(){
String url="https://yingyan.baidu.com/api/v3/track/addpoints";
List

模拟用户骑行操作
/**
* 为一个Entity上传一个轨迹点(模拟用户骑行操作)
*/
@Test
public void testEntityAddpoint2() {
String url = "https://yingyan.baidu.com/api/v3/track/addpoint";
String point="121.674519,31.139177|121.657272,31.201467|121.560686,31.221234|121.476174,31.198502|121.433486,31.250999";
StrUtil.split(point,'|').forEach(poinTStr ->{
String[] splitStr = StrUtil.splitToArray(poinTStr, ',');
String body = HttpRequest.post(url)
.form("ak", ak)
.form("service_id", 233936)
.form("entity_name", "route_1_1003")
.form("latitude", Convert.toDouble(splitStr[1]))//纬度
.form("longitude", Convert.toDouble(splitStr[0]))//经度
.form("loc_time", System.currentTimeMillis() / 1000)//定位时间戳,精确到秒
.form("coord_type_input", "bd09ll")//坐标类型
.form("speed", 10.23)//速度
.form("direction", 15)//方向,
.execute().body();
System.out.println(body);
try {
Thread.sleep(RandomUtil.randomInt(5,30)*1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
});
}
