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

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

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

 

http://sharpmap.codeplex.com/wikipage?title=Make%20dashed%20lines&referringTitle=Change%20rendering%20styles

Or like the “City map”:

http://sharpmap.codeplex.com/wikipage?title=Screenshots&referringTitle=Home

thanks Alberto

Coordinator
Feb 24, 2010 at 9: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

Coordinator
Feb 24, 2010 at 10: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

Coordinator
Feb 24, 2010 at 11:54 AM

"Works on My Computer" :)

Coordinator
Feb 24, 2010 at 12: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 12: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);
            geomColl.Add(lineString1);

Feb 24, 2010 at 12:28 PM

..some example with CompoundArray?

 

 

Coordinator
Feb 24, 2010 at 12: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 12: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?

Coordinator
Feb 24, 2010 at 1:07 PM
Edited Feb 24, 2010 at 1: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 1: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.