Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a "suggest stops" option in the relation editor. #34

Open
IpswichMapper opened this issue Nov 15, 2020 · 4 comments
Open

Add a "suggest stops" option in the relation editor. #34

IpswichMapper opened this issue Nov 15, 2020 · 4 comments
Assignees

Comments

@IpswichMapper
Copy link

IpswichMapper commented Nov 15, 2020

This is the feature that is present in the "public transport" addon, and would be really, REALLY useful if we could have it support the PTv2 schema. Currently, the "public transport" addon needs "forward" and "backward" roles to tell whether a stop is on the left side or right side of the road. If this feature could be implemented into pt_assistant, it could really speed up the mapping of public transport routes.

Here is the java file which (I think) contains the "suggest stops" code:

https://github.com/openstreetmap/josm-plugins/blob/efc3157855f357e2a6d9a1800c75d91b9d4bad29/public_transport/src/org/openstreetmap/josm/plugins/public_transport/actions/RoutePatternAction.java

Here seems to be some code I salvaged from that file that actually does the "suggesting stops":

 else if ("routePattern.metaSuggestStops".equals(event.getActionCommand())) {
            // Prepare Segments: The segments of all usable ways are arranged in a linear
            // list such that a coor can directly be checked concerning position and offset
            Vector<StopReference> srm = new Vector<>();
            // Determine for each member its position on the itinerary: position means here the
            // point on the itinerary that has minimal distance to the coor
            mainDataSet = MainApplication.getLayerManager().getEditDataSet();
            if (mainDataSet != null) {
                String stopKey = "";
                String stopValue = "";
                if ("bus".equals(currentRoute.get("route"))) {
                    stopKey = "highway";
                    stopValue = "bus_stop";
                } else if ("trolleybus".equals(currentRoute.get("route"))) {
                    stopKey = "highway";
                    stopValue = "bus_stop";
                } else if ("tram".equals(currentRoute.get("route"))) {
                    stopKey = "railway";
                    stopValue = "tram_stop";
                } else if ("light_rail".equals(currentRoute.get("route"))) {
                    stopKey = "railway";
                    stopValue = "station";
                } else if ("subway".equals(currentRoute.get("route"))) {
                    stopKey = "railway";
                    stopValue = "station";
                } else if ("rail".equals(currentRoute.get("route"))) {
                    stopKey = "railway";
                    stopValue = "station";
                }

                Collection<Node> nodeCollection = mainDataSet.getNodes();
                Iterator<Node> nodeIter = nodeCollection.iterator();
                while (nodeIter.hasNext()) {
                    Node currentNode = nodeIter.next();
                    if (!currentNode.isUsable())
                        continue;
                    if (stopValue.equals(currentNode.get(stopKey))) {
                        StopReference sr = detectMinDistance(currentNode, segmentMetrics,
                                cbRight.isSelected(), cbLeft.isSelected());
                        if ((sr != null)
                                && (sr.distance < Double.parseDouble(tfSuggestStopsLimit.getText())
                                        * 9.0 / 1000000.0))
                            srm.addElement(sr);
                    }
                }
            }

See: https://lists.openstreetmap.org/pipermail/josm-dev/2020-November/008346.html

@sudhanshu2 sudhanshu2 self-assigned this Nov 16, 2020
@sudhanshu2 sudhanshu2 assigned sudhanshu2 and unassigned sudhanshu2 Nov 29, 2020
@michaelzangl
Copy link
Collaborator

In our region, stops are often to the left (with right hand traffic): The tram is mapped as two separate ways and then the stop is added in the middle between those ways. For rails, this is even more difficult. We have some stops that have platforms at both sides, in some cases, both can be used, in some cases, only the right one.

For this feature, I would advise to use stop areas instead: Detect all stop areas the route is passing. Then, for each area, select the best 'stop' and 'platform', preferring the ones on the right if present.

@IpswichMapper
Copy link
Author

For trains and trams, I think you can have different settings.

However, for buses, stops will always be either on the right or left side of the road. I think this feature should mainly be for buses.

@IpswichMapper
Copy link
Author

IpswichMapper commented Dec 19, 2020

furthermore, like the old public transport addon, you can simply have three options:

  • stops appear on the left side
  • stops appear on the right side
  • stops appear on both sides

If you are doing tram or train, simply chose "stops appear on both sides.

@sudhanshu2

Thanks for undertaking this task!
Is there any progress on this?

@sudhanshu2
Copy link
Collaborator

sudhanshu2 commented Dec 19, 2020

Yeah I have made some progress but I am currently trying to remove the stopToWay bug! I am a bit new to JOSM so I will try and incorporate all of the features you and @michaelzangl have described! Am a bit behind on bug fixes because of school work, but I will try and get this done pretty soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants