After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 745242 - Support roundabouts in GraphHopper route results
Support roundabouts in GraphHopper route results
Status: RESOLVED FIXED
Product: gnome-maps
Classification: Applications
Component: general
git master
Other Linux
: Normal enhancement
: ---
Assigned To: gnome-maps-maint
gnome-maps-maint
Depends on:
Blocks:
 
 
Reported: 2015-02-26 18:35 UTC by Mattias Bengtsson
Modified: 2016-01-11 20:31 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Icons (33.49 KB, image/png)
2015-04-11 21:22 UTC, Mattias Bengtsson
  Details
roundabouts preview (3.87 KB, image/png)
2016-01-08 16:05 UTC, Andreas Nilsson
  Details
roundabout icons (3.97 KB, application/gzip)
2016-01-08 17:06 UTC, Andreas Nilsson
  Details
A patch for roundabout support in GraphHopper search. (3.91 KB, patch)
2016-01-08 23:39 UTC, Prashant Tyagi
needs-work Details | Review
Roundabout support for map. (42.84 KB, patch)
2016-01-09 21:59 UTC, Prashant Tyagi
none Details | Review
Screenshot of icons in action (632.06 KB, image/png)
2016-01-10 10:01 UTC, Jonas Danielsson
  Details
screenshot. (167.07 KB, image/jpeg)
2016-01-10 10:29 UTC, Prashant Tyagi
  Details
A Patch for Roundabout support. (42.84 KB, patch)
2016-01-10 11:20 UTC, Prashant Tyagi
none Details | Review
A Patch for roundabout support (42.96 KB, patch)
2016-01-10 14:11 UTC, Prashant Tyagi
none Details | Review
A patch for roundabout support (43.10 KB, patch)
2016-01-10 15:55 UTC, Prashant Tyagi
none Details | Review
A patch for roundabout support to route (43.11 KB, patch)
2016-01-10 19:19 UTC, Prashant Tyagi
none Details | Review
Updated patch. (43.11 KB, patch)
2016-01-11 07:00 UTC, Prashant Tyagi
none Details | Review
generic roundabout icon (3.57 KB, image/svg+xml)
2016-01-11 10:14 UTC, Andreas Nilsson
  Details
A patch for roundabout support to route (48.60 KB, patch)
2016-01-11 13:00 UTC, Prashant Tyagi
none Details | Review
roundabout support for route service. (46.95 KB, patch)
2016-01-11 13:41 UTC, Prashant Tyagi
none Details | Review
A patch for roundabout suppport (46.96 KB, patch)
2016-01-11 14:12 UTC, Prashant Tyagi
committed Details | Review

Description Mattias Bengtsson 2015-02-26 18:35:09 UTC
GraphHopper just added support for round-abouts in its search results. 

The relevant result data is:

paths[0].instructions[0].sign (USE_ROUNDABOUT = 6)
paths[0].instructions[0].exit_number
and perhaps
paths[0].instructions[0].turn_angle

Adding support for this in Maps should be fairly easy.

Look in RouteService::_createTurnPointType (in routeService.js) and TurnPointType (in route.js).
Comment 1 Mattias Bengtsson 2015-02-26 18:36:50 UTC
We also need icons for this. The question is how many and if it should rely on the turn_angle property.
Comment 2 Jonas Danielsson 2015-02-27 09:16:08 UTC
Thanks for filing this, Mattias!

From https://github.com/graphhopper/directions-api/blob/master/docs-routing.md

turn_angle:
"[optional] Only available for USE_ROUNDABOUT instructions. The radian of the route within the roundabout: 0<r<2*PI for clockwise and -2PI<r<0 for counterclockwise transit. Is null the direction of rotation is undefined."

exit_number:
"[optional] Only available for USE_ROUNDABOUT instructions. The count of exits at which the route leaves the roundabout."


So what you are asking about icons is whether the icon should be rotated based on the turn_angle? I think not, but not sure.

Andreas?


So for requesting icons, either I think, ask in #gnome-design. And/or add the request here: https://wiki.gnome.org/action/show/Design/ArtRequests?action=show&redirect=GnomeArt%2FArtRequests
Comment 3 Andreas Nilsson 2015-04-10 09:16:57 UTC
I recall drawing some roundabout icons in the past, so I might actually still have them around.
What states are needed? Go Straight, Go Right, Go Left?
- Andreas
Comment 4 Zeeshan Ali 2015-04-10 11:28:23 UTC
(In reply to Andreas Nilsson from comment #3)
> I recall drawing some roundabout icons in the past, so I might actually
> still have them around.
> What states are needed? Go Straight, Go Right, Go Left?

Maybe in small cities that would suffice but out here there are roundabouts with 5 or even 6 exits. I think I'd do it like Waze does: Show a roundabout (circle) with the number of the exit in the middle of it. If you could somehow nicely represent the exit number and direction of the exit, that would be awesome.
Comment 5 Zeeshan Ali 2015-04-10 11:29:07 UTC
(In reply to Zeeshan Ali (Khattak) from comment #4)
> (In reply to Andreas Nilsson from comment #3)
> > I recall drawing some roundabout icons in the past, so I might actually
> > still have them around.
> > What states are needed? Go Straight, Go Right, Go Left?

Oh and don't forget 'going around' state. :)
Comment 6 Mattias Bengtsson 2015-04-11 21:08:56 UTC
My suggestion is that we make seven icons, one for each 45 degrees of
roundabout exit. These would map to the current turn-point icons we already
have in the following way:

Angle    New Roundabot turn-point    Old plain turn-point
—————————————————————————————————————————————————————
45°      ROUNDABOUT_SHARP_LEFT       SHARP_LEFT
90°      ROUNDABOUT_LEFT             LEFT
135°     ROUNDABOUT_SLIGHT_LEFT      SLIGHT_LEFT
180°     ROUNDABOUT_CONTINUE         CONTINUE
225°     ROUNDABOUT_SLIGHT_RIGHT     SLIGHT_RIGHT
270°     ROUNDABOUT_RIGHT            RIGHT
315°     ROUNDABOUT_SHARP_RIGHT      SHARP_RIGHT

Then since we have the turn angle we map that to the closest icon there is.

Regarding the exit number:
that is available in the turnpoint description and I don't think we want to
complicate these icons any more.

Regarding going full round in the roundabout I'm not sure GraphHopper understands
that yet, since it doesn't understand U-turns.
But yeah, we could ask Peter, and if it does add ROUNDABOUT_U_TURN (or something).
Comment 7 Mattias Bengtsson 2015-04-11 21:11:23 UTC
FWIW, I'd like to work on this during our little hack weekend in GBG in two weeks.
Comment 8 Mattias Bengtsson 2015-04-11 21:22:16 UTC
Created attachment 301387 [details]
Icons

Something like this attachment (but pretty).
Comment 9 Prashant Tyagi 2016-01-08 13:41:40 UTC
How do i exactly draw these icons for Roundabout as given in the above attachment by Mattias any suggestion??
Comment 10 Prashant Tyagi 2016-01-08 13:44:08 UTC
I am almost done with the coding part for this feature i need icons for roundabout angles.
Comment 11 Jonas Danielsson 2016-01-08 13:45:06 UTC
(In reply to Prashant Tyagi from comment #10)
> I am almost done with the coding part for this feature i need icons for
> roundabout angles.

Excellent, maybe you could attach a patch with the code you have, and use dummy icons or missing icons for the image for now? So we can start the review process?
Comment 12 Andreas Nilsson 2016-01-08 16:05:36 UTC
Created attachment 318510 [details]
roundabouts preview

Something like this?
If it looks good I'll export them out as individual files.
Comment 13 Andreas Nilsson 2016-01-08 17:06:30 UTC
Created attachment 318521 [details]
roundabout icons
Comment 14 Prashant Tyagi 2016-01-08 23:39:27 UTC
Created attachment 318556 [details] [review]
A patch for roundabout support in GraphHopper search.

i have temporarily use the icon name as maps-aboutdirectio[angle]-symbolic.Let me know if there is better possible method to find closest possible angle with aboutpoint_turn_angle.
Comment 15 Jonas Danielsson 2016-01-09 06:06:22 UTC
(In reply to Andreas Nilsson from comment #13)
> Created attachment 318521 [details]
> roundabout icons

Really nice!
Comment 16 Jonas Danielsson 2016-01-09 06:19:28 UTC
Review of attachment 318556 [details] [review]:

Thanks Prashant!

For the commit message: "Add roundabout support to route service"

maybe?

Andreas has posted icons for you, please include them in your patch. Look at data/icons/Makefile.am for how to do that.
I have some more comments below.

We also need to solve the issue were we get no angle, do we need a generic icon?

::: src/route.js
@@ +35,3 @@
     END:           7,
     VIA:           8,
+    ROUND_ABOUT:   9,

This should be ROUNDABOUT.

@@ +81,3 @@
     Name: 'TurnPoint',
 
+    _init: function({ coordinate, type, distance, instruction, turn_angle }) {

We use camelCase in Maps: turnAngle.

@@ +89,1 @@
         this.iconName = this._getIconName();

send turnAngle here: this._getIconName(turnAngle) and we do not need this.turnAngle;

@@ +89,3 @@
         this.iconName = this._getIconName();
+        this.min_diff = 360
+        this.angle = 0

No need for these to be part of the class. They can be local variables to the getRoundaboutIconName function

@@ +115,3 @@
         case TurnPointType.VIA:          return 'maps-point-end-symbolic';
         case TurnPointType.END:          return 'maps-point-end-symbolic';
+        case TurnPointType.ROUND_ABOUT:

We also need to deal with the case that there is no angle, the docs say it can be unavailable, rigt?

So what should we do then do you think? Do we need another icon? Request one from Andreas in that case.

@@ +117,3 @@
+        case TurnPointType.ROUND_ABOUT:
+            if(this.turn_angle < 0)
+                this.turn_angle += 360

The angle is in radians.

@@ +119,3 @@
+                this.turn_angle += 360
+            for(var x = 0;x < 360;x += 45)
+            {

curly braces on same line: for (...) {

@@ +120,3 @@
+            for(var x = 0;x < 360;x += 45)
+            {
+                if(Math.abs(x - this.turn_angle) < this.min_diff)

if (...) {

@@ +126,3 @@
+                }
+            }
+                                        return 'maps-aboutdirection-' + this.angle + '-symbolic';

It gets kind of messy with all this code in the case-statement.
Could we break it out to a function?

case TurnPointType.ROUNDABOUT:      return this._getRoundaboutIconName(turnAngle);

The name should be 'maps-direction-roundabout-%d-symbolic',format(angle);

::: src/routeService.js
@@ +168,3 @@
                                                instruction: _("Start!"),
+                                               time:        0,
+                                               turn_angle:  0

turnAngle here and everywhere
Comment 17 Prashant Tyagi 2016-01-09 11:04:32 UTC
when roundabout angle is not defined may be we could have a generic icon for that 
,andreas please make a generic icon for that.
Comment 18 Andreas Nilsson 2016-01-09 15:10:26 UTC
(In reply to Prashant Tyagi from comment #17)
> when roundabout angle is not defined may be we could have a generic icon for
> that 
> ,andreas please make a generic icon for that.

Sure!
I'll get you something ASAP.
Comment 19 Prashant Tyagi 2016-01-09 21:59:31 UTC
Created attachment 318605 [details] [review]
Roundabout support for map.

updated patch.
Comment 20 Jonas Danielsson 2016-01-10 09:58:53 UTC
Review of attachment 318605 [details] [review]:

Thanks Prashant, looking good!

Please obsolete old patches when submitting a new one, to make the bugzolla less confusing!
And take a moment to set up git-bz, read more here: https://wiki.gnome.org/Projects/GnomeShell/Development/WorkingWithPatches
It will help you work with patches in bugzilla easier.

::: data/icons/Makefile.am
@@ +33,3 @@
+	hicolor_apps_32x32_maps-direction-roundabout-225-symbolic.svg  \
+	hicolor_apps_32x32_maps-direction-roundabout-270-symbolic.svg  \
+	hicolor_apps_32x32_maps-direction-roundabout-315-symbolic.svg	\

Please align these at 72 like all other \

::: src/route.js
@@ +123,3 @@
+        if(turnAngle < 0)
+            turnAngle += 2 * Math.PI;
+        var min_diff = 2 * Math.PI;

Two things.

1) look around in Maps code. We use "let" to declare variables, not "var".

Read more here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let

'let' is for local variables, bound by the scope it is declared in.

2) camelCase! :) This should be let minDiff

@@ +126,3 @@
+        var angle = 0;
+
+        for(var x = 0;x < 360; x += 45) {

for (let x = ...

@@ +127,3 @@
+
+        for(var x = 0;x < 360; x += 45) {
+            if(Math.abs(turnAngle - (x / 180) * Math.PI) < min_diff) {

if (...)

Space after if and for!

@@ +135,1 @@
     }

Maybe a

/*
 * Type of comment above to explain this function?
 *
 */
Comment 21 Jonas Danielsson 2016-01-10 10:01:35 UTC
Created attachment 318646 [details]
Screenshot of icons in action

Also the icons looks weird in my Maps, do they look the same at you?
Is this the icons fault or something else?
Comment 22 Prashant Tyagi 2016-01-10 10:29:00 UTC
Created attachment 318647 [details]
screenshot.

Icon is not a problem for me.As you can see in attachment.
Comment 23 Prashant Tyagi 2016-01-10 11:20:43 UTC
Created attachment 318649 [details] [review]
A Patch for Roundabout support.

This to add roundabout support to routes service.
Comment 24 Jonas Danielsson 2016-01-10 13:54:07 UTC
Review of attachment 318649 [details] [review]:

Did you miss to update this? Looks like the same
Comment 25 Prashant Tyagi 2016-01-10 14:11:21 UTC
Created attachment 318653 [details] [review]
A Patch for roundabout support

Sorry i submited the previous patch. Here is a new updated patch.
Comment 26 Jonas Danielsson 2016-01-10 15:04:03 UTC
Review of attachment 318653 [details] [review]:

Awesome, thanks!

So for the commit message, it does not really make sense, we want the short log to give us an idea of what and where.


So maybe: "route: Add roundabout support" ? And no space before ":".

And "route" not "routes" in the body.

::: data/icons/Makefile.am
@@ +33,3 @@
+	hicolor_apps_32x32_maps-direction-roundabout-225-symbolic.svg      \
+	hicolor_apps_32x32_maps-direction-roundabout-270-symbolic.svg      \
+	hicolor_apps_32x32_maps-direction-roundabout-315-symbolic.svg	   \

These are still not aligned with the others! :)

::: src/route.js
@@ +118,3 @@
+
+    _getRoundaboutIconName: function(turnAngle) {
+        /* To map turnAngle with closest roundabout turning angle symbol available */

The comment is a bit long.
Split it up in multiple line, formated like:

/*
 * ...
 * ...
 */

And maybe explain a bit how the algo below works?

@@ +127,3 @@
+        let angle = 0;
+
+        for (let x = 0;x < 360; x += 45) {

Be consistent with whitespace, "; x < 360;
Comment 27 Prashant Tyagi 2016-01-10 15:55:58 UTC
Created attachment 318659 [details] [review]
A patch for roundabout support

A patch for roundabout support to route.
Comment 28 Jonas Danielsson 2016-01-10 18:34:32 UTC
Review of attachment 318659 [details] [review]:

Thanks, looks very nice!

Now we just need to wait for the generic icon then!

Some nit comments below while we wait! Overall looks great!

::: src/route.js
@@ +122,3 @@
+         * calculates the minimum of absolute difference
+         * between turnAngle and the angle of which map
+         * has turning symbols. */

Nice,

so please, format like:

/*
 * To map ...
 * ...
 * ...
 * ...
 * ...
 */

@@ +129,3 @@
+            turnAngle += 2 * Math.PI;
+        let minDiff = 2 * Math.PI;
+        let angle = 0;

Define these variables at the top of the function please.

@@ +131,3 @@
+        let angle = 0;
+
+        for (let x = 0;x < 360;x += 45) {

I did prefer the space after ; :)

@@ +140,2 @@
     }
+

Do not add extra blanks!
Comment 29 Prashant Tyagi 2016-01-10 19:19:07 UTC
Created attachment 318678 [details] [review]
A patch for roundabout support to route

A patch for roundabout support for route.
Comment 30 Jonas Danielsson 2016-01-11 06:49:18 UTC
(In reply to Prashant Tyagi from comment #29)
> Created attachment 318678 [details] [review] [review]
> A patch for roundabout support to route
> 
> A patch for roundabout support for route.

Please. Obsolete the last patch when uploading a new. Otherwise it makes working with git-bz harder for me.
Comment 31 Prashant Tyagi 2016-01-11 07:00:47 UTC
Created attachment 318707 [details] [review]
Updated patch.

A patch for roundabout support tp route service.
Comment 32 Andreas Nilsson 2016-01-11 10:14:25 UTC
Created attachment 318712 [details]
generic roundabout icon

(In reply to Prashant Tyagi from comment #17)
> when roundabout angle is not defined may be we could have a generic icon for
> that 
> ,andreas please make a generic icon for that.


Here is a generic roundabout icon, for undefined angles.
Comment 33 Prashant Tyagi 2016-01-11 11:49:16 UTC
(In reply to Andreas Nilsson from comment #32)
> Created attachment 318712 [details]
> generic roundabout icon
> 
> (In reply to Prashant Tyagi from comment #17)
> > when roundabout angle is not defined may be we could have a generic icon for
> > that 
> > ,andreas please make a generic icon for that.
> 
> 
> Here is a generic roundabout icon, for undefined angles.

can you please give me a .svg format as you have created previously.
Comment 34 Jonas Danielsson 2016-01-11 11:50:58 UTC
(In reply to Prashant Tyagi from comment #33)
> (In reply to Andreas Nilsson from comment #32)
> > Created attachment 318712 [details]
> > generic roundabout icon
> > 
> > (In reply to Prashant Tyagi from comment #17)
> > > when roundabout angle is not defined may be we could have a generic icon for
> > > that 
> > > ,andreas please make a generic icon for that.
> > 
> > 
> > Here is a generic roundabout icon, for undefined angles.
> 
> can you please give me a .svg format as you have created previously.

It is in svg, right?
Comment 35 Prashant Tyagi 2016-01-11 13:00:10 UTC
Created attachment 318719 [details] [review]
A patch for roundabout support to route

A updated patch with generic icon of roundabout.
Comment 36 Jonas Danielsson 2016-01-11 13:03:56 UTC
Review of attachment 318719 [details] [review]:

Thanks!

Something has happen with this patch :)
Where is the routeService changes? And the Makefile diff is out of control... and the name of the icon is wrong.

::: data/icons/Makefile.am
@@ +60,1 @@
 	$(NULL)

What happend with this file? The diff should not look like this :)

::: src/route.js
@@ +122,3 @@
+         * between turnAngle and the angle of which map
+         * has turning symbols.
+        /* To map turnAngle with closest roundabout

If you are re-spinning ,could you also fix the format of the comment to be:

/*
 * text...
 * text ...
 * ...
 */

@@ +126,3 @@
+        let angle = 0;
+        if (turnAngle === null)
+         * calculates the minimum of absolute difference

wasn't it generic? not undefined?
Comment 37 Prashant Tyagi 2016-01-11 13:41:29 UTC
Created attachment 318722 [details] [review]
roundabout support for route service.

updated patch with few fixes.
Comment 38 Jonas Danielsson 2016-01-11 13:43:36 UTC
Review of attachment 318722 [details] [review]:

Thanks!

::: src/route.js
@@ +126,3 @@
+        let angle = 0;
+        if (turnAngle === null)
+         * calculates the minimum of absolute difference

map? not maps? have you tested this? And could you  format the comment the way I commented earlier?
Comment 39 Prashant Tyagi 2016-01-11 14:12:00 UTC
Created attachment 318737 [details] [review]
A patch for roundabout suppport

A updated patch. last time i didnt tested that so it happens.
Comment 40 Jonas Danielsson 2016-01-11 14:15:54 UTC
Review of attachment 318737 [details] [review]:

Thanks! Looks great!
Comment 41 Jonas Danielsson 2016-01-11 20:30:56 UTC
Review of attachment 318737 [details] [review]:

Pushed, thanks!