Esempio n. 1
0
        public void TestStreetDirectionSymbolizer()
        {
            var p = new SharpMap.Data.Providers.ShapeFile(@"d:\\daten\GeoFabrik\\Aurich\\roads.shp", false);
            var l = new SharpMap.Layers.VectorLayer("roads", p);

            l.Style.Outline       = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 7);
            l.Style.Line          = new System.Drawing.Pen(System.Drawing.Color.Gold, 3);
            l.Style.EnableOutline = true;
            var sd = new SharpMap.Layers.Symbolizer.LinealVectorLayer("streetd", p, new StreetDirectionSymbolizer()
            {
                ArrowLength = 100, RepeatInterval = 500
            });
            var m = new SharpMap.Map(new System.Drawing.Size(1440, 1080))
            {
                BackColor = System.Drawing.Color.Cornsilk
            };

            m.Layers.Add(l);
            m.Layers.Add(sd);

            m.ZoomToExtents();
            m.Zoom *= 0.3;

            var sw = new System.Diagnostics.Stopwatch();

            sw.Start();
            var bmp = m.GetMap();

            sw.Stop();
            System.Console.WriteLine(string.Format("Rendering new method: {0}ms", sw.ElapsedMilliseconds));
            bmp.Save("NDSRoadsSD.bmp");
        }
Esempio n. 2
0
        public void TestPerformanceLinealLayer()
        {
            NUnit.Framework.Assert.IsTrue(System.IO.File.Exists(GetTestDataFilePath("roads_ugl.shp")),
                                          "Specified shapefile is not present!");

            var map = new SharpMap.Map(new System.Drawing.Size(1024, 768));

            var shp = new SharpMap.Data.Providers.ShapeFile(GetTestDataFilePath("roads_ugl.shp"), false, false);
            var lyr = new SharpMap.Layers.Symbolizer.LinealVectorLayer("Roads", shp)
            {
                Symbolizer =
                    new SharpMap.Rendering.Symbolizer.BasicLineSymbolizer
                {
                    Line = new System.Drawing.Pen(System.Drawing.Color.Black)
                }
            };

            map.Layers.Add(lyr);
            map.ZoomToExtents();

            RepeatedRendering(map, shp.GetFeatureCount(), NumberOfRenderCycles, out _msLineal);
            System.Console.WriteLine("\nWith testing if record is deleted ");

            shp.CheckIfRecordIsDeleted = true;
            long tmp;

            RepeatedRendering(map, shp.GetFeatureCount(), 1, out tmp);

            var res  = map.GetMap();
            var path = System.IO.Path.ChangeExtension(GetTestDataFilePath("SPATIAL_F_SKARVMUFF.shp"), "lineal.png");

            res.Save(path, System.Drawing.Imaging.ImageFormat.Png);
            System.Console.WriteLine("\nResult saved at file://" + path.Replace('\\', '/'));
        }
Esempio n. 3
0
        public static void Example3()
        {
            var map = new SharpMap.Map(new Size(1280, 1084));

            SharpMap.Data.Providers.IProvider provider =
                new SharpMap.Data.Providers.ShapeFile(
                    @"C:\temp\Data\niedersachsen.shp\railways.shp");

            var cls = new SharpMap.Rendering.Symbolizer.CachedLineSymbolizer();

            cls.LineSymbolizeHandlers.Add(
                new SharpMap.Rendering.Symbolizer.PlainLineSymbolizeHandler
            {
                Line = new System.Drawing.Pen(System.Drawing.Color.Gold, 2)
            });

            var wls = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander
            {
                Pattern =
                    SharpMap.Rendering.Symbolizer.WarpedLineSymbolizer.
                    GetGreaterSeries(3, 3),
                Line     = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 1),
                Interval = 20
            };

            cls.LineSymbolizeHandlers.Add(wls);

            var vl = new SharpMap.Layers.Symbolizer.LinealVectorLayer(
                "Railways", provider);

            vl.Symbolizer = cls;

            map.Layers.Add(vl);

            var env = vl.Envelope;

            env.ExpandBy(-0.45f * env.Width, -0.45 * env.Height);

            map.ZoomToBox(env);

            var mapImage = map.GetMap();

            mapImage.Save("Example3.png",
                          System.Drawing.Imaging.ImageFormat.Png);
        }
Esempio n. 4
0
        public static void Example3()
        {
            var map = new SharpMap.Map(new Size(1280, 1084));

            SharpMap.Data.Providers.IProvider provider =
                new SharpMap.Data.Providers.ShapeFile(
                    @"C:\temp\Data\niedersachsen.shp\railways.shp");

            var cls = new SharpMap.Rendering.Symbolizer.CachedLineSymbolizer();
            cls.LineSymbolizeHandlers.Add(
                new SharpMap.Rendering.Symbolizer.PlainLineSymbolizeHandler 
                { Line = new System.Drawing.Pen(System.Drawing.Color.Gold, 2) });

            var wls = new SharpMap.Rendering.Symbolizer.WarpedLineSymbolizeHander
            {
                Pattern =
                    SharpMap.Rendering.Symbolizer.WarpedLineSymbolizer.
                    GetGreaterSeries(3, 3),
                Line = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 1),
                Interval = 20
            };
            cls.LineSymbolizeHandlers.Add(wls);

            var vl = new SharpMap.Layers.Symbolizer.LinealVectorLayer(
                "Railways", provider);
            vl.Symbolizer = cls;

            map.Layers.Add(vl);

            var env = vl.Envelope;
            env.ExpandBy(-0.45f * env.Width, -0.45 * env.Height);

            map.ZoomToBox(env);

            var mapImage = map.GetMap();
            mapImage.Save("Example3.png",
                System.Drawing.Imaging.ImageFormat.Png);
        }
Esempio n. 5
0
        private static Map InitializeMapWithSymbolizerLayers(float angle)
        {
            //Initialize a new map of size 'imagesize'
            Map map = new Map();

            //Set up the countries layer
            var layCountries = new SharpMap.Layers.Symbolizer.PolygonalVectorLayer(
                "Countries",
                new ShapeFileEx("GeoData/World/countries.shp", true),
                new BasicPolygonSymbolizer {Fill = new SolidBrush(Color.Green), Outline = Pens.Black,}
                ) {SRID = 4326};

            //Set up a river layer
            var symbolizer = new CachedLineSymbolizer();
            symbolizer.LineSymbolizeHandlers.AddRange( new [] {
                new PlainLineSymbolizeHandler { Line = new Pen(Color.Blue, 3) { LineJoin = LineJoin.Round } },
                new PlainLineSymbolizeHandler{ Line = new Pen(Color.Aqua, 1)}, });

            var layRivers = new SharpMap.Layers.Symbolizer.LinealVectorLayer("Rivers")
                                {
                                    //Set the datasource to a shapefile in the App_data folder
                                    DataSource = new ShapeFileEx("GeoData/World/rivers.shp", true),
                                    //Define a blue 2px wide pen
                                    Symbolizer = symbolizer,
                                    SRID = 4326
                                };

            //Set up a cities layer
            var layCities = new SharpMap.Layers.Symbolizer.PuntalVectorLayer("Cities")
                                {
                                    //Set the datasource to a shapefile in the App_data folder
                                    DataSource = new ShapeFileEx("GeoData/World/cities.shp", true),
                                    Symbolizer = new RasterPointSymbolizer() { Scale = 0.8f },
                                    MaxVisible = 40
                                } ;

            //Set up a country label layer
            var layLabel = new LabelLayer("Country labels")
                               {
                                   DataSource = layCountries.DataSource,
                                   Enabled = true,
                                   LabelColumn = "Name",
                                   Style =
                                       new LabelStyle
                                           {
                                               ForeColor = Color.White,
                                               Font = new Font(FontFamily.GenericSerif, 12),
                                               BackColor = new SolidBrush(Color.FromArgb(128, 255, 0, 0)),
                                               HorizontalAlignment = LabelStyle.HorizontalAlignmentEnum.Center
                                           },
                                   MaxVisible = 90,
                                   MinVisible = 30,
                                   SRID = 4326,
                                   MultipartGeometryBehaviour = LabelLayer.MultipartGeometryBehaviourEnum.Largest,

                               };

            //Set up a city label layer
            var layCityLabel = new LabelLayer("City labels")
                                   {
                                       DataSource = layCities.DataSource,
                                       Enabled = true,
                                       LabelColumn = "Name",
                                       TextRenderingHint = TextRenderingHint.AntiAlias,
                                       SmoothingMode = SmoothingMode.AntiAlias,
                                       SRID = 4326,
                                       LabelFilter = LabelCollisionDetection.ThoroughCollisionDetection,
                                       Style =
                                           new LabelStyle
                                               {
                                                   ForeColor = Color.Black,
                                                   Font = new Font(FontFamily.GenericSerif, 11),
                                                   HorizontalAlignment = LabelStyle.HorizontalAlignmentEnum.Left,
                                                   VerticalAlignment = LabelStyle.VerticalAlignmentEnum.Bottom,
                                                   Offset = new PointF(3, 3),
                                                   CollisionDetection = true,
                                                   Halo = new Pen(Color.Yellow, 2)
                                               }, 
                                       MaxVisible = layLabel.MinVisible,
                                   };

            //Setup River label
            var layRiverLabel = new LabelLayer("River labels")
                                   {
                                       DataSource = layRivers.DataSource,
                                       Enabled = true,
                                       LabelColumn = "Name",
                                       TextRenderingHint = TextRenderingHint.AntiAlias,
                                       SmoothingMode = SmoothingMode.AntiAlias,
                                       SRID = 4326,
                                       LabelFilter = LabelCollisionDetection.ThoroughCollisionDetection,
                                       MultipartGeometryBehaviour = LabelLayer.MultipartGeometryBehaviourEnum.All,
                                       Style =
                                           new LabelStyle
                                               {
                                                   ForeColor = Color.DarkBlue,
                                                   Font = new Font("Arial", 11),
                                                   HorizontalAlignment = LabelStyle.HorizontalAlignmentEnum.Center,
                                                   VerticalAlignment = LabelStyle.VerticalAlignmentEnum.Middle,
                                                   //CollisionDetection = true,
                                                   Halo = new Pen(Color.Azure, 2), 
                                                   IgnoreLength =  true
                                                   
                                               }, 
                                   };

            //Add the layers to the map object.
            //The order we add them in are the order they are drawn, so we add the rivers last to put them on top
            map.Layers.Add(layCountries);
            map.Layers.Add(layRivers);
            map.Layers.Add(layCities);
            map.Layers.Add(layRiverLabel);
            map.Layers.Add(layLabel);
            map.Layers.Add(layCityLabel);


            //limit the zoom to 360 degrees width
            map.MaximumZoom = 360;
            map.BackColor = Color.LightBlue;

            map.Zoom = 360;
            map.Center = new Point(0, 0);

            Matrix mat = new Matrix();
            mat.RotateAt(angle, map.WorldToImage(map.Center));
            map.MapTransform = mat;

            return map;
        }
Esempio n. 6
0
        private static Map InitializeMapWithSymbolizerLayers(float angle)
        {
            //Initialize a new map of size 'imagesize'
            Map map = new Map();

            //Set up the countries layer
            var layCountries = new SharpMap.Layers.Symbolizer.PolygonalVectorLayer(
                "Countries",
                new ShapeFile("GeoData/World/countries.shp", true),
                new BasicPolygonSymbolizer {
                Fill = new SolidBrush(Color.Green), Outline = Pens.Black,
            }
                )
            {
                SRID = 4326
            };

            //Set up a river layer
            var symbolizer = new CachedLineSymbolizer();

            symbolizer.LineSymbolizeHandlers.AddRange(new [] {
                new PlainLineSymbolizeHandler {
                    Line = new Pen(Color.Blue, 3)
                    {
                        LineJoin = LineJoin.Round
                    }
                },
                new PlainLineSymbolizeHandler {
                    Line = new Pen(Color.Aqua, 1)
                },
            });

            var layRivers = new SharpMap.Layers.Symbolizer.LinealVectorLayer("Rivers")
            {
                //Set the datasource to a shapefile in the App_data folder
                DataSource = new ShapeFile("GeoData/World/rivers.shp", true),
                //Define a blue 2px wide pen
                Symbolizer = symbolizer,
                SRID       = 4326
            };

            //Set up a cities layer
            var layCities = new SharpMap.Layers.Symbolizer.PuntalVectorLayer("Cities")
            {
                //Set the datasource to a shapefile in the App_data folder
                DataSource = new ShapeFile("GeoData/World/cities.shp", true),
                Symbolizer = new RasterPointSymbolizer()
                {
                    Scale = 0.8f
                },
                MaxVisible = 40
            };

            //Set up a country label layer
            var layLabel = new LabelLayer("Country labels")
            {
                DataSource  = layCountries.DataSource,
                Enabled     = true,
                LabelColumn = "Name",
                Style       =
                    new LabelStyle
                {
                    ForeColor           = Color.White,
                    Font                = new Font(FontFamily.GenericSerif, 12),
                    BackColor           = new SolidBrush(Color.FromArgb(128, 255, 0, 0)),
                    HorizontalAlignment = LabelStyle.HorizontalAlignmentEnum.Center
                },
                MaxVisible = 90,
                MinVisible = 30,
                SRID       = 4326,
                MultipartGeometryBehaviour = LabelLayer.MultipartGeometryBehaviourEnum.Largest,
            };

            //Set up a city label layer
            var layCityLabel = new LabelLayer("City labels")
            {
                DataSource        = layCities.DataSource,
                Enabled           = true,
                LabelColumn       = "Name",
                TextRenderingHint = TextRenderingHint.AntiAlias,
                SmoothingMode     = SmoothingMode.AntiAlias,
                SRID        = 4326,
                LabelFilter = LabelCollisionDetection.ThoroughCollisionDetection,
                Style       =
                    new LabelStyle
                {
                    ForeColor           = Color.Black,
                    Font                = new Font(FontFamily.GenericSerif, 11),
                    HorizontalAlignment = LabelStyle.HorizontalAlignmentEnum.Left,
                    VerticalAlignment   = LabelStyle.VerticalAlignmentEnum.Bottom,
                    Offset              = new PointF(3, 3),
                    CollisionDetection  = true,
                    Halo                = new Pen(Color.Yellow, 2)
                },
                MaxVisible = layLabel.MinVisible,
            };

            //Setup River label
            var layRiverLabel = new LabelLayer("River labels")
            {
                DataSource        = layRivers.DataSource,
                Enabled           = true,
                LabelColumn       = "Name",
                TextRenderingHint = TextRenderingHint.AntiAlias,
                SmoothingMode     = SmoothingMode.AntiAlias,
                SRID        = 4326,
                LabelFilter = LabelCollisionDetection.ThoroughCollisionDetection,
                MultipartGeometryBehaviour = LabelLayer.MultipartGeometryBehaviourEnum.All,
                Style =
                    new LabelStyle
                {
                    ForeColor           = Color.DarkBlue,
                    Font                = new Font("Arial", 11),
                    HorizontalAlignment = LabelStyle.HorizontalAlignmentEnum.Center,
                    VerticalAlignment   = LabelStyle.VerticalAlignmentEnum.Middle,
                    //CollisionDetection = true,
                    Halo         = new Pen(Color.Azure, 2),
                    IgnoreLength = true
                },
            };

            //Add the layers to the map object.
            //The order we add them in are the order they are drawn, so we add the rivers last to put them on top
            map.Layers.Add(layCountries);
            map.Layers.Add(layRivers);
            map.Layers.Add(layCities);
            map.Layers.Add(layRiverLabel);
            map.Layers.Add(layLabel);
            map.Layers.Add(layCityLabel);


            //limit the zoom to 360 degrees width
            map.MaximumZoom = 360;
            map.BackColor   = Color.LightBlue;

            map.Zoom   = 360;
            map.Center = new Point(0, 0);

            Matrix mat = new Matrix();

            mat.RotateAt(angle, map.WorldToImage(map.Center));
            map.MapTransform = mat;

            return(map);
        }
Esempio n. 7
0
        public void TestStreetDirectionSymbolizer()
        {
            var p = new SharpMap.Data.Providers.ShapeFile(@"d:\\daten\GeoFabrik\\Aurich\\roads.shp", false);
            var l = new SharpMap.Layers.VectorLayer("roads", p);
            l.Style.Outline = new System.Drawing.Pen(System.Drawing.Color.Firebrick, 7);
            l.Style.Line = new System.Drawing.Pen(System.Drawing.Color.Gold, 3);
            l.Style.EnableOutline = true;
            var sd = new SharpMap.Layers.Symbolizer.LinealVectorLayer("streetd", p, new StreetDirectionSymbolizer()
            {
                ArrowLength = 100, RepeatInterval = 500
            });
            var m = new SharpMap.Map(new System.Drawing.Size(1440, 1080)) { BackColor = System.Drawing.Color.Cornsilk };
            m.Layers.Add(l);
            m.Layers.Add(sd);

            m.ZoomToExtents();
            m.Zoom *= 0.3;

            var sw = new System.Diagnostics.Stopwatch();
            sw.Start();
            var bmp = m.GetMap();
            sw.Stop();
            System.Console.WriteLine(string.Format("Rendering new method: {0}ms", sw.ElapsedMilliseconds));
            bmp.Save("NDSRoadsSD.bmp");

        }
Esempio n. 8
-1
        public void TestPerformanceLinealLayer()
        {
            NUnit.Framework.Assert.IsTrue(System.IO.File.Exists(GetTestDataFilePath("roads_ugl.shp")),
                                          "Specified shapefile is not present!");

            var map = new SharpMap.Map(new System.Drawing.Size(1024, 768));

            var shp = new SharpMap.Data.Providers.ShapeFile(GetTestDataFilePath("roads_ugl.shp"));
            var lyr = new SharpMap.Layers.Symbolizer.LinealVectorLayer("Roads", shp)
                          {
                              Symbolizer =
                                  new SharpMap.Rendering.Symbolizer.BasicLineSymbolizer
                                      {Line = new System.Drawing.Pen(System.Drawing.Color.Black)}
                          };
            map.Layers.Add(lyr);
            map.ZoomToExtents();

            RepeatedRendering(map, shp.GetFeatureCount(), NumberOfRenderCycles, out _msLineal);
            System.Console.WriteLine("\nWith testing if record is deleted ");
            
            shp.CheckIfRecordIsDeleted = true;
            long tmp;
            RepeatedRendering(map, shp.GetFeatureCount(), 1, out tmp);

            var res = map.GetMap();
            var path = System.IO.Path.ChangeExtension(GetTestDataFilePath("SPATIAL_F_SKARVMUFF.shp"), "lineal.png");
            res.Save(path, System.Drawing.Imaging.ImageFormat.Png);
            System.Console.WriteLine("\nResult saved at file://" + path.Replace('\\', '/'));
        }