Open teshtek opened 2 years ago
How to parse this :
[ { "type":"FeatureCollection", "metadata":{ "attribution":"openrouteservice.org, OpenStreetMap contributors, tmc - BASt", "service":"routing", "timestamp":1664711043488, "query":{ "coordinates":[ [ 10.9202123, 45.5838054 ], [ 10.9078685, 45.5896399 ] ], "profile":"foot-hiking", "format":"geojson", "units":"m", "language":"it-it", "instructions":true, "elevation":true, "extra_info":[ "steepness", "suitability", "surface", "waycategory", "waytype", "tollways" ] }, "engine":{ "version":"6.7.0", "build_date":"2022-10-02T08:43:25Z", "graph_date":"2022-09-20T08:21:48Z" }, "system_message":"This message would be sent with every request for geojson response" }, "features":[ { "bbox":[ 10.906799, 45.582498, 322.9, 10.920215, 45.58964, 586.0 ], "type":"Feature", "properties":{ "ascent":8.0, "descent":263.1, "segments":[ { "distance":2046.0, "duration":1508.7, "steps":[ { "distance":357.4, "duration":293.0, "type":11, "instruction":"Avanti Sud", "name":"-", "way_points":[ 0, 20 ] }, { "distance":225.6, "duration":162.4, "type":1, "instruction":"Gira a destra", "name":"-", "way_points":[ 20, 27 ] }, { "distance":183.4, "duration":132.0, "type":0, "instruction":"Gira a sinistra", "name":"-", "way_points":[ 27, 47 ] }, { "distance":1276.1, "duration":918.8, "type":0, "instruction":"Gira a sinistra", "name":"-", "way_points":[ 47, 159 ] }, { "distance":3.4, "duration":2.5, "type":0, "instruction":"Gira a sinistra", "name":"-", "way_points":[ 159, 160 ] }, { "distance":0.0, "duration":0.0, "type":10, "instruction":"Arrivo a destinazione, dritto", "name":"-", "way_points":[ 160, 160 ] } ], "ascent":7.956422424316429, "descent":263.10344848632815 } ], "extras":{ "waycategory":{ "values":[ [ 0, 160, 0 ] ], "summary":[ { "value":0.0, "distance":2046.0, "amount":100.0 } ] }, "surface":{ "values":[ [ 0, 16, 10 ], [ 16, 157, 12 ], [ 157, 158, 4 ], [ 158, 160, 12 ] ], "summary":[ { "value":12.0, "distance":1719.9, "amount":84.06 }, { "value":10.0, "distance":324.5, "amount":15.86 }, { "value":4.0, "distance":1.6, "amount":0.08 } ] }, "waytypes":{ "values":[ [ 0, 160, 4 ] ], "summary":[ { "value":4.0, "distance":2046.0, "amount":100.0 } ] }, "steepness":{ "values":[ [ 0, 7, -5 ], [ 7, 55, -3 ], [ 55, 65, -5 ], [ 65, 91, -3 ], [ 91, 110, -4 ], [ 110, 141, -5 ], [ 141, 160, -1 ] ], "summary":[ { "value":-3.0, "distance":952.0, "amount":46.53 }, { "value":-5.0, "distance":583.7, "amount":28.53 }, { "value":-1.0, "distance":334.8, "amount":16.36 }, { "value":-4.0, "distance":175.4, "amount":8.58 } ] }, "suitability":{ "values":[ [ 0, 160, 9 ] ], "summary":[ { "value":9.0, "distance":2046.0, "amount":100.0 } ] } }, "warnings":[ { "code":4, "message":"Extra info requested but not available: tollways" } ], "summary":{ "distance":2046.0, "duration":1508.7 }, "way_points":[ 0, 160 ] }, "geometry":{ "coordinates":[ [ 10.920212, 45.583805, 586.0 ], [ 10.920214, 45.583774, 579.6 ], [ 10.920215, 45.583743, 577.1 ], [ 10.920062, 45.583586, 574.0 ], [ 10.919663, 45.583263, 569.3 ], [ 10.919441, 45.583129, 567.6 ], [ 10.919268, 45.583066, 566.4 ], [ 10.91914, 45.583047, 565.5 ], [ 10.918994, 45.58306, 564.6 ], [ 10.918713, 45.583035, 563.0 ], [ 10.918333, 45.582901, 560.9 ], [ 10.917962, 45.582694, 557.0 ], [ 10.91771, 45.582498, 554.6 ], [ 10.917577, 45.582522, 553.5 ], [ 10.917518, 45.582629, 552.6 ], [ 10.917541, 45.582853, 551.0 ], [ 10.917536, 45.583028, 550.1 ], [ 10.917408, 45.582989, 549.1 ], [ 10.917367, 45.582933, 548.2 ], [ 10.917273, 45.58288, 547.5 ], [ 10.9172, 45.582878, 546.9 ], [ 10.917132, 45.58303, 546.2 ], [ 10.917015, 45.583119, 545.5 ], [ 10.916928, 45.583256, 544.7 ], [ 10.916612, 45.583823, 538.9 ], [ 10.916433, 45.584219, 534.6 ], [ 10.916118, 45.584671, 529.7 ], [ 10.916031, 45.584707, 528.5 ], [ 10.915985, 45.58466, 527.2 ], [ 10.915822, 45.584214, 522.2 ], [ 10.915687, 45.584144, 521.5 ], [ 10.915655, 45.584114, 520.9 ], [ 10.915602, 45.584113, 520.4 ], [ 10.915581, 45.584132, 519.9 ], [ 10.915544, 45.584136, 519.5 ], [ 10.915449, 45.584086, 519.0 ], [ 10.915425, 45.583925, 518.5 ], [ 10.915441, 45.583892, 518.1 ], [ 10.91536, 45.583809, 517.6 ], [ 10.915266, 45.583771, 517.2 ], [ 10.915246, 45.583723, 516.8 ], [ 10.915188, 45.583681, 516.4 ], [ 10.915081, 45.583687, 516.0 ], [ 10.915007, 45.58367, 516.0 ], [ 10.914963, 45.58371, 516.0 ], [ 10.914881, 45.583713, 516.0 ], [ 10.914802, 45.583678, 516.0 ], [ 10.914782, 45.583677, 516.0 ], [ 10.914764, 45.583662, 514.4 ], [ 10.914623, 45.583673, 512.7 ], [ 10.914434, 45.583791, 510.9 ], [ 10.914248, 45.583818, 509.2 ], [ 10.914075, 45.583781, 507.3 ], [ 10.913914, 45.583828, 505.4 ], [ 10.913708, 45.583856, 503.5 ], [ 10.913681, 45.583825, 501.6 ], [ 10.913533, 45.583796, 499.7 ], [ 10.913473, 45.583807, 497.7 ], [ 10.91345, 45.583835, 495.7 ], [ 10.913451, 45.583965, 493.8 ], [ 10.913472, 45.584035, 491.8 ], [ 10.913449, 45.58409, 489.8 ], [ 10.913402, 45.584128, 487.8 ], [ 10.913327, 45.584134, 485.8 ], [ 10.913304, 45.584108, 483.7 ], [ 10.913275, 45.584106, 481.7 ], [ 10.913225, 45.584177, 479.6 ], [ 10.913157, 45.584195, 477.5 ], [ 10.912981, 45.584205, 476.9 ], [ 10.912877, 45.58428, 476.4 ], [ 10.912772, 45.58428, 475.9 ], [ 10.912648, 45.584261, 475.4 ], [ 10.912368, 45.584301, 474.5 ], [ 10.912284, 45.584271, 474.1 ], [ 10.912174, 45.584276, 473.6 ], [ 10.91213, 45.584355, 473.2 ], [ 10.912068, 45.584395, 472.8 ], [ 10.911936, 45.584418, 472.3 ], [ 10.911868, 45.584406, 471.7 ], [ 10.911566, 45.58445, 470.5 ], [ 10.911474, 45.584526, 469.9 ], [ 10.911472, 45.584572, 469.3 ], [ 10.91143, 45.584584, 468.6 ], [ 10.911411, 45.584547, 467.9 ], [ 10.911368, 45.58457, 467.3 ], [ 10.91136, 45.584609, 466.6 ], [ 10.911255, 45.584608, 466.1 ], [ 10.911217, 45.584581, 465.5 ], [ 10.91115, 45.584647, 464.9 ], [ 10.911143, 45.58469, 464.3 ], [ 10.911097, 45.584711, 463.8 ], [ 10.910959, 45.584682, 463.1 ], [ 10.910817, 45.584679, 462.5 ], [ 10.91061, 45.584706, 461.8 ], [ 10.910549, 45.584814, 461.1 ], [ 10.910478, 45.584833, 460.3 ], [ 10.910464, 45.584878, 459.6 ], [ 10.910405, 45.584942, 458.7 ], [ 10.910389, 45.585005, 457.9 ], [ 10.910361, 45.585017, 457.1 ], [ 10.910285, 45.584977, 456.3 ], [ 10.910187, 45.585003, 455.5 ], [ 10.910068, 45.585061, 454.7 ], [ 10.909742, 45.584983, 452.8 ], [ 10.909663, 45.585009, 451.6 ], [ 10.909597, 45.585001, 450.3 ], [ 10.909466, 45.585045, 448.9 ], [ 10.909392, 45.585088, 447.3 ], [ 10.909403, 45.585137, 445.7 ], [ 10.909361, 45.58518, 444.0 ], [ 10.909337, 45.585172, 442.3 ], [ 10.909326, 45.585135, 440.7 ], [ 10.909256, 45.585141, 439.0 ], [ 10.909196, 45.585168, 437.3 ], [ 10.909039, 45.585303, 435.2 ], [ 10.908936, 45.585328, 433.0 ], [ 10.908859, 45.585377, 430.7 ], [ 10.908776, 45.585378, 428.2 ], [ 10.908745, 45.585421, 425.7 ], [ 10.908642, 45.585422, 423.0 ], [ 10.90863, 45.585464, 420.4 ], [ 10.908586, 45.58548, 417.8 ], [ 10.908371, 45.585502, 415.0 ], [ 10.90816, 45.585546, 412.1 ], [ 10.907906, 45.585536, 409.5 ], [ 10.907905, 45.585589, 407.0 ], [ 10.907867, 45.585627, 404.7 ], [ 10.907506, 45.585776, 397.8 ], [ 10.907403, 45.585792, 395.6 ], [ 10.907154, 45.585715, 391.3 ], [ 10.907073, 45.585742, 389.5 ], [ 10.907048, 45.585762, 384.9 ], [ 10.907061, 45.585787, 380.5 ], [ 10.90711, 45.585831, 376.4 ], [ 10.907178, 45.585892, 372.5 ], [ 10.907332, 45.586353, 354.2 ], [ 10.907338, 45.58653, 351.1 ], [ 10.90732, 45.586644, 348.0 ], [ 10.907209, 45.586901, 341.8 ], [ 10.907096, 45.58706, 338.9 ], [ 10.906997, 45.587134, 336.1 ], [ 10.906953, 45.587422, 328.1 ], [ 10.906843, 45.5877, 322.9 ], [ 10.906799, 45.587766, 323.3 ], [ 10.90683, 45.587792, 323.6 ], [ 10.906975, 45.587812, 324.0 ], [ 10.907283, 45.587961, 324.7 ], [ 10.907449, 45.588021, 325.1 ], [ 10.907586, 45.588124, 325.5 ], [ 10.907582, 45.588411, 326.4 ], [ 10.907608, 45.588625, 326.8 ], [ 10.907535, 45.58884, 327.2 ], [ 10.90736, 45.588974, 327.5 ], [ 10.907311, 45.589035, 327.6 ], [ 10.907277, 45.589121, 327.7 ], [ 10.907307, 45.589214, 327.8 ], [ 10.907754, 45.589506, 327.9 ], [ 10.907824, 45.589567, 328.0 ], [ 10.907829, 45.58958, 328.1 ], [ 10.907871, 45.589609, 329.5 ], [ 10.907868, 45.58964, 330.9 ] ], "type":"LineString" } } ], "bbox":[ 10.906799, 45.582498, 322.9, 10.920215, 45.58964, 586.0 ] } ]
There is no proprietes inside the root of geojson, it gives me that error:
Error: <rect> attribute y: Expected length, "NaN". Error: <text> attribute y: Expected length, "NaN" Error: <path> attribute transform: Trailing garbage, "translate(727,undefined) rotat…"
RESULT
Inside _prepareData: function _prepareData() {}I notice that I have to passresult.bodyas array so:this.hg.addData([result.body])` but here fails:
_prepareData:
I notice that I have to pass
as array so:
this._categories[y] = { info: { id: y, text: data[y].properties.label || data[y].properties.summary }, distances: [], attributes: [], geometries: [], legend: {} };
there is no properties inside response
How to parse this :
[ { "type":"FeatureCollection", "metadata":{ "attribution":"openrouteservice.org, OpenStreetMap contributors, tmc - BASt", "service":"routing", "timestamp":1664711043488, "query":{ "coordinates":[ [ 10.9202123, 45.5838054 ], [ 10.9078685, 45.5896399 ] ], "profile":"foot-hiking", "format":"geojson", "units":"m", "language":"it-it", "instructions":true, "elevation":true, "extra_info":[ "steepness", "suitability", "surface", "waycategory", "waytype", "tollways" ] }, "engine":{ "version":"6.7.0", "build_date":"2022-10-02T08:43:25Z", "graph_date":"2022-09-20T08:21:48Z" }, "system_message":"This message would be sent with every request for geojson response" }, "features":[ { "bbox":[ 10.906799, 45.582498, 322.9, 10.920215, 45.58964, 586.0 ], "type":"Feature", "properties":{ "ascent":8.0, "descent":263.1, "segments":[ { "distance":2046.0, "duration":1508.7, "steps":[ { "distance":357.4, "duration":293.0, "type":11, "instruction":"Avanti Sud", "name":"-", "way_points":[ 0, 20 ] }, { "distance":225.6, "duration":162.4, "type":1, "instruction":"Gira a destra", "name":"-", "way_points":[ 20, 27 ] }, { "distance":183.4, "duration":132.0, "type":0, "instruction":"Gira a sinistra", "name":"-", "way_points":[ 27, 47 ] }, { "distance":1276.1, "duration":918.8, "type":0, "instruction":"Gira a sinistra", "name":"-", "way_points":[ 47, 159 ] }, { "distance":3.4, "duration":2.5, "type":0, "instruction":"Gira a sinistra", "name":"-", "way_points":[ 159, 160 ] }, { "distance":0.0, "duration":0.0, "type":10, "instruction":"Arrivo a destinazione, dritto", "name":"-", "way_points":[ 160, 160 ] } ], "ascent":7.956422424316429, "descent":263.10344848632815 } ], "extras":{ "waycategory":{ "values":[ [ 0, 160, 0 ] ], "summary":[ { "value":0.0, "distance":2046.0, "amount":100.0 } ] }, "surface":{ "values":[ [ 0, 16, 10 ], [ 16, 157, 12 ], [ 157, 158, 4 ], [ 158, 160, 12 ] ], "summary":[ { "value":12.0, "distance":1719.9, "amount":84.06 }, { "value":10.0, "distance":324.5, "amount":15.86 }, { "value":4.0, "distance":1.6, "amount":0.08 } ] }, "waytypes":{ "values":[ [ 0, 160, 4 ] ], "summary":[ { "value":4.0, "distance":2046.0, "amount":100.0 } ] }, "steepness":{ "values":[ [ 0, 7, -5 ], [ 7, 55, -3 ], [ 55, 65, -5 ], [ 65, 91, -3 ], [ 91, 110, -4 ], [ 110, 141, -5 ], [ 141, 160, -1 ] ], "summary":[ { "value":-3.0, "distance":952.0, "amount":46.53 }, { "value":-5.0, "distance":583.7, "amount":28.53 }, { "value":-1.0, "distance":334.8, "amount":16.36 }, { "value":-4.0, "distance":175.4, "amount":8.58 } ] }, "suitability":{ "values":[ [ 0, 160, 9 ] ], "summary":[ { "value":9.0, "distance":2046.0, "amount":100.0 } ] } }, "warnings":[ { "code":4, "message":"Extra info requested but not available: tollways" } ], "summary":{ "distance":2046.0, "duration":1508.7 }, "way_points":[ 0, 160 ] }, "geometry":{ "coordinates":[ [ 10.920212, 45.583805, 586.0 ], [ 10.920214, 45.583774, 579.6 ], [ 10.920215, 45.583743, 577.1 ], [ 10.920062, 45.583586, 574.0 ], [ 10.919663, 45.583263, 569.3 ], [ 10.919441, 45.583129, 567.6 ], [ 10.919268, 45.583066, 566.4 ], [ 10.91914, 45.583047, 565.5 ], [ 10.918994, 45.58306, 564.6 ], [ 10.918713, 45.583035, 563.0 ], [ 10.918333, 45.582901, 560.9 ], [ 10.917962, 45.582694, 557.0 ], [ 10.91771, 45.582498, 554.6 ], [ 10.917577, 45.582522, 553.5 ], [ 10.917518, 45.582629, 552.6 ], [ 10.917541, 45.582853, 551.0 ], [ 10.917536, 45.583028, 550.1 ], [ 10.917408, 45.582989, 549.1 ], [ 10.917367, 45.582933, 548.2 ], [ 10.917273, 45.58288, 547.5 ], [ 10.9172, 45.582878, 546.9 ], [ 10.917132, 45.58303, 546.2 ], [ 10.917015, 45.583119, 545.5 ], [ 10.916928, 45.583256, 544.7 ], [ 10.916612, 45.583823, 538.9 ], [ 10.916433, 45.584219, 534.6 ], [ 10.916118, 45.584671, 529.7 ], [ 10.916031, 45.584707, 528.5 ], [ 10.915985, 45.58466, 527.2 ], [ 10.915822, 45.584214, 522.2 ], [ 10.915687, 45.584144, 521.5 ], [ 10.915655, 45.584114, 520.9 ], [ 10.915602, 45.584113, 520.4 ], [ 10.915581, 45.584132, 519.9 ], [ 10.915544, 45.584136, 519.5 ], [ 10.915449, 45.584086, 519.0 ], [ 10.915425, 45.583925, 518.5 ], [ 10.915441, 45.583892, 518.1 ], [ 10.91536, 45.583809, 517.6 ], [ 10.915266, 45.583771, 517.2 ], [ 10.915246, 45.583723, 516.8 ], [ 10.915188, 45.583681, 516.4 ], [ 10.915081, 45.583687, 516.0 ], [ 10.915007, 45.58367, 516.0 ], [ 10.914963, 45.58371, 516.0 ], [ 10.914881, 45.583713, 516.0 ], [ 10.914802, 45.583678, 516.0 ], [ 10.914782, 45.583677, 516.0 ], [ 10.914764, 45.583662, 514.4 ], [ 10.914623, 45.583673, 512.7 ], [ 10.914434, 45.583791, 510.9 ], [ 10.914248, 45.583818, 509.2 ], [ 10.914075, 45.583781, 507.3 ], [ 10.913914, 45.583828, 505.4 ], [ 10.913708, 45.583856, 503.5 ], [ 10.913681, 45.583825, 501.6 ], [ 10.913533, 45.583796, 499.7 ], [ 10.913473, 45.583807, 497.7 ], [ 10.91345, 45.583835, 495.7 ], [ 10.913451, 45.583965, 493.8 ], [ 10.913472, 45.584035, 491.8 ], [ 10.913449, 45.58409, 489.8 ], [ 10.913402, 45.584128, 487.8 ], [ 10.913327, 45.584134, 485.8 ], [ 10.913304, 45.584108, 483.7 ], [ 10.913275, 45.584106, 481.7 ], [ 10.913225, 45.584177, 479.6 ], [ 10.913157, 45.584195, 477.5 ], [ 10.912981, 45.584205, 476.9 ], [ 10.912877, 45.58428, 476.4 ], [ 10.912772, 45.58428, 475.9 ], [ 10.912648, 45.584261, 475.4 ], [ 10.912368, 45.584301, 474.5 ], [ 10.912284, 45.584271, 474.1 ], [ 10.912174, 45.584276, 473.6 ], [ 10.91213, 45.584355, 473.2 ], [ 10.912068, 45.584395, 472.8 ], [ 10.911936, 45.584418, 472.3 ], [ 10.911868, 45.584406, 471.7 ], [ 10.911566, 45.58445, 470.5 ], [ 10.911474, 45.584526, 469.9 ], [ 10.911472, 45.584572, 469.3 ], [ 10.91143, 45.584584, 468.6 ], [ 10.911411, 45.584547, 467.9 ], [ 10.911368, 45.58457, 467.3 ], [ 10.91136, 45.584609, 466.6 ], [ 10.911255, 45.584608, 466.1 ], [ 10.911217, 45.584581, 465.5 ], [ 10.91115, 45.584647, 464.9 ], [ 10.911143, 45.58469, 464.3 ], [ 10.911097, 45.584711, 463.8 ], [ 10.910959, 45.584682, 463.1 ], [ 10.910817, 45.584679, 462.5 ], [ 10.91061, 45.584706, 461.8 ], [ 10.910549, 45.584814, 461.1 ], [ 10.910478, 45.584833, 460.3 ], [ 10.910464, 45.584878, 459.6 ], [ 10.910405, 45.584942, 458.7 ], [ 10.910389, 45.585005, 457.9 ], [ 10.910361, 45.585017, 457.1 ], [ 10.910285, 45.584977, 456.3 ], [ 10.910187, 45.585003, 455.5 ], [ 10.910068, 45.585061, 454.7 ], [ 10.909742, 45.584983, 452.8 ], [ 10.909663, 45.585009, 451.6 ], [ 10.909597, 45.585001, 450.3 ], [ 10.909466, 45.585045, 448.9 ], [ 10.909392, 45.585088, 447.3 ], [ 10.909403, 45.585137, 445.7 ], [ 10.909361, 45.58518, 444.0 ], [ 10.909337, 45.585172, 442.3 ], [ 10.909326, 45.585135, 440.7 ], [ 10.909256, 45.585141, 439.0 ], [ 10.909196, 45.585168, 437.3 ], [ 10.909039, 45.585303, 435.2 ], [ 10.908936, 45.585328, 433.0 ], [ 10.908859, 45.585377, 430.7 ], [ 10.908776, 45.585378, 428.2 ], [ 10.908745, 45.585421, 425.7 ], [ 10.908642, 45.585422, 423.0 ], [ 10.90863, 45.585464, 420.4 ], [ 10.908586, 45.58548, 417.8 ], [ 10.908371, 45.585502, 415.0 ], [ 10.90816, 45.585546, 412.1 ], [ 10.907906, 45.585536, 409.5 ], [ 10.907905, 45.585589, 407.0 ], [ 10.907867, 45.585627, 404.7 ], [ 10.907506, 45.585776, 397.8 ], [ 10.907403, 45.585792, 395.6 ], [ 10.907154, 45.585715, 391.3 ], [ 10.907073, 45.585742, 389.5 ], [ 10.907048, 45.585762, 384.9 ], [ 10.907061, 45.585787, 380.5 ], [ 10.90711, 45.585831, 376.4 ], [ 10.907178, 45.585892, 372.5 ], [ 10.907332, 45.586353, 354.2 ], [ 10.907338, 45.58653, 351.1 ], [ 10.90732, 45.586644, 348.0 ], [ 10.907209, 45.586901, 341.8 ], [ 10.907096, 45.58706, 338.9 ], [ 10.906997, 45.587134, 336.1 ], [ 10.906953, 45.587422, 328.1 ], [ 10.906843, 45.5877, 322.9 ], [ 10.906799, 45.587766, 323.3 ], [ 10.90683, 45.587792, 323.6 ], [ 10.906975, 45.587812, 324.0 ], [ 10.907283, 45.587961, 324.7 ], [ 10.907449, 45.588021, 325.1 ], [ 10.907586, 45.588124, 325.5 ], [ 10.907582, 45.588411, 326.4 ], [ 10.907608, 45.588625, 326.8 ], [ 10.907535, 45.58884, 327.2 ], [ 10.90736, 45.588974, 327.5 ], [ 10.907311, 45.589035, 327.6 ], [ 10.907277, 45.589121, 327.7 ], [ 10.907307, 45.589214, 327.8 ], [ 10.907754, 45.589506, 327.9 ], [ 10.907824, 45.589567, 328.0 ], [ 10.907829, 45.58958, 328.1 ], [ 10.907871, 45.589609, 329.5 ], [ 10.907868, 45.58964, 330.9 ] ], "type":"LineString" } } ], "bbox":[ 10.906799, 45.582498, 322.9, 10.920215, 45.58964, 586.0 ] } ]
There is no proprietes inside the root of geojson, it gives me that error:
RESULT
Inside
_prepareData:
function _prepareData() {}I notice that I have to pass
result.bodyas array so:
this.hg.addData([result.body])` but here fails:there is no properties inside response