Skip to content

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

@IpswichMapper

Description

@IpswichMapper

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions