Dear Chen, > Now I see how difficult it is for public transit.Yet I wonder if a public > transport graph is more realistic?
It depends on whether you can invest some time. The simplest and fastest solution might be to use existing systems. A well-known map is http://www.öpnvkarte.de but this is probably not what you want. A better solution would be to bring the bus route data in a proper form. This means to touch each relation. I give you an example how I do it with relations in Germany: --- Begin of: How To --- * Get JOSM with the Public Transport Plugin Download the latest JOSM editor (version 2964). Open it ("java -jar josm-latest.jar"). Go to "Edit > Preferences > Plugins" (the plug symbol), click "Download list" and search for the "public_transport" plugin. Tick the box and close the dialogue. This installs the plugin. Restart JOSM and choose "Update Plugins" if a dialogue box pops up. * Download and edit a relation Let's take relation 23653 as an example. Go to "File > Download object", select "relation" and type 23653, click "Download object". Go to "Public Transport > Route patterns". Choose "bus: 2", change to tab "Itinerary" and click "Show". Now you can see the relation. Open the standard relation editor by clicking on the cogwheel (on the left in the main window). Mark "route ("2" ..." on the right, then click the button with the two sheets of paper. This duplicates the relation to split it into two direction. You can close the editor that pops up by clicking OK. Go in the window "Route Pattern" back to the tab "Overview" and press "Refresh". Mark the first of the two relations "bus: 2 [23653]". Change to the tab "Itinerary" and click "Sort". The plugin tries to sort the itinerary as good as possible. There remain some lines "[gap]"; these lines indicate gaps in the itinerary. Let's examine them one after another: We are now trying to obtain a complete itinerary from "Illervägen" to "Vasaplan". One direction, for the back direction we will use the copied relation. The first entry "Mariehemsvägen" (could also be the last of that name, depending on how the plugin has tried to sort) does not belong to the itinerary in this direction. Mark it in the Route Pattern window and click "Mark" and then "Show". Now the way is highlighted and we see that it is the wrong oneway. Click "Delete" to remove this way. If you now press "Sort" again, you can realise that this "[gap]" is gone away. The same procedure applies to two ways "Blå Vägen" and two ways "Rothoffsvägen" before the way "[ID] 28444098". They are also the wrong oneways for the current direction, can be highlighted with "Mark" and should be deleted. If you now press "Sort" again, you get a complete itinerary - no lines with "[gap]" are leftover. If the sorting produces just the wrong ordering (from Skolgatan to Illervägen), click "Reflect". Go to tab "Stops" and click "Sort". Now the stops are automatically ordered in their proper order. Delete the "backward_stop_10". Congratulations, the first direction is now complete. The back direction required the same steps. First, cleanup the itinerary. Then, order the stops and delete the one stop that's only in the other direction. Now go back to the standard relation editor and add a "to"-tag to each direction. That is not necessary but makes life easier for other mappers. Go to "File > Upload data" and click "Upload changes". Congratulations, now you can completed the entire bus route. -- End of: How To --- Other bus routes are more messy, but after the first sort, things look better. There are 166 bus routes in Sweden at the moment (quite few), thus this should take some rainy weekends if you do it alone. I'll do my best to make the plugin more convenient. Hence please tell me if you have any suggestions. The plugin is at the moment not yet mature and being developed. E.g., are more complete version will allow you to directly duplicate the relation and edit the relations' tags in the plugin itself, without involving the standard relation editor. Thus a better approach would be to encourage the community to improve the data: there is a specific public transport project in Sweden http://wiki.openstreetmap.org/wiki/WikiProject_Sweden/Public_transport I supoose you know it, otherwise you can find there people to contact which can help you with the editing work. I hope you can encourage them with the above how-to. Another motivation might be that proper relations appear in http://www.öpnvkarte.de and as a feature developed this evening: http://78.46.81.38/api/sketch-route?34633&359796 http://78.46.81.38/api/sketch-route?163298&359774 You can replace 34633 and 359796 with a pair of other relation ids representing a bus line. It works (should work) correctly with lines in the Oxmoa scheme as we have created one in the above howto. Yiu can also use http://78.46.81.38/api/sketch-route?34633 and replace 34633 with any relation id but that shows only one direction. > Do you think it is possible to get bus stops (includes the origin and > destination point) in order in a route through any geometry method? If you have for a given bus line a correct and complete itinerary, you can use it to get stops in the correct order. In this case, every bus stop is quite close to a segment of the itinerary. Thus, you can order them by calculating for each stop the nearest point of the itinerary and then order them in the order of the points of the itinerary. The provide some sample code, you can look into the Public Transport Plugin at http://svn.openstreetmap.org/applications/editors/josm/plugins/public_transport/src/public_transport/RoutePatternAction.java The method "detectMinDistance" from line 1694 calculates the closest point for each stop (the itinerary is stored in "segmentMetrics" which is filled in line 1060 in the calling method). This attaches to each node a position information to which segment it belongs. Sorting is with this data structure trivial and done in line 1162. Cheers, Roland _______________________________________________ Talk-transit mailing list Talk-transit@openstreetmap.org http://lists.openstreetmap.org/listinfo/talk-transit