This project has moved and is read-only. For the latest updates, please go here.

Street "Style" line? Which pen or brush???

Topics: Italiano, SharpMap v0.9 / v1.x
Feb 24, 2010 at 10:47 AM

Can i use a Brush or a Pen in order to render lines like this:

Or like the “City map”:

thanks Alberto

Feb 24, 2010 at 10:57 AM

Hi Alberto, use the vectorStyle.Line and vectorStyle.Outline properties. They are both pens - the outline should be wider than the line. hth jd

Feb 24, 2010 at 11:44 AM

Unfortunately setting VectorStyle.Outline property only works for (Multi)Polygon geometries.

If you want to use it on linear geometries you can play with System.Drawing.Pens CompoundArray property or duplicate the layer, one first with a thick pen, the other with a thinner pen.

Hth FObermaier

Feb 24, 2010 at 12:54 PM

"Works on My Computer" :)

Feb 24, 2010 at 1:25 PM

sorry, my fault, you have to set EnableOutline to true, though. Still with this and CompundArray you can draw fancy lines :)

Feb 24, 2010 at 1:26 PM

i've tested with a LineString runs....

            List<Point> points = new List<Point>();
            points.Add(new Point(1, 1));
            points.Add(new Point(10, 1));

            LineString lineString1 = new SharpMap.Geometries.LineString(points);

Feb 24, 2010 at 1:28 PM

..some example with CompoundArray?



Feb 24, 2010 at 1:49 PM
vectorStyle.Line = new Pen(Color.Red, 10F)
                            CompoundArray = new float[] { 0.0F, 0.2F, 0.8F, 1.0F }
will give 2 parallel lines, each 1/5th the width of the whole line (10F) separated by 3/5ths the width of the whole line. cheers jd
Feb 24, 2010 at 1:53 PM

Niiiiiiceeee!!!  i'll try asap....   and...      if i would render something like the standard railway line?     you know??  something similar to - - - | - - - | - - - | - - -

It easy to do?

Feb 24, 2010 at 2:07 PM
Edited Feb 24, 2010 at 2:08 PM

Ah, for the spacing along the line you need to set pen.DashPattern. CompoundArray makes parallel lines that follow 'the line'.

So your vectorStyle might look something like:

vectorStyle.Line = new Pen(Color.Black, 2F);

vectorStyle.OutlineEnabled = true;

vectorStyle.Outline = new Pen(Color.Black, 20F){DashPattern = new float[]{0.2F,10F}}; 


hth jd

Feb 24, 2010 at 2:14 PM

That's was grate!!!!!   thankyou very very very veeeery much!... ...  i'm not so expert of GDI but with this hints i'll learn a lot! 


Thanks again.