[Openstreetmap-dev] drawing algorihtms

Tom Carden tom at tom-carden.co.uk
Tue May 24 01:12:52 BST 2005


(Apologies to Matt who got two copies of this).

Here's a demo in Processing which shows how to do it without inventing 
our own clever line stroking algorithms.

http://www.tom-carden.co.uk/p5/osm_lines/applet/

Click to add nodes.  Click and drag to join nodes.  Space to clear. 
Apologies for lack of interface feedback, but I'm sure you get the idea.

It draws thick black strokes with rounded caps, then thinner white 
strokes with rounded caps.  Viola! Outlined roads, without computing 
stacks of intersections.

Java2d can definitely do this (Processing uses Java2d behind the scenes).

Since I emailed Matt, I realised that this would need some tweaking if 
it was to work for bridges etc.  Still, it's a start.

Cheers,

Tom.



Matt Amos wrote:
> On Monday 23 May 2005 16:39, SteveC wrote:
> 
>>and this time I'll actually attach the png
> 
> 
> this is cool.
> 
> i've been looking at the problem in a different way... (without loss 
> of generality etc...) considering regions as closed polygons:
> 
> initial.png: shows the "initial" state - just lines downloaded from 
> OSM.
> 
> step1.png: inset the lines by x+y pixels where x is the road width, y 
> is the "outer" line width.
> 
> step2.png: start with a black background and fill the inset polygons, 
> make the road lines have round joins and caps (stroked in white), as 
> Rob was saying.
> 
> step 3.png: add text on the road lines.
> 
> now, the maximum complexity is the same as steve was saying, but in 
> general, with closed non-overlapping polygons, you only have to 
> consider the left and right lines of the polygon at each vertex...
> 
> cya,
> 
> matt
> 
> 
> ------------------------------------------------------------------------
> 
> 
> ------------------------------------------------------------------------
> 
> 
> ------------------------------------------------------------------------
> 
> 
> ------------------------------------------------------------------------
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Openstreetmap-dev mailing list
> Openstreetmap-dev at vr.ucl.ac.uk
> http://bat.vr.ucl.ac.uk/cgi-bin/mailman/listinfo/openstreetmap-dev





More information about the dev mailing list