Google Summer of Code/2020/PT Assistant Plugin

From OpenStreetMap Wiki
Jump to navigation Jump to search

The PT assistant is a plugin for JOSM. The plugin was written and improved during multiple GSoC years. A lot of current functionality focuses on expert users. The proposal of the current year should focus on usability improvements especially for OpenStreetMap beginner users and users that are used to editing OpenStreetMap but not to public transport.

Development takes place on Github.

Things to work on during this year's GSoC

Unify functionality for foot, bicycle and horse route relations

  • Refactor duplicated code

Relation editor

When opening a public transport route in the relation editor, more PT related actions should be presented.

  • Highlight the closest way when selecting a stop in the relation dialog
  • Add a symbol (maybe a dot on the continuity line?) next to ways close to stops in the relation dialog (to indicate that they have a stop), highlight that stop when selecting them.
  • Add a public transport tab to that dialog that helps with debugging and visualizing PT (master) relations.
    • Might look something like the Overpass PT
    • The main goal is to visualize the route and all its parts and provide quick validation
    • For route relations, a list of Stops that are contained in that relation
    • For route master relations, a list of stops for all relations and a line for each relation indicating which stops it includes (requires some rendering work to get this 'optimal'). Stops can/should be grouped using public transport stop relations.
      Josm-pt-parent-relation-debug.png

    • In this dialog, validation warnings should be indicated
      • If a stop is not on the way
        • Action: 'Open in relation editor' => Selects the stop
        • Action: 'Zoom to stop'
      • If a way between two stops is missing / of wrong type / ...
        • Action: 'Open in relation editor' => selects the two items
        • Action: 'Zoom to gap'
      • If start / end of route is not a stop

Routing helper

  • When routing helper proposes a solution based on other route relations, this solution should be an improvement. If it finds solutions in other route relations which are also going against oneway traffic or over unsuitable highways, it should open these relations in different relation editor windows with the 'offending' ways selected, so they can be removed and fixed.
  • When option 8 to split the white way (origin) is used. The origin way is split correctly, but if the way the bus is going to also needs to be split, this doesn't happen atm.

Validator

  • When pressing fix on the Route passes a oneway in the wrong direction, the selection should be extended to include all adjacent ways on roundabouts
  • There are many other parts of the validator that need to be revised. For example,
    • route gap can be closed by adding a single way, where gaps are fixed should become more interactive. Add the way filling the gap, then open the relation editor for that route with the added way(s) selected, so the user can review what was done.
    • Route contains a gap that can be fixed by sorting. Not entirely sure how to make it more interactive, probably simply open the relation editor after the sorting happened. Or show a before and after somehow.
    • The first stop of the route doesn't match the first way and The last stop of the route doesn't match the last way: Open relation editor with the first stop and way or last stop and way selected and zoom in on them.

Public Transport routing

This is a functionality that is accessible from the relation editor and allows the user to select the way a bus / train takes between two stops.

  • Make it more interactive. e.g. there should be a distinct dialog presenting the progress of the current routing action.
  • It should be clear when the plugin is downloading data, when the user is expected to provide input and when the plugin is done (indicating error / success)
  • Allow to add ways adjacent to stops to route relation prior to starting routing helper
  • Make it more interactive - allow mouse input (clicking on the candidate ways directly) in addition to keyboard input
  • Reimplement option 8 by allowing the mapper to click on suitable side ways.

Smaller improvements

  • Settings → always use the positive form (remove 'not', invert checkboxes)
  • Double split tool: Better indication which way will be split and then make it undoable in one step
  • The same applies to add stop_position node (make it undoable in one step)
  • There are also three keyboard shortcuts (Ctrl-g, Shift-G and Ctrl-Alt-g) which extract a node from a way and convert it to platform node next to the way. Their existence should be more apparent and they should also be undoable in a single step.

New features

If you include these in the proposal, make them optional, i.e. for the third period, time permitting. If there is not enough time, they are for 2021.

  • Make it possible to change a bundle of PT route relations in one go, when all of them are changed at the same time.
  • Different visualisations
    • spider-like diagram excluding stops (just the route bundles)
    • stops coloured along the rainbow spectrum, ways between the stops coloured along that part of the spectrum.

Wizard to set up JOSM environment

  • revise / drop wizard, automatically include functionality into JOSM

Suggested demo of coding ability

  • Add the adjacent way for each stop in the route relation, if it's not present yet. For stops that are split on the stop_position node, it may be needed to add 2 ways. If a stop appears multiple times in the route relation, the adjacent way(s) should also be added two times.

Getting to know the Code

Before you apply, you should get to know the code of the plugin. For this, you should add a small feature to the relation editor. This helps you find out more about how it works and it will help us evaluate your skill set and how you work on coding projects. Your code won't be used in production later, but try to make it readable and maintainable. Add usefull coments.

  • Setting up development. You need Java, IntelliJ community edition and Git
    • Fork the pt_assistant git repository (you need a github account for this)
    • Clone your fork to your local disk
    • Start Intellij
    • 'File' → 'Open' → select the project directory.
    • IntelliJ will download all the required files and set everything up, this may take a few minutes
  • Get to know the plugin
    • On the right hand side, open the 'Gradle' panel
    • Expand 'pt_assistant' → 'Tasks' → 'josm'. Double click on 'runJosm'
    • JOSM will now start and present you with the welcome screen
    • Download a small area of your choice that contains public transport routes (most cities do)
    • Select a bus/train stop. On the right hand side, you will see the routes that stop belongs to
      This bus stop is a member of 'Bus 35'

    • Double click on that row. A new dialog will open.
    • Notice that there are two buttons. Those Buttons are added by the PT Assistant plugin. If you would have started JOSM without the plugin, those buttons would not be there.
      Pt assistant get to know 2.png

    • You can play around with the relation editor / JOSM if you want to
    • Prepare our scenario:
      • Use 'File' → 'New layer' to get an empty layer to play around
      • Zoom in so that you see ~50m on the scale in the top left corner
      • Draw a street consisting of multiple segments. In my example, I use 3 ways. I did draw a long way and then use the split tool.
      • Select a node for the first bus stop, use 'Presets' → 'Transport' → 'Public transport' → 'Stop position', give it a name and 'Apply Preset'. Normally, the 'stop' roled node is next to the way, but it will make implementation easier if we pretend that it is on the way.
      • Select the node for the second bus stop, do the same
      • Select both bus stop nodes. Use 'Presets' → 'Transport' → 'Public transport' → 'Public transport route (bus)'. Enter 'bus' as route type. Give it a name. Click on 'New relation'
      • In the dialog that just opened, enter 'stop' in the role column on the left side.
      • This is what it should look like now:
        Pt assistant get to know 3.png

      • Confirm using 'OK'
  • Now start programming. Your task is to add a button the editor. When the button is pressed, the for each stop of the relation, the neares way is added. In your example, the first and third way would have been added. So after the klick, you would have two mor ways in the left (Members) list of the dialog.
    • Open IntelliJ to start coding
    • Search for the package org.openstreetmap.josm.plugins.pt_assistant.actions
    • Create a new class for your action. The class name should end with 'Action'. It will be the definition for your button.
      • Make your class extend AbstractRelationEditorAction
      • Create the main constructor. Have a look on the RoutingAction on what to include. Ignore the 'tr' calls for now, they are just for translation.
      • Implement updateEnabledState. For now, you can just add a setEnabled(true). Later, you can add more logic and only make the action clickable while it is useful
      • Implement actionPerformed. This is where your real code should go. For testing, use this code: new Notification("Button is working").show();
    • In the PTAssistantPlugin.java, search for the lines containing: RelationEditorHooks.addActionsToMembers. Register your button here the same way as the two other buttons are registered.
    • Now start JOSM, open a public transport relation, click your button. You should see the notification
    • Implement the alogrithm:
      • Your algorithm is:
        • For every member of the relation, do:
          • If it is a 'Node' and it's role is equal to 'stop'
            • Let data be the DataSet of the Node
            • Let ways be all Ways in that DataSet
            • Let way be one of the ways that contains Node
            • If way does not exist, continue with next member
            • Add way to the relation
      • Some hints on the Implementation:
        • Have a look at the first part of SortPTRouteMembersAction#continueAfterDownload
        • You should not modify the relation directly. Instead, copy the relation and work on the copy.
        • To copy, use Relation newRel = new Relation(editor.getRelation());
        • You can get the DataSet (this is all data that JOSM has downloaded so far) using editor.getRelation().getDataSet()
        • Use the debugger and content assist / javadoc to get through the data structures.
        • Ask questions if you are stuck.
        • After you have modified the relation, use this to apply the changes (it will replace the displayed relation with you copy) UndoRedoHandler.getInstance().add(new ChangeCommand(editor.getRelation(), newRel)); editor.reloadDataFromRelation();


Your application

See the GSoC 2020 page for more information. You should have at least basic coding skills in Java, so you should include references in your application. Include a link to the challenge repo as well. We usually do a hangout / skype call to address more details. You should apply / get in touch early, since you are welcome to include your own ideas and so that we can costumize the scope of this project according to your current skill set and to your preferences (and therefore, be honest about your skills - we don't expect students to be perfect coders, but we expect them to communicate honestly). If you have questions or need early feedback, contact User:Polyglot or [osm:user/michael2402 michael2402].