JOSM / pt_assistant

JOSM's Public Transport Assistant plugin
https://wiki.openstreetmap.org/wiki/JOSM/Plugins/PT_Assistant
GNU General Public License v3.0
9 stars 12 forks source link

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

Open IpswichMapper opened 3 years ago

IpswichMapper commented 3 years ago

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

michaelzangl commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

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 commented 3 years ago

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!