Talk:Pyroute

From OpenStreetMap Wiki
Jump to navigation Jump to search

Problems

When I try to use this it never seems to work. I can use pyroute.py to get a route from one node to another perfectly fine it give me a route.osm and a output.png file. Trying to do the same thing using routeasosm.py (or any of the other methods) brings up the list of nodes (in osm format) in the command window then finishes. This creates only one new file route.pyc, confused about what should be happening (as I have no OSM file) I tried running route.pyc and get:

traceback (most recent call last):
file "C:\[loads of directories]\route.py" ,line=132, in <module>
data = loadOsm(sys.argv[1])
IndexError: list index out of range

I am running this on windows, Is that the problem! Or am I not doing something right. I would really love to get this working as it looks really good.

Thanks for any help and sorry if there is somewhere more appropriate for this comment.

--pray4mojo 14:38, 15 November 2007 (UTC)

The list of nodes in the output window is the main output. To save it to a file, run routeAsOsm.py data.osm node1 node2 > route.osm (the header of routeAsOsm.py should confirm this).
When you run routeAsOsm.pyc without any arguments, it fails because you didn't give it a data file, start node, or end node. (pyc files are compiled python files, essentially just python's cached version of the program) Ojw 08:43, 16 November 2007 (UTC)

To get a GPX or OSM file i use the command and then put behind the full command " > route.gpx". Then i get a GPX file.

But i have a problem with the GUI, when i try to load it i get the following error: ValueError: unknown url type: data/wiki.xml . Does anyone have an idea how to create this file? --Skywave 17:38, 15 November 2007 (UTC)

I have not, but I just commented out the two line with "geonames" in them in gui.py. Now, it fails with the tile loading. --Colin Marquardt 00:23, 16 November 2007 (UTC)
Ah, just create a directory "cache"! --Colin Marquardt 00:25, 16 November 2007 (UTC)

Thanks for that skywave I can now get that working but I get the same error as you when I try to run gui.py.--pray4mojo 22:19, 15 November 2007 (UTC)

The wikipedia integration is still in development (e.g. maybe it will go off OSM data instead of geonames soon). To get it to run, download http://ws.geonames.org/findNearbyWikipedia?lat=51.3&lng=-0.2&radius=20 (with your favourite lat/long) and save that as data/wiki.xml Ojw 08:39, 16 November 2007 (UTC)

Suggestions

  • If the output style with all considered routes was interactive, it would also serve well for checking the street network for errors (wrong or missing oneways; unconnected nodes close by; etc.). Even better if it would add info about the cost for each route - would make it easier to see forgotten maxspeed tags or traffic lights. --Colin Marquardt 18:34, 19 November 2007 (UTC)

UK.osm

After leaving it overnight to load, gui.py was able to load the entire UK planet.osm file. Panning and zooming was possible, although I did not test routing.

   16222 KyleG     15   0 1740m 1.1g 5996 S    0 55.8  12:35.67 python ./gui.py uk-071114.osm

Rendering on the fly

One disadvantage of this program is that I can't use it for in-car-navigation or routing since I obviously don't have internet-access there.

So download the tiles first. This is no different to downloading vector data first

So, why do we even need the tiles from the server?

Because it's currently the only map type that pyroute is capable of displaying

We got the OSM-data, so we could actually draw the streets.

Using Osmarender? It takes many CPU-hours of a multi-core desktop machine to render tiles of a city.
Using mapnik? More likely. maybe someone could get postgreSQL running on OpenMoko and populate it with a database of UK roads
Using line_to(x,y)? That would show just a tiny subset of the information currently available on osmarender images.

Nevertheless I have to admit that using Osmarender will take some time to get the pngs so this wouldn't be quite good.

It also wouldn't have correct coastlines, lakes, and islands, or smooth roads, unless it also runs all the tiles@home preprocessing stages.

Are there any ideas/plans to realize rendering on-the-fly with pyroute? --Jannis 21:33, 23 November 2007 (UTC)

Help for use with Windows

Hi, I tried to start it in Win, but I do not get the gui started, kann anybody tell me how to do this? I allready installed python, pycairo, pygtk but allway get the following error:

Traceback (most recent call last):
 File "E:\pyroute\gui.py", line 37, in <module>
   import pygtk
ImportError: No module named pygtk

Maybe some has a step by step "how to"?

Look at Windows section of http://cairographics.org/download/ which links to http://gladewin32.sourceforge.net/modules/news/
Tried this, but doesn't work for me, maybe I'm doing something wrong? --Astrofreak85 15:50, 3 December 2007 (UTC)
I have managed to run pyroute successfully using Win XP. Please see my steps at the Pyroute wiki (under "Download and Installing") --Singastreet 8 January 2008


I have the same problem. Unfortunately the link to "PyGTK all-in-one installer for win32 Tuesday 13 February 2007" doesn´t work. Can anybody give me another URL or send me the file by mail? --John07 14:26, 14 January 2008 (UTC)

The file size is a bit large. Instead, I have uploaded the file and you can find it here. Please note that this is a temporary solution and I will remove the file when the original link is working again. -- Singastreet 06:11, 19 January 2008 (UTC)
Thanks. Unfortunately the installation didn´t solved my problem. Perhaps I have to delet everything and install it again. --John07 08:09, 19 January 2008 (UTC)

Problem loading Setup/poi.txt

Hi,

When I want to start the gui.py, I get:

[<poi_base.poiGroup instance at 0x2f17c20>, <poi_base.poiGroup instance at 0x2f28638>]
Loading POIs from /home/ls/pyroute/Setup/poi.txt
Traceback (most recent call last):
  File "./gui.py", line 406, in <module>
    program = GuiBase()
  File "./gui.py", line 357, in __init__
    self.mapWidget = MapWidget()
  File "./gui.py", line 86, in __init__
    self.loadModules()
  File "./gui.py", line 100, in loadModules
    self.modules['poi']['osm'] = osmPoiModule(self.modules)
  File "/home/ls/pyroute/poi_osm.py", line 30, in __init__
    self.loadPOIs("all", "amenity|shop=*")
  File "/home/ls/pyroute/poi_osm.py", line 43, in loadPOIs
    "Setup", "poi.txt"))
  File "/home/ls/pyroute/poi_osm.py", line 70, in load
    parser.parse(filename)
  File "/usr/lib/python2.6/site-packages/_xmlplus/sax/expatreader.py", line 109, in parse
    xmlreader.IncrementalParser.parse(self, source)
  File "/usr/lib/python2.6/site-packages/_xmlplus/sax/xmlreader.py", line 125, in parse
    self.close()
  File "/usr/lib/python2.6/site-packages/_xmlplus/sax/expatreader.py", line 226, in close
    self.feed("", isFinal = 1)
  File "/usr/lib/python2.6/site-packages/_xmlplus/sax/expatreader.py", line 220, in feed
    self._err_handler.fatalError(exc)
  File "/usr/lib/python2.6/site-packages/_xmlplus/sax/handler.py", line 38, in fatalError
    raise exception
xml.sax._exceptions.SAXParseException: /home/ls/pyroute/data/poi_all.osm:1:0: no element found

This is the contents of Setup/poi.txt:

Pub|amenity=pub
Pub food|amenity=pub;food=yes
Restaurant|amenity=restaurant
Cafe|amenity=cafe
Supermarket|amenity=supermarket
DIY|tourism=diy
Car park|amenity=parking
Free car park|amenity=parking;cost=free
Bike park|amenity=cycle_parking
Lay-by|amenity=layby
Police Stn|amenity=police
Fire Stn|amenity=fire
Hospital|amenity=hospital
Ranger|amenity=ranger_station
Pharmacy|amenity=pharmacy
Car hire|amenity=car_hire
Bike hire|amenity=bike_hire
Ski hire|amenity=ski_hire
Bike shop|amenity=bike_shop
Garage|amenity=garage

How can this be fixed?

Thanks! Nathan

Bugfix to IOError: [Errno socket error] [Errno -2] Name or service unknown

Hi, when i start gui.py, i get:

File "/usr/lib/python2.6/socket.py", line 500, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
IOError: [Errno socket error] [Errno -2] Name or service unknown

Tracing the error i found in tilenames.py this bug:

def tileLayerBase(layer):
  layers = { \
    "tah": "http://cassini.toolserver.org:8080/http://a.tile.openstreetmap.org/+http://toolserver.org/~cmarqu/hill/",

the "tah" key has multiples urls instead one, so i changed it to:

 "tah": "http://toolserver.org/~cmarqu/hill/"

and problem solved.

I hope this helps to anyone with the problem.

Geronimo.