[英]MapBox map matching api throwing error
I am using mapbox to display maps in my application. 我正在使用mapbox在我的应用程序中显示地图。 I am displaying user's location as the user moves and to keep the location on the street I am trying to use map box map-matching api. 当用户移动时,我正在显示用户的位置,并将位置保持在街道上,我正在尝试使用地图框地图匹配API。 But the api works with the test points in map-matching api, but throws error when i use my actual lat-long points. 但是该api可与地图匹配api中的测试点一起使用,但是当我使用实际的经纬度点时会引发错误。 https://www.mapbox.com/api-documentation/#retrieve-a-match I send the request using https://www.mapbox.com/api-documentation/#retrieve-a-match我使用发送请求
curl -X POST \
--header "Content-Type:application/json"-d @trace.json \
"https://api.mapbox.com/matching/v4/mapbox.driving.json?access_token=<your token here>"
When my trace.json file has the test input mentions in api, i get the result This is trace.json with lat long from the api, and returns result. 当我的trace.json文件在api中提到测试输入时,我得到的结果是api中的经度为long的trace.json,并返回结果。
{
"type": "Feature",
"properties": {
"coordTimes": [
"2015-04-21T06:00:00Z",
"2015-04-21T06:00:05Z"
]
},
"geometry": {
"type": "LineString",
"coordinates": [
[ 13.418946862220764, 52.50055852688439 ],
[ 13.419011235237122, 52.50113000479732 ]
]
}
}
But the same trace.json with my lat-long point throws following error. 但是我的经纬度相同的trace.json引发以下错误。
Error : {"message":"each coordinate must be array with float in-bounds [longitude, latitude]","code":"InvalidInput"}
{
"type": "Feature",
"properties": {
"coordTimes": [
"2015-04-21T06:00:00Z",
"2015-04-21T06:00:05Z"
]
},
"geometry": {
"type": "LineString",
"coordinates": [
[47.586479, -122.229704],
[47.578238, -122.209869]
]
}
}
can't figure out what's wrong with the request. 无法确定请求出了什么问题。
The error code you received is the key to the problem. 您收到的错误代码是问题的关键。 Your "coordinates"
data must be in [longitude, latitude]
which is the standard for GeoJson . 您的"coordinates"
数据必须为[longitude, latitude]
,这是GeoJson的标准。
Error : {"message":" each coordinate must be array with float in-bounds [longitude, latitude] ","code":"InvalidInput"} 错误:{“ message”:“ 每个坐标必须是带有浮点入边界[经度,纬度] ”,“ code”:“ InvalidInput”}的数组
To fix, you need to swap around your data for the "coordinates"
. 要解决此问题,您需要在数据周围交换"coordinates"
。 As another test you can use GeoJson.io to validate your traces.json
, and to verify you have proper input data into your MapMatch tool. 作为另一项测试,您可以使用GeoJson.io验证您的traces.json
,并验证您在MapMatch工具中是否有正确的输入数据。
{
"type": "Feature",
"properties": {
"coordTimes": [
"2015-04-21T06:00:00Z",
"2015-04-21T06:00:05Z"
]
},
"geometry": {
"type": "LineString",
"coordinates": [
[-122.229704, 47.586479],
[-122.209869, 47.578238]
]
}
}
See this gist , and the image here for how you can use other tools to validate your original GeoJson. 请参见此要点和此处的图像,以了解如何使用其他工具来验证原始的GeoJson。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.