Skip to content

Added Roundabout Instruction - #316

Merged
karussell merged 5 commits into
graphhopper:masterfrom
jansoe:RoundaboutInstr
Feb 6, 2015
Merged

karussell merged 5 commits into
graphhopper:masterfrom
jansoe:RoundaboutInstr

Conversation

@jansoe

@jansoe jansoe commented Feb 3, 2015

Copy link
Copy Markdown
Contributor

This introduces extra instructions for roundabouts (i.e. enter roundabout and take exit 3). This is achieved by subclassing Instruction as RoundaboutInstruction.
Furthermore every instruction now contains its angle (radian).

Things still to improve:

  • Better description by splitting insturctions for entering and leaving roundabout (in translation document)
  • Improve angle calculation by considering slip roads (relates to Wrong and missing turn instruction #94)
  • Expose full roundabout information to json

Code change has no measurable influence on calculation time of instructions (0.3ms of 3ms for Duesseldorfarea )

@karussell

Copy link
Copy Markdown
Member

Thanks! Also for the bunch of tests!

I'll try it tomorrow. Some notes:

  • we need to expose the roundabout information to JSON similar to instructions. As we add the angle to the roundabout instructions we should probably also do for all other.
  • Additionally we have to think how to expose the clockwise variable, either we use a separate property OR we use additional constants like Instruction.USE_ROUNDABOUT_CW, Instruction.USE_ROUNDABOUT_CCW, Instruction.USE_ROUNDABOUT_INVALID? I tend to prefer the first, but would like to discuss.
  • the other points you mentioned are okay if done later
  • to avoid casting to RoundaboutInstruction you can assign it to a temporary variable: RoundaboutInstruction tmpInstruction = new RoundaboutInstruction and as a last step do prevInstruction = tmpInstruction -> read: casting is often ugly and sometimes even a sign of bad design (but yes, sometimes not possible in a different way).
  • Place the open bracket on a new line (maybe we can create an IntelliJ profile similar to what I have in NetBeans). This is none-standard Java coding style but the way we do it currently in GH
  • As the radian is a field in the Instruction class you can expose it directly there: Instruction.getRadian

Also as you have asked to be nit-picky ;)

  • To get the encoder you can grab it more directly, no need for string based stuff: private final FlagEncoder encoder = new CarFlagEncoder(); private final EncodingManager manager = new EncodingManager(encoder);
  • make the tests a little more separate - e.g. one method for clockwise roundabout and one for counterclockwise
  • instead public boolean getContinuedStreet() the getter for boolean is in Java: isContinuedStreet()
  • I would use only positives as variable instead of unfinished I would use finished as !unfinished is too complex for me ;)
  • The inline comment should come before somethings happens e.g. instead of
    int someVar; // some comment do it in two lines:
// some comment
int someVar;

Only sometimes I use one line and behind e.g. as you did sometimes to describe the if-else clauses.

@karussell karussell mentioned this pull request Feb 3, 2015
@karussell karussell added this to the 0.4 milestone Feb 3, 2015
@devemux86

Copy link
Copy Markdown
Contributor

👍

@jansoe

jansoe commented Feb 3, 2015

Copy link
Copy Markdown
Contributor Author

thanx for the comments.
eventually I also missed some test failure, i will fix it tomorrow, and i adress your comments:

  • i agree we should include the angle for all instructions in the json
  • by this we could easily code for the clockwise variable: positve radian -> counterclockwise, negative -> clockwise, and if undetermined getRadian throws an error or special value >2pi
  • Unfortunately I can't assign the Roundabout Instruction to a temporary variable because the instruction "lives" for consecutives iterator calls.
  • getRadian() is already there :) and just overwritten in the RoundaboutInstruction class

So far, more tommorow

@karussell

Copy link
Copy Markdown
Member

eventually I also missed some test failure

Yeah, in RoutingAlgorithmIT there are some tests failing. Maybe some distance addition or points are missing?

and if undetermined getRadian throws an error or special value >2pi

undetermined can only be for tagging problems or strange roundabouts we do not know yet, right? I would prefer Double.NaN

Unfortunately I can't assign the Roundabout Instruction to a temporary variable

Yeah, I just meant within the one if to avoid casting in the loop (I can also change afterwards and you see what I meant or maybe even leave it as it is)

getRadian() is already there :)

ups, perfect :) !

@jansoe

jansoe commented Feb 4, 2015

Copy link
Copy Markdown
Contributor Author

Yeah, in RoutingAlgorithmIT there are some tests failing. Maybe some distance addition or points are missing?

Are there still some test faiures? For me everything worked fine after fixing a bug when starting in Roundabout.

@karussell

Copy link
Copy Markdown
Member

Ah, missed the commit you did yesterday. Looks fine now. Do you want to add json stuff here (or should I?) and merge later or separate issue?

@jansoe

jansoe commented Feb 4, 2015

Copy link
Copy Markdown
Contributor Author

I would adress your comments right now, including json and then push here.
If you prefer to implement the json interface by yourself go ahead.

@karussell

Copy link
Copy Markdown
Member

Nice and yes, if you would do the json stuff it would be even better :)

@karussell
karussell merged commit 055054c into graphhopper:master Feb 6, 2015
@jansoe jansoe mentioned this pull request Feb 6, 2015
5 of 8 tasks
@jansoe
jansoe deleted the RoundaboutInstr branch March 4, 2015 16:48
dabiih pushed a commit to dabiih/graphhopper that referenced this pull request Jan 7, 2025
…raphhopper#316)

* initial version

* custom model is kept even when switching back and forth between desktop and mobile size

* fix bug when mobile view is changed to compact view and no new route is calculated because of an invalid custom model due to missing encoded values (recreation of CustomModelBox without the previously expected /info endpoint being called)

* move CustomModelBox into SettingsBox but outside of settingsTable

* minor -> warn

* minor css fix

* make settings css better fit the rest

* 1. URL with custom_model should trigger a routing request with it; 2. avoid route re-calculation if settings box is shown; 3. invalid custom model is reset to custom model before if settings box is closed

* tricky to fix error 'Cannot use import statement outside a module' in tests: 1. insist on transpiling custom model editor code to avoid ES6 modules for jest and 2. allowJs in tsconfig and 3. explicitly transform js files using ts-jest - why?

* remove CustomModel from QueryStore state

* formatting

* revert change with SettingsContext to use ShowDistanceInMilesContext

* format and clean up imports

* show error message if invalid custom model (not possible at Settings construction time)

* not many benefits to use validateJson as e.g. encoded values not yet known

* revert commit 96108d7e07af7811bdf908d32b8fc4f6804c3e89

* remove TODO NOW

* Use string to represent custom model state (graphhopper#320)

* Move custom model examples to separate file

* Minor rename

* Extract custom model area function

* Remove openSettingsHandle

* Rename custom model examples file

* Remove warning that can never occur

* Move state from settings to query store, query store even depended on settings..

* minor

* move custom model box out of settings

* oops, made a mistake

* Use string to represent custom model state!

* much better

* add todos

* Rename action

* no shadow, use text instead

* i18n: update

* separate custom model box and settings box and use gear as indicator instead of shadow

* format

---------

Co-authored-by: easbar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants