Need Help with osm5XmlHandler File

Hello, I wanted to patch /trunk/src/uk/me/parabola/mkgmap/reader/osm/xml/Osm5XmlHandler.java to map oneway attributes to 'highway=oneway1' adapting the code that was used for the cycleway opposite patch. Attached is what I added but it does not work. Can someone find the mistake or my understanding error? (I would like to do this for several attributes like tracktype, mtb:scale or oneway, currently I render them in different mkgmap runs, and add it together as a layer) I would prefer to have everything in one layer however to save compiling time. I would be fine editing all in this file, or maybe even better would be to have mkgmap call lines0, lines1, lines2, lines3 file and subsequent in one run and put them all into the same .img. I can't use the overlays file, because it's too limited for what I wan't to achieve because I can't possibly list all possible combinations. Find attached the patch I tried to use, please someone help me why it doesn't work (I added highway=oneway1 and oneway1=* in the lines stylefile to search for but id doesn't find them, nor displays them in the map). Index: Osm5XmlHandler.java =================================================================== --- Osm5XmlHandler.java (revision 1052) +++ Osm5XmlHandler.java (working copy) @@ -72,7 +72,8 @@ private static final int MODE_BOUNDS = 5; private static final long CYCLEWAY_ID_OFFSET = 0x10000000; - + private static final long ONEWAY_ID_OFFSET = 0x20000000; + private Node currentNode; private Way currentWay; private Relation currentRelation; @@ -84,7 +85,8 @@ private Runnable endTask; private long nextFakeId = 1; - + + private final boolean makeOnewayOverlay; private final boolean makeOppositeCycleways; private final boolean ignoreBounds; private final boolean ignoreTurnRestrictions; @@ -93,6 +95,7 @@ private final String frigRoundabouts; public Osm5XmlHandler(EnhancedProperties props) { + makeOnewayOverlay = props.getProperty("make-oneway-overlay", false); makeOppositeCycleways = props.getProperty("make-opposite-cycleways", false); ignoreBounds = props.getProperty("ignore-osm-bounds", false); routing = props.containsKey("route"); @@ -314,7 +317,26 @@ log.info("Making opposite cycleway '" + cycleWay.getTag("name") + "'"); } } - } + + + if(makeOnewayOverlay && currentWay.isBoolTag("oneway")) { + String onewayTag = currentWay.getTag("oneway1"); + // what we want is an arrow pointing into the direction + // of the onway attribute, therefore we make a copy of all + // oneway ways except oneway=-1 which we will have to give it's + // own ruleset. + long oneway1Id = currentWay.getId() + ONEWAY_ID_OFFSET; + Way oneway1 = new Way(oneway1Id); + wayMap.put(oneway1Id, oneway1); + // I hope that I made no errors above on copying the code + oneway1.copyTags(currentWay); + log.info("Making Oneway Overlay '"); + } + } + + + + if("motorway".equals(highway) || "trunk".equals(highway)) motorways.add(currentWay);

Hi Felix, Not sure what you're trying to achieve but looking at the patch I see you have: + String onewayTag = currentWay.getTag("oneway1"); that's getting the value of the tag "oneway1" but then onewayTag doesn't seem to be used anywhere (unless I missed it). Err, don't you want to be setting that tag rather than reading it? Something like: oneway1.addTag("oneway1"); Cheers, Mark

Hi Mark, What I want to achieve is getting a copy of the way. I named the copy of the way oneway1 it could be named anything (that's not yet existing). Actually I don't need it to be routable. Here's a sceenshot how the final result is supposed to look like (currently I do this by processing the data twice (well actually even more times, but for each attribute one additional time). So I want to copy oneway attribute to line=oneway1 so I can add an additional line in the my style-file calling for highway=oneway1 [0x3a resolution 24]. The reason I don't wan't to use the overlay file, is that I don't know all possible street values that exist for oneway. Also I do the same for mtb:scale, mtb:scale:uphill, tracktype, sac_scale and routes. So I would end up with something like 2^10 additional overlay types per line in my lines file, assuming any tag can exist besides each other. My problem was that I did not completely understand your code of doubling the cycleways. So I wan't to achieve the same look as below, but instead of passing two style-files, each in a seperate mkgmap call, I would like to do it in one call. Thanks for your help (I will try your correction but I bet it is not enough). Felix Mark Burton wrote:
Hi Felix,
Not sure what you're trying to achieve but looking at the patch I see you have:
+ String onewayTag = currentWay.getTag("oneway1");
that's getting the value of the tag "oneway1" but then onewayTag doesn't seem to be used anywhere (unless I missed it). Err, don't you want to be setting that tag rather than reading it? Something like:
oneway1.addTag("oneway1");
Cheers,
Mark _______________________________________________ mkgmap-dev mailing list mkgmap-dev@lists.mkgmap.org.uk http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

On May 31, 2009, at 8:27 PM, Felix Hartmann wrote:
Attached is what I added but it does not work
Hi Felix, If I didn't miss it, your code appears to be missing the statements for copying the nodes of the old way to the new one. In Mark Burton's code, the nodes are copied in reverse, as he reverses the way. You need to copy them in the correct direction. If you look at my patch for pedestrian squares, you can see something similar. Hope this helps. Cheers.
participants (3)
-
Clinton Gladstone
-
Felix Hartmann
-
Mark Burton