Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

[Public transport] Display basic route results on the map #357

Merged
merged 6 commits into from
Sep 11, 2019

Conversation

bbecquet
Copy link
Contributor

@bbecquet bbecquet commented Aug 27, 2019

Probably easier to review commit by commit

Description

Displays public transport route results on the map, for now with the basic style, i.e. without any distinction of step type, metro line color, etc.
As public transport result geoms are GeoJSON FeatureCollection (and not unique geometries like car/walking/bike), we clean and refactor some stuff to be able to manage all results in a generic way, independently of the routing mode:

  • always convert result data to a FeatureCollection MapBox-GL data source, even where there is a single feature
  • use turf/bbox to compute bbox for all kinds of data

Why

  • Display a first iteration of public transport results
  • Increase the genericity of how we manage geoms

localhost_3000_routes__origin=addr_2 361615;48 822339_12@12%20Rue%20Philibert%20Lucot destination=latlon_48 87149_2 37028 mode=publicTransport

@bbecquet bbecquet changed the title [Publit transport] Display basic route results on the map [Public transport] Display basic route results on the map Aug 27, 2019
@@ -73,8 +74,11 @@ export default class SceneDirection {
if (isActive) {
mainRoute = route;
}
this.map.setFeatureState({ source: `source_${route.id}`, id: 1 }, { isActive });
const geoJson = this.getRouteGeoJson(route.geometry, isActive);
this.map.getSource(`source_${route.id}`).setData(geoJson);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that using setFeatureState is not practical to update multiple features.
But reloading the whole geoJson data seems to be significantly slower.

Maybe another solution could be to define a routeId property in the features, and update the layer style (to set the line-color rule dynamically) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion! 👌
I did it with the second alternative, as it didn't require manipulating each feature independently, requires a lot less code, and we already did something similar for the pedestrian case.
Now it's generic and snappy :)

ALTERNATE_ROUTE_COLOR,
],
'line-color': route.isActive ? MAIN_ROUTE_COLOR : ALTERNATE_ROUTE_COLOR,
'line-color-transition': { duration: 0 },
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added that for iso-functionnalilty, because otherwise there is a 300ms transition effect which wasn't in the current version. We can drop it later if we decide the transition is nice :)

Copy link
Contributor

@amatissart amatissart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arf, I was about to approve the PR, but the test needs to be updated too ;)

@bbecquet bbecquet merged commit 2dee751 into Qwant:master Sep 11, 2019
@bbecquet bbecquet deleted the transport-display-map branch September 11, 2019 09:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants