# Interpolate point along route - Java library

Kia ora!

I have a route between coordinates `a` and `b` (e.g. `[-41.31001,174.778842]` and `[-41.321305, 174.825574]`), with a known traversal time (e.g. 11 minutes).

I wish to identify the coordinate location `x < 11` mins along the route.

i.e. if the total route length is `11` mins and `x = 8`, is there a function to quickly find the coordinate `72.73%` (`8/11`) along the route?

My current method: iterate over every adjacent pair of coordinates in the route (`curr` & `next`), calculate and sum the time distance between them until I reach `x`, and then linearly interpolate a point between the final `curr` and `next` coordinates. Inefficient.

Ngā mihi,
Mak

Hey,

I’m not aware of any such libraries.
The simplest optimization I can think of is starting at the point that is closer to your coordinate, i.e for your example, starting from the end point and finding the coordinate that is `27.27%` from your end point.

I don’t think you’ll be able to run this a lot faster, but if you’re using the same route multiple times for such calculations, you can probably pre-calculate the relative distance for all points comprising your route, and then be able to run a binary search on your point list.

Best regards

Kia ora jschnell,

Thanks for getting back to me. No worries re: existing methods. Your idea for (potentially) halving compute is a good one.

If ORS were to implement this (or a better version) natively at some stage, it would be fantastic. In the meantime, I’ll make do!

Another question, inbound.

Ngā mihi,
Mak

1 Like