osm2mp.pl: OSM -> Polish format converter

I think the problem with the current planet splitting tools like (osmosis and osmcut) is that it requires a lot of preprocessing or RAM to gather all the road polylines. Determining the intersection with a bbox when you have the polylines available is CPU intensive (but doable), but I guess the OSM XML format isn’t very suitable to read polylines from.

I see three possible solutions:
Load all ways into memory (lots of RAM needed) and check each node to see to which way it belongs (CPU intensive), then save the road/node combination as polyline. Finally check each polyline agains every tile bbox to determine if crosses the border. Then add a node on the border position. Then split the way on the border node and save the resulting ways in the individual tile files. That is a lot of work.

Do as described above, but convert the planet file into a shape file first using osm2shp (dunno what how much RAM/CPU time that requires).

While writing this I forgot the third option I had in mind :confused:

Edit: I cannot find any OSM to Shapefile converter in the SVN repository, so this leaves us at the first option…

Hi all!

I’ve updated osm2mp in svn.
Now it supports maxspeed and access=private

Do you mean you add new nodes to the way where it crosses the edge and tag those as “garmin:is_external_node=true”, or do you tag the nearest existing nodes to the edge that way? If it is the 2nd option, how does the Garmin know which route nodes connect to each other?

I’m looking at osmcut currently to do the job. Osmcut already knows which ways cross a tile edge so adding some more functions to enable routing shouldn’t be very difficult.

Yes, the new nodes should be right at the edge of the tile.

Ok, should the node have the same id in both tiles?

Doesn’t have to be the same id. Here’s an example (in polish format) of a way that extends to another tile. The most important thing is that the coordinates should match up, and it is exactly at the edge of the tile.

Tile 1
[POLYLINE]
Type=0x01
EndLevel=4
Label=~[0x04]E2 NSE
DirIndicator=1
Data0=(3.0391936,101.7062182), … (2.6274582,102)
RoadID=1299
RouteParams=6,4,1,0,0,0,0,0,0,0,0,0
Nod0=0,1046,0
Nod1=

Nod16=224,2649,1
[END]

Tile 2
[POLYLINE]
Type=0x01
EndLevel=4
Label=~[0x04]E2 NSE
DirIndicator=1
Data0=(2.6274582,102), … (2.1308003,102.7412188)
RoadID=285
RouteParams=6,4,1,0,0,0,0,0,0,0,0,0
Nod0=0,1143,1
Nod1=56,462,0
Nod2=97,754,0
Nod3=215,375,0
Nod4=223,769,0
[END]

Some info from Rottweiller Auto-Routing guide (via http://cgpsmapper.com/route.htm))

All of the above are if we are using the gpsmapedit method. It seems that maproute can detect and join the matching nodes automatically, which I think is the best way to work with irregular-shaped maps.

Saved by the bell for me :smiley:

http://www.mkgmap.org.uk/page/tile-splitter

Now only Mkgmap needs to be adapted to set the correct edge routing information.

The following is a copy from the IRC talk about this, contains some additional info:

Great stuff indeed :stuck_out_tongue:

Could someone point me to wiki article or similar describing the tiles you are referring to?
What defines the tile edges? I create map from southern half of finland. Looking at the link http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=http:%2F%2Fwww.mkgmap.org.uk%2Ftmp%2Fareas.kml&ie=UTF8&z=3
seems that my map contains 3 tiles. Is that the case?

The tilesplitter has some kind of tile optimisation algorithm which aparently produces these tile bboxes. Luckily you can define your own bboxes as well, placing the while of Finland in a single tile and have the algorithm determine the other bboxes.

This is my result when working with half the planet (Europe, Asia, Africa and Oceania)

That’s nice, prolly a picture of the month… And also fun seeing Google maps being slow.

Hi all!

I’ve added basic cropping functionality to osm2mp. It also creates boundary road nodes.
This time available in svn only.
Use --bbox <minlon,minlat,maxlon,maxlat> to specify boundary box.

Does this mean that I can take one large file (say country.osm), split it into smaller tiles via multiple runs of osm2mp with several matching --bbox’es and routing will work across tile borders?

weolvi,
yes, you can. And routing will work :slight_smile:
You can also use tile splitter first, and then osm2mp with bboxes from areas.list
I’ve successfully built map of Russia such way: http://gpsmapsearch.com/osm/mp/

Note that turn restrictions disabled this time

Awesome! It looks like we now have a full chain of software capable of generating routable Garmin maps without human intervention for the first time. :smiley:

Very cool and good work liosha!

/me is going to implement an automated chain this weekend :slight_smile:

great work , I’m sure we are all waiting for this
thanks

Always a convert a map from an osm file to mp with osm2mp I get some messages saying: Warning! Turn restriction RelID=XXX is not properly processed, but I check relations and seem to be correct (at least I don’t find the error). Could someone check relations in this area [1] and tell me if there’s something wrong or if it’s a problem of osm2mp?
[1] http://www.openstreetmap.org/?lat=39.481821&lon=-6.363901&zoom=18&layers=B000FTF

cdavila,
it’s a problem of osm2mp - this time it can’t process restrictions on splitted roads.
hope i’ll fix it soon :slight_smile:

OK, let’s wait
Thanks