NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

I am using osrm for route api. The response i got from osrm route is geometry and nodes. I want to slit the line-string to response given below.

Desired example of response:

[{"type":"Feature","geometry":
{"type":"LineString","coordinates":[
    [73.08365, 33.662523],
    [73.083333, 33.662344],
    [73.083071, 33.662188],
    [73.082894, 33.662081],
    [73.082701, 33.661965],
    [73.08239, 33.661795],
    [73.082159, 33.661643],
    [73.081923, 33.661474],
    [73.081135, 33.660951],
    [73.080701, 33.660661],
    [73.08046, 33.660509],
    [73.080272, 33.660384],
    [73.08002, 33.660224],
    [73.079741, 33.660072],
    [73.079371, 33.659875],
    [73.078969, 33.659648],
    [73.078336, 33.659313],
    [73.077741, 33.659],
   ]},
properties:
{"osmhighway":"motorway_link","osmoneway":"yes","osmwayid":5669636,"start_node":370705004,"end_node":1369956654,
"speed_mean_mph":16,"pct_from_freeflow":72,"speed_freeflow_mph":22}},{"type":"Feature","geometry":
{"type":"LineString","coordinates":[

    [73.077741, 33.659],
    [73.077194, 33.658714],
    [73.076765, 33.658496],
    [73.076508, 33.658344],
    [73.075672, 33.65792],
    [73.075012, 33.657576],
    [73.074465, 33.657295],
    [73.073929, 33.657031],
    [73.073023, 33.656571],
    [73.072438, 33.656281],
    [73.071983, 33.65604],
    [73.071457, 33.655763],
    [73.071044, 33.65554],
    [73.070401, 33.655196],
    [73.069993, 33.654959],
    [73.069511, 33.654723],
    [73.069136, 33.654535],
    [73.067977, 33.653959],
    [73.06742, 33.653669],
    [73.066894, 33.653401],
    [73.066487, 33.653204],
    [73.065948, 33.652923],
    [73.06547, 33.652668],
    [73.065084, 33.652463],
    [73.064677, 33.652262],
    [73.063941, 33.65186],
    [73.063378, 33.651552],
    [73.062907, 33.651307]]},
properties:
{"osmhighway":"motorway_link","osmoneway":"yes","osmwayid":5669636,"start_node":42469049,"end_node":1369956654,
"speed_mean_mph":16,"pct_from_freeflow":72,"speed_freeflow_mph":22}},
{"type":"Feature","geometry":{"type":"LineString","coordinates":
[[73.064677, 33.652262],
[73.063941, 33.65186],
[73.063378, 33.651552],
[73.062907, 33.651307],
[73.062354, 33.650985],
[73.061856, 33.650713],
[73.061486, 33.650512],
[73.060987, 33.650244],
[73.060424, 33.649949],
[73.059218, 33.649297],
[73.057212, 33.64827],
[73.056328, 33.647792]
]},
properties:{"osmname":"Bay Parkway","osmhighway":"primary","osmoneway":"no","osmwayid":5675398,"start_node":36202597,
"end_node":36202835,"speed_mean_mph":20,"pct_from_freeflow":67,"speed_freeflow_mph":29}}]

But the response i got from osrm route api is given below.

osrm route api response:

{"routes":[{"geometry":{"coordinates":[[13.388798,52.517033],[13.388827,52.516848],[13.389003,52.516864],[13.389842,52.51692],[13.390517,52.516965],[13.390708,52.516983],[13.39089,52.517003],[13.392584,52.517118],[13.393055,52.517149],[13.393172,52.517192],[13.39314,52.517372],[13.393103,52.517377],[13.393052,52.517385],[13.39296,52.517399],[13.392852,52.5174],[13.392628,52.517386],[13.392347,52.519016],[13.392296,52.519063],[13.392249,52.519105],[13.392231,52.519122],[13.392225,52.519131],[13.392173,52.519237],[13.391997,52.52006],[13.39199,52.520089],[13.391985,52.520111],[13.391949,52.520261],[13.391931,52.520348],[13.391886,52.520573],[13.39185,52.520768],[13.391838,52.520829],[13.391629,52.521964],[13.391643,52.522074],[13.391649,52.522156],[13.391676,52.522717],[13.391704,52.522807],[13.391718,52.522858],[13.391782,52.522976],[13.392118,52.523552],[13.392549,52.524365],[13.392789,52.524807],[13.392821,52.524865],[13.392884,52.524984],[13.392948,52.525096],[13.392967,52.525131],[13.393075,52.525323],[13.393195,52.525538],[13.393295,52.52564],[13.393344,52.525736],[13.393387,52.525821],[13.393407,52.52588],[13.393407,52.525992],[13.393586,52.526289],[13.393565,52.52634],[13.393541,52.526401],[13.393492,52.526483],[13.392896,52.527482],[13.392668,52.527848],[13.392638,52.527894],[13.392528,52.52806],[13.392498,52.52811],[13.392425,52.528233],[13.392659,52.528281],[13.392712,52.528292],[13.39314,52.528379],[13.393219,52.528396],[13.393668,52.528491],[13.393814,52.528526],[13.393989,52.52857],[13.394591,52.528715],[13.395724,52.528996],[13.397265,52.529357],[13.397326,52.529372],[13.397565,52.529429],[13.397631,52.529432]],"type":"LineString"},"legs":[{"annotation":{"nodes":[21487242,2264199819,6583929461,3869306771,6583929470,25664779,6583929468,450169274,3602294176,29207420,1263312256,262455378,7026359390,7026359391,262455379,27005148,3378459473,4590472037,4590472043,25665679,4590472042,3378459484,29192960,3590535063,1635318723,1635318763,3463843411,3463843421,540972281,4843707050,539817446,27412113,541130319,3463843610,3463843613,2435547302,27412088,27412072,29192284,2489942693,2344513388,26871464,2344513396,2435547308,5426423331,672892368,1769645439,1769645505,1769645476,2341815347,1769645437,2269947166,5700339361,25954549,5700339360,1448679340,3185200556,6665554019,5700389945,5700389948,311464976,5700389949,5700389946,3933855818,3185200558,4815315420,26871576,4815315421,3933855819,1448679343,5700389941,3836987623,659394041,3836987625]},"summary":"","weight":618.2,"duration":408.5,"steps":[],"distance":1998.6}],"weight_name":"routability","weight":618.2,"duration":408.5,"distance":1998.6}],"waypoints":[{"distance":4.231665624816857,"name":"Friedrichstraße","location":[13.388798,52.517033]},{"distance":2.7893928415656375,"name":"Torstraße","location":[13.397631,52.529432]}],"code":"Ok"}

Now i want to create response like above mentioned example.

asked 17 Apr '20, 07:18

ahsan368's gravatar image

ahsan368
11112
accept rate: 0%

edited 17 Apr '20, 09:20

scai's gravatar image

scai ♦
33.3k21309459

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×710
×85
×60
×1
×1

question asked: 17 Apr '20, 07:18

question was seen: 1,435 times

last updated: 17 Apr '20, 13:24

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum