EastCoastGreenwayAlliance / ecg-map

Interactive map and trip planner for the ECGA
https://map.greenway.org
7 stars 0 forks source link

Location awareness for Turn by turn View #37

Closed danrademacher closed 7 years ago

danrademacher commented 7 years ago

for this view: image

We need:

For testing location, we can use dev tools to spoof other latlons image

Assigned to Chris, but feel free to pull in Greg if helpful

clhenrick commented 7 years ago

Iterating that this view is only available on mobile. I think it a couple other issues need to be flushed out first:

  1. Locate Me button for showing user's current location

  2. More work on layout for mobile, including the "view cues" button and "start route" button, which enables a user to get to this point.

We'll also want to integrate a feature that tells the user if they aren't in the vicinity of the ECG and thus prevents the "Locate Me" feature from working. No point in showing their current location on the map if they are in West Virginia or elsewhere.

gregallensworth commented 7 years ago

PR 45 brings the current state, which meets the spec per discussion.

Internally I'm calling this "ActiveTurning"

Still to do:

clhenrick commented 7 years ago

I'm sure the distance given from one transition to the next will be confusing for users at first. I wonder if there's a somewhat elegant way we can word this or make it clear that it's not the actual distance from a user's current location to the next turn? cc @danrademacher

gregallensworth commented 7 years ago

As of 0417bc4 there is no longer a dependency on L.GeometryUtil which doesn't work properly in Leaflet 0.7 I rewrote the geometry calculations to emulate the same effect, though, so nobody will notice...

clhenrick commented 7 years ago

This seems to be working well when fibbing my location in the browser.

The one part that I left out of the UI is the number in the upper left of the box to the left of the cancel button, which I believe represents the remaining mileage of the route from the user's current location. As @gregallensworth has already mentioned, without a true GPS implementation (which is beyond the scope of this feature) we can't accurately tell someone how much distance is left in the portion of the route they selected; nor can we tell them exactly how far they are from the next turn.

clhenrick commented 7 years ago

Implemented, waiting to be tested in the field. We can open a new issue for any bugs that come up.

gregallensworth commented 7 years ago

Reopening for some testing: Chris hypothesizes that if we are nearby a very long segment (there's one record 9 miles in length) the "my distance to nearest line" calculations may be off, as if they're using the endpoint or nearest vertex? I thought I coded it to find the nearest point, but an extreme case sounds worth testing.

Relevant sections of code: https://github.com/EastCoastGreenwayAlliance/ecg-map/blob/master/client/src/components/LeafletMap.jsx#L290-L310

gregallensworth commented 7 years ago

On review, the new version does use turfDistance(turfMidpoint()) so is fetching the distance to the midpoint of the vertex-pair. If the road is very straight (highway, ferry) a single vertex pair could hypothetically be a mile or more in length, giving an inflated result.

gregallensworth commented 7 years ago

On a route from Philadelphia, PA to New Bruncwick, NJ there are some straight sections with wider spacing between vertices. Using these, I did confirm that the midpoint technique would give inflated distances in these situations.

I replaced the code with Leaflet code based on my original from July 5. The effective change was largely one line to convert the L.Point back to a L.LatLng before calling distanceTo()

In the process I did make some other small changes:

clhenrick commented 7 years ago

thanks @gregallensworth!