Route point granularity (Path)

Hello,

Is it possible to set the granularity of points for a GPS route? I mean, from Paris to Lyon (700km) I have about 4500 points instead of Mapbox which return maybe 40 points. I save this points on db so 4500 is too much for me.

thank you.

Such a long route with only 40 points this would be a very rough approximation. Under which circumstances would this be sufficient? As zoomed out overview?

If you are using the Route Optimization API: couldn’t you apply a certain path simplification that fits your requirements on the client side?

Or are you using the Routing API?

It’s quite approximative but it’s enought for me, I will build a buffer around it :

Look on mapbox, it’s approximative but enought.

I will search on this zone, it does not need to be very precise.

Maybe I can use a simplification algorithm as posttreatment? Do you have any examples?

Thank you !

There are multiple JS libraries for simplification. But I still don’t understand your use case: why would it make sense to reduce the route to just 40 points? What if the user zooms in? Do you request the API again?

Hello,

In fact I do not display the route for my user, it’s just to found delivery for him. So I store in database route_points for matching and I can not save 4k points per routes (I have 130k routes).
What it matters for me is to build my “bean” :
CleanShot 2023-02-07 at 14.38.44@2x

And for that I do not need so many points.

I tried to use simplify-js but it just does not reduce the number of points…

You probably need to tune the parameters of simplify-js a bit. There usually is a trade-off between removing and keeping too many points so you need to find a value that fits your purposes.