bug in LineClipper (branches/nod)

Hi, there seems to be something wrong in LineClipper.clip -- it seems to create a bunch of zero-node roads, which then cause a crash in RoadDef.writeNod2 due to a null RoadDef.node. Since my attempts to understand LineClipper.clip failed, I reimplemented it somewhat more explicitly, patch attached. I won't be offended if you prefer to fix your algorithm; the patch is quite ugly and I'm not really sure it works outside my samples. The resulting maps appear to have some segments missing. Do you think this might be caused by clipping? Cheers Robert

Hi I am just about to commit a merge the work from trunk into nod which I hope doesn't confuse things too much. Sorry if it does.
there seems to be something wrong in LineClipper.clip -- it seems to create a bunch of zero-node roads, which then cause a crash in
OK, I havn't looked at your patch fully yet, but I see a problem. MapRoad is a sublass of MapLine, but if one is clipped, then it is copied as if it were a MapLine. Therefore it will not get a roadId or a roadDef set.
The resulting maps appear to have some segments missing. Do you think this might be caused by clipping?
Perhaps, but nothing should be clipped, should it? There may be a bug where more is being clipped than should be. This was recently the case with polygons and a similar bug caused all polygons to be invisible. Cheers, ..Steve

On Nov 27, 2008, at 23:52, Steve Ratcliffe wrote:
I am just about to commit a merge the work from trunk into nod which I hope doesn't confuse things too much. Sorry if it does.
Don't worry.
OK, I havn't looked at your patch fully yet, but I see a problem. MapRoad is a sublass of MapLine, but if one is clipped, then it is copied as if it were a MapLine. Therefore it will not get a roadId or a roadDef set.
The patch was intended to provide a functionally equivalent version of LineClipper.clip (apart from possible bugs). So it shouldn't affect MapRoad. Apart from that: LineClipper.clip is called from FeatureListConverter.clipAndAddLine. This clips the line and then calls FeatureListConverter.addLine for each part, which creates a new MapRoad object for such a subline, so each should get its roadId and roadDef. Cheers Robert

On Nov 28, 2008, at 10:08, Robert Vollmert wrote:
Apart from that: LineClipper.clip is called from FeatureListConverter.clipAndAddLine. This clips the line and then calls FeatureListConverter.addLine for each part, which creates a new MapRoad object for such a subline, so each should get its roadId and roadDef.
FeatureListConverter is gone now, and StyledConverter doesn't do roads yet. That's probably where the confusion arose. So I tried going through polish format (using osm2mp). mkgmap had a little trouble reading the resulting mp file; I've attached a patch (including some extra logging statements). Routing now seems to work, even over the invisible segments. If I compile with '--net' instead of '--route', the map looks the same (also missing some segments). If I run it without '--net', the map is quite strangely broken. Finally, if I run current trunk, the map is blank. Cheers Rob

I found two more things: For one, old versions of mkgmap create a kind of bounding box in each subdivison, while the current nod-branch doesn't. Could this be related to roads sometimes not showing up the way they should? I also found the map displayed better if I added some POIs around the outsides of the map. Secondly, the filters may convert MapRoads to MapLines. In particular, I had this problem with SmoothingFilter. A possible solution would be to go from newline = new MapLine(oldline); to something like newline = oldline.copy(); If that looks good for you, I can try to make a patch. Cheers Robert

Hi Robert,
The patch was intended to provide a functionally equivalent version of LineClipper.clip (apart from possible bugs). So it shouldn't affect MapRoad.
Oh I didn't mean in your patch. I meant the case that you mention in one of your next posts where the Road in converted to a Line if it is split. ..Steve

On Nov 27, 2008, at 23:52, Steve Ratcliffe wrote:
The resulting maps appear to have some segments missing. Do you think this might be caused by clipping?
Perhaps, but nothing should be clipped, should it? There may be a bug where more is being clipped than should be. This was recently the case with polygons and a similar bug caused all polygons to be invisible.
I've looked at this some more... My guess would be that something is wrong with the Polyline bitstreams. In my sample, there's two problematic roads. Each has three nodes (two segments), and one zoom level, the first is missing its last segment, while at the other level, the other one misses its last segment. Extending both roads by one segment, the two first segments were always there, but the new segments went missing as before. I also tried reversing one of the roads, and its problem went away. I also tested the "node" bits in the bitstream (all to true, all to false, no difference). Shifting the first point of the road so it wasn't straight anymore also caused the last segment to show always. All missing segments I've observed were in straight roads. One other thing: the background polygons aren't generated for .mp files because PolishMapDataSource doesn't call mapper.finish(). Adding this doesn't make a noticeable difference, though. Cheers Robert

I've looked at this some more... My guess would be that something is wrong with the Polyline bitstreams.
In that case it is likely to be extraBit as that is now used and is different to how I used to think it worked. There may still be something to find out about how it works.
One other thing: the background polygons aren't generated for .mp files because PolishMapDataSource doesn't call mapper.finish(). Adding this doesn't make a noticeable difference, though.
Yes, I suppose I expected that a .mp file will always supply everything it needs. That may just be wrong though, in which case will have to add the same code as for the OSM conversion. Cheers, ..Steve
participants (2)
-
Robert Vollmert
-
Steve Ratcliffe