cyclestreets / android

The Android app brings CycleStreets routing and turn-by-turn live navigation to your phone.
https://www.cyclestreets.net/mobile/android/
GNU General Public License v3.0
213 stars 217 forks source link

Feature request: allow circular routes #408

Closed HilaryN closed 3 years ago

HilaryN commented 4 years ago

I saw a review saying this is available on iPhone: allow planning of a circular route from start point, entering number of miles you wish to cycle.

mvl22 commented 4 years ago

Yes; would be good to add this to the Android app - there is definitely demand.

oliverlockwood commented 4 years ago

@mvl22 could you point me at the relevant API call, please?

mvl22 commented 4 years ago

@si-the-pie Could you e-mail Oliver, Hilary, and Jez the details for leisure routing under the API V1 layout? It should be the same as what the iPhone app is using.

HilaryN commented 4 years ago

It would be good to have the circular route on the website journey planner, too - I'm not sure where to request that. (Unless circular route is already there and I can't see it.)

mvl22 commented 4 years ago

It would be good to have the circular route on the website journey planner, too - I'm not sure where to request that. (Unless circular route is already there and I can't see it.)

Yes, we hope to have news on this soon. The current whole main website UI is horrendously outdated and that has slowed down getting the leisure routing in.

I'm not sure where to request that.

Via the main feedback system, but I've seen it now anyway :)

oliverlockwood commented 4 years ago

In the absence of an email from @si-the-pie, I've just gone ahead and reverse engineered this from the (already public) iOS code. We need to use something like the following:

  1. leisure route by distance in metres: in this case, 5km: https://www.cyclestreets.net/api/journey.json?key=redacted&plan=leisure&distance=5000&itinerarypoints=0.117950,52.205302,City+Centre
  2. leisure route by ride duration in seconds, in this case, 30 minutes: https://www.cyclestreets.net/api/journey.json?key=redacted&plan=leisure&duration=1800&itinerarypoints=0.117950,52.205302,City+Centre
jezhiggins commented 4 years ago

I knew I had something buried in my email, so I've dug through and can confirm this is correct.

We must have either distance or duration, you can't have both. The must be only one waypoint passed in the itinerarypoints parameter.

We may also pass a poitypes parameter, containing a comma-separated list of poi types. Leisure routes will 'tend to find routes through these POI types, if they are available'.

My email also describes some additional return types, although I don't know if this is still correct.

  1. otherRoutes string A comma separated list of the leisure routes found, which can be some or all of: leisure1,leisure2,leisure3,leisure4,leisure5,leisure6,leisure7,leisure8. These can be used as the plan argument to retrieve a particular one of the (up to) eight routes that were previously generated. (This may not be/have ever been relevant. Or possibly only applies in a small area of North Staffordshire :slightly_smiling_face:)

  2. POI These contain points of interest, POIs (if found) near to the requested waypoints.

    • longitude float, Longitude of the resolved POI
    • latitude float, Latitude of the resolved POI
    • sequenceId tinyint, Index for the POI corresponding to the waypoint, starting from 1.
    • poitypeId string, The POI type key name.
    • name string, Name of the POI.
    • website string, Any link for the POI.
mvl22 commented 4 years ago

Yes, that is all correct - thanks.

HilaryN commented 4 years ago

Screenshot from an iPhone:

IMG-20200822-WA0000

mvl22 commented 4 years ago

Yep, that UI is good to replicate.

oliverlockwood commented 4 years ago

I might even use this feature... except the app would probably tell me to avoid all the fun hills 😂

If you're up for developing this one @HilaryN then feel free to crack on. Personally I'd start from the API calls but that's because I've never been a UI person... 😀

mvl22 commented 4 years ago

The documentation is now public, at: https://www.cyclestreets.net/api/v1/leisure/

HilaryN commented 3 years ago

Progress update.

Here is a series of screenshots showing what happens currently when 0/1/2/3 waypoints are selected:

Circular route screenshots before

I've changed the second one (when 1 waypoint is selected) so that the text at the top now reads “Tap map to set Waypoint” / “Tap here for Circular Route”. The other screens (2 or more waypoints selected) are the same as before, and tapping at the top would bring back an A-B route as before:

Circular route screenshots after

Tapping at the top for a Circular Route brings up this screen, and you can drag the bar to change the minutes:

Circular route screens duration

I've only done duration so far, not distance or POI's yet.

I'm thinking to save whatever duration / distance is selected here to bring up next time this screen is brought up.

When the “Create circular route” button is pressed, the route is retrieved and displayed. According to the API documentation, up to 8 routes are plotted and the quietest one is returned. Here, “leisure2 route” is shown (see description at top):

Circular Leisure2 route

If you were to tap and hold on this screen for an A-B route you would get the menu allowing you to replan as quietest, balanced etc. For a circular route you get a choice of the alternative leisure routes (excluding the one already displayed, of course). Here are a couple of screenshots of the context menu for an A-B route and a circular route:

Circular route context menu

Or if you press the Options menu at the top, you will get one of the following, depending on whether an A-B route or Circular route is displayed – the last option on this menu has slightly different wording:

Circular route options menu

Selecting a different alternative retrieves the relevant alternative circular route, and the context menu changes accordingly:

Circular route 6

btw The number of minutes on the route seems to vary quite a lot from that selected (17 mins here) – is that what you would expect, @mvl22, or have I done something wrong?

Any other feedback welcome. @oliverlockwood @jezhiggins

Also, I haven't looked at LiveRide yet, but any thoughts on what should happen when one goes too far off the route? Maybe replan a route from current position to nearest point on route and append the rest of the route, if that's possible?

It's snowing tomorrow so I can't try it out for real - I'll have to make do with the emulator :-)

mvl22 commented 3 years ago

Tapping at the top for a Circular Route brings up this screen, and you can drag the bar to change the minutes:

What's the current range of the slider you have? Please do make it the same as the iPhone app. (We want to avoid super-long times/distances.)

The number of minutes on the route seems to vary quite a lot from that selected (17 mins here)

Yes, unfortunately the resulting output time compared to the requested time is not particularly accurate yet. Unfortunately the leisure routing is quite complex so this needs some engineering. Please just assume this will improve over time.

Also, I haven't looked at LiveRide yet, but any thoughts on what should happen when one goes too far off the route? Maybe replan a route from current position to nearest point on route and append the rest of the route, if that's possible?

It should just be the same as whatever happens with a normal A-B route.

HilaryN commented 3 years ago

What's the current range of the slider you have? Please do make it the same as the iPhone app. (We want to avoid super-long times/distances.)

Good question. The iPhone seems to have a range of 15 mins to 240 mins, according to the screenshot above. But when I tested the API I found it accepted 5 - 203 mins, hence I've made the range 5 - 200 mins. Do you mind if I keep the lower limit of 5 mins, to allow for less fit / beginner cyclists?

I haven't checked the distance limits yet on the API and I'm not sure what they are on the iPhone - I'll need to ask someone with an iPhone.

Yes, unfortunately the resulting output time compared to the requested time is not particularly accurate yet. Unfortunately the leisure routing is quite complex so this needs some engineering. Please just assume this will improve over time.

I can imagine, yes.

Also, I haven't looked at LiveRide yet, but any thoughts on what should happen when one goes too far off the route? Maybe replan a route from current position to nearest point on route and append the rest of the route, if that's possible?

It should just be the same as whatever happens with a normal A-B route.

Hmm, I would expect a normal replan to plan from my current location to my destination, via relevant waypoints I specify, which wouldn't work for a circular route, and it wouldn't make sense to plan a new circular route from current location.

Though in fact what seems to happen for an A-B route is that it just tries to take me back to my original route, no matter how far off it I go. (My experiences from having to go round 3 sides of a park when either it's closed or I don't want to get mugged by going through it after dark!)

So I guess that would work for a circular route.

mvl22 commented 3 years ago

hence I've made the range 5 - 200 mins. Do you mind if I keep the lower limit of 5 mins, to allow for less fit / beginner cyclists?

5-200 is good. Definitely good to have a low range of 5 minutes - yes!

Hmm, I would expect a normal replan to plan from my current location to my destination, via relevant waypoints I specify, which wouldn't work for a circular route, and it wouldn't make sense to plan a new circular route from current location.

Yes, sorry I clearly wasn't thinking very clearly at all! You're completely right this doesn't actually translate well.

Maybe replan a route from current position to nearest point on route and append the rest of the route, if that's possible?

Yes, I think that's the best that can be done.

HilaryN commented 3 years ago

Currently I'm just displaying the start point as a waypoint for a circular route, as in the screenshots above. I don't really want to clutter the display with lots of waypoints. Is that how it shows on the iPhone, do you know?

But if a replan is needed in LiveRide it would then turn into an A-B route with lots of waypoints, which would need to be displayed - I can't see any easy way around. Again, is that what happens on the iPhone for a replan?

mvl22 commented 3 years ago

Currently I'm just displaying the start point as a waypoint for a circular route, as in the screenshots above. I don't really want to clutter the display with lots of waypoints. Is that how it shows on the iPhone, do you know?

The iPhone app does actually show the waypoints, but it shouldn't really. Ideally you should just show the planned point, not the virtual points.

But if a replan is needed in LiveRide it would then turn into an A-B route with lots of waypoints, which would need to be displayed - I can't see any easy way around. Again, is that what happens on the iPhone for a replan?

There is no LiveRide equivalent yet on the iPhone :(

I don't think you can avoid doing what you suggest. I wouldn't worry too much about this - it would be better to have replanning with the points showing explicitly than not having replanning at all.

HilaryN commented 3 years ago

Yes, I don't think I can avoid it. I thought I'd double check for consistency. (The waymarks do appear in the itinerary, but I'll leave that as it is for now.) LiveRide works fine without me having to do anything, apart from the replan which crashes it at the moment because of the lack of waypoints :-)

Thanks!

HilaryN commented 3 years ago

OK, replan is working now. I'm back to the Circular route screen now to put in the distance. iPhone has 1-64km / 1-40 miles, but I'm finding it times out above 55km. Shall I keep it at 50km / 30 miles max?

mvl22 commented 3 years ago

Yes, in practice we’re not quite getting the right length and it invariably ends up more than it really should be. So I’d keep it not too long as you suggest.

Excited to see this in action soon, let me know when it’s in the beta channel!

HilaryN commented 3 years ago

Here's the Circular route screen with the Distance tab selected, depending whether you have km's or miles set in Preferences:

Distance tab selected
HilaryN commented 3 years ago

LiveRide - the last screenshot shows a replan after going off route:

LiveRide replan

This is in the emulator but I tried it for real on my phone as well.

mvl22 commented 3 years ago

Well done so far Hilary - very excited to see this coming together!

Let me know when it's in the Beta channel and I'll have a go :)