I’m sorry to trouble you. I’m a beginner in graphopper.
Using the spring boot framework, I’m ready to display the map and navigate.
I introduced graphoper with Maven according to the document of graphoper, and wrote a controller to respond to the request according to the official document. Here is my code:
@RequestMapping("/")
@ResponseBody
public GHResponse mytest(){
GraphHopper hopper = new GraphHopperOSM().forServer();
hopper.setMinNetworkSize(0, 0);
hopper.setDataReaderFile("src\\main\\resources\\static\\osm\\01.osm");
hopper.setGraphHopperLocation("src\\main\\resources\\static\\mapStorage\\resource");
hopper.setEncodingManager(EncodingManager.create("car"));
hopper.importOrLoad();
double latFrom =38.871352;
double lonFrom =115.453452;
double latTo =38.871352;
double lonTo =115.453356;
GHRequest req = new GHRequest(latFrom, lonFrom, latTo, lonTo).
setWeighting("fastest").
setVehicle("car").
setLocale(Locale.US);
GHResponse rsp = hopper.route(req);
return rsp;
}
Although I can see the information of the RSP object in debug, the RSP object returned to the page cannot display the data I saw in debug
This is my debug message:
This is the data I returned to the page:
{
"paths": {
"distance": 12.756846684008838,
"weight": 0.45879048062431826,
"time": 458,
"ascend": 0.0,
"descend": 0.0,
"instructions": [{
"points": {
"size": 1,
"empty": false,
"immutable": false,
"dimension": 2,
"3D": false
},
"annotation": {
"empty": true,
"importance": 0,
"message": ""
},
"sign": 0,
"name": "",
"distance": 2.1719677066689083,
"time": 78,
"length": 1,
"extraInfoJSON": {
"heading": 3.78
}
}, {
"points": {
"size": 1,
"empty": false,
"immutable": true,
"dimension": 2,
"3D": false
},
"annotation": {
"empty": true,
"importance": 0,
"message": ""
},
"sign": -2,
"name": "",
"distance": 8.498999999999999,
"time": 305,
"length": 1,
"extraInfoJSON": {}
}, {
"points": {
"size": 1,
"empty": false,
"immutable": false,
"dimension": 2,
"3D": false
},
"annotation": {
"empty": true,
"importance": 0,
"message": ""
},
"sign": -2,
"name": "",
"distance": 2.0858789773399318,
"time": 75,
"length": 1,
"extraInfoJSON": {}
}, {
"points": {
"size": 1,
"empty": false,
"immutable": false,
"dimension": 2,
"3D": false
},
"annotation": {
"empty": true,
"importance": 0,
"message": ""
},
"sign": 4,
"name": "",
"distance": 0.0,
"time": 0,
"length": 0,
"extraInfoJSON": {
"last_heading": 178.27008837700436
}
}],
"points": {
"size": 4,
"empty": false,
"immutable": true,
"dimension": 2,
"3D": false
}
},
"hints": {
"empty": false
},
"geojson": null,
"elevator": 0,
"sameFloor": false
}
In points, there is no longitude and latitude information
How do I get longitude and latitude in points。