Exemplo n.º 1
0
        public void TestLayer()
        {
            var map = new SharpMap.Map(new System.Drawing.Size(500, 500));
            var gp  = new SharpMap.Data.Providers.FeatureProvider(
                new[]
            {
                Factory.CreatePolygon(
                    ShapeFactory.CreateEllipse(Factory, new GeoAPI.Geometries.Coordinate(0, 0),
                                               new System.Drawing.SizeF(40, 30)),
                    new[]
                {
                    ShapeFactory.CreateEllipse(Factory, new GeoAPI.Geometries.Coordinate(90, 55),
                                               new System.Drawing.SizeF(40, 30)),
                    ShapeFactory.CreateEllipse(Factory, new GeoAPI.Geometries.Coordinate(77, 24),
                                               new System.Drawing.SizeF(40, 30)),
                    ShapeFactory.CreateEllipse(Factory, new GeoAPI.Geometries.Coordinate(-80, 41),
                                               new System.Drawing.SizeF(40, 30)),
                    ShapeFactory.CreateEllipse(Factory, new GeoAPI.Geometries.Coordinate(-45, -36),
                                               new System.Drawing.SizeF(40, 30)),
                })
            });
            var gl = new SharpMap.Layers.VectorLayer("GeometryLayer", gp);

            map.Layers.Add(gl);
            map.ZoomToExtents();
            var mapimage = map.GetMap();

            mapimage.Save("ellipse.png", System.Drawing.Imaging.ImageFormat.Png);
        }
Exemplo n.º 2
0
        public void CreatingFeatureProviderWithNoSchema()
        {
            FProvider provider = new FProvider(null);
            DataTable schema   = provider.GetSchemaTable();

            Assert.Equal(0, schema.Rows.Count);
        }
Exemplo n.º 3
0
        public void TestCharacterPointSymbolizer()
        {
            var fdt = TestData.CreatingData.CreatePointFeatureDataTableFromArrays(
                TestData.CreatingData.GetRandomOrdinates(50, -180, 180), TestData.CreatingData.GetRandomOrdinates(50, -90, 90), null);
            var geometryFeatureProvider = new SharpMap.Data.Providers.FeatureProvider(fdt);
            var layer = new SharpMap.Layers.VectorLayer("randompoints", geometryFeatureProvider);
            var cps   = new SharpMap.Rendering.Symbolizer.CharacterPointSymbolizer
            {
                Halo      = 1,
                HaloBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Wheat),
                //Font = new System.Drawing.Font("Arial", 12),
                CharacterIndex = 0xcc,
            };

            layer.Style.PointSymbolizer = cps;
            var map = new SharpMap.Map(new System.Drawing.Size(720, 360));

            map.Layers.Add(layer);
            map.ZoomToExtents();
            map.GetMap().Save("CharacterPointSymbolizer1.bmp");

            cps.Rotation = -30;
            cps.Offset   = new System.Drawing.PointF(4, 4);
            map.GetMap().Save("CharacterPointSymbolizer2.bmp");

            cps.Font     = new System.Drawing.Font("Arial", 12);
            cps.Text     = "ABC";
            cps.Offset   = System.Drawing.PointF.Empty;
            cps.Rotation = -90;
            map.GetMap().Save("CharacterPointSymbolizer3.bmp");
        }
Exemplo n.º 4
0
        public void TestCharacterPointSymbolizer()
        {
            var fdt = CreatingData.CreatePointFeatureDataTableFromArrays(
                CreatingData.GetRandomOrdinates(50, -180, 180), CreatingData.GetRandomOrdinates(50, -90, 90), null);
            var geometryFeatureProvider = new SharpMap.Data.Providers.FeatureProvider(fdt);
            var layer = new SharpMap.Layers.VectorLayer("randompoints", geometryFeatureProvider);
            var cps  = new SharpMap.Rendering.Symbolizer.CharacterPointSymbolizer
                                              {
                                                  Halo = 1,
                                                  HaloBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Wheat),
                                                  //Font = new System.Drawing.Font("Arial", 12),
                                                  CharacterIndex = 0xcc,
                                              };
            layer.Style.PointSymbolizer = cps;
            var map = new SharpMap.Map(new System.Drawing.Size(720, 360));
            
            map.Layers.Add(layer);
            map.ZoomToExtents();
            map.GetMap().Save("CharacterPointSymbolizer1.bmp");

            cps.Rotation = -30;
            cps.Offset = new System.Drawing.PointF(4, 4);
            map.GetMap().Save("CharacterPointSymbolizer2.bmp");

            cps.Font = new System.Drawing.Font("Arial", 12);
            cps.Text = "ABC";
            cps.Offset = System.Drawing.PointF.Empty;
            cps.Rotation = -90;
            map.GetMap().Save("CharacterPointSymbolizer3.bmp");
        }
Exemplo n.º 5
0
        public void TestListPointSymbolizer()
        {
            var fdt = TestData.CreatingData.CreatePointFeatureDataTableFromArrays(
                TestData.CreatingData.GetRandomOrdinates(50, -180, 180), TestData.CreatingData.GetRandomOrdinates(50, -90, 90), null);
            var geometryFeatureProvider = new SharpMap.Data.Providers.FeatureProvider(fdt);
            var layer = new SharpMap.Layers.VectorLayer("randompoints", geometryFeatureProvider);
            var pps   =
                SharpMap.Rendering.Symbolizer.PathPointSymbolizer.CreateSquare(new System.Drawing.Pen(System.Drawing.Color.Red, 2),
                                                                               new System.Drawing.SolidBrush(
                                                                                   System.Drawing.Color.DodgerBlue), 20);

            var cps = new SharpMap.Rendering.Symbolizer.CharacterPointSymbolizer
            {
                Halo           = 1,
                HaloBrush      = new System.Drawing.SolidBrush(System.Drawing.Color.WhiteSmoke),
                Foreground     = new System.Drawing.SolidBrush(System.Drawing.Color.Black),
                Font           = new System.Drawing.Font("Arial", 12),
                CharacterIndex = 65
            };

            var lps = new SharpMap.Rendering.Symbolizer.ListPointSymbolizer {
                pps, cps
            };

            layer.Style.PointSymbolizer = lps;
            var map = new SharpMap.Map(new System.Drawing.Size(720, 360));

            map.Layers.Add(layer);
            map.ZoomToExtents();
            map.GetMap().Save("ListPointSymbolizer1.bmp");
        }
Exemplo n.º 6
0
        public void TestListPointSymbolizer()
        {
            var fdt = TestData.CreatingData.CreatePointFeatureDataTableFromArrays(
                TestData.CreatingData.GetRandomOrdinates(50, -180, 180), TestData.CreatingData.GetRandomOrdinates(50, -90, 90), null);
            var geometryFeatureProvider = new SharpMap.Data.Providers.FeatureProvider(fdt);
            var layer = new SharpMap.Layers.VectorLayer("randompoints", geometryFeatureProvider);
            var pps =
                SharpMap.Rendering.Symbolizer.PathPointSymbolizer.CreateSquare(new System.Drawing.Pen(System.Drawing.Color.Red, 2),
                                                                    new System.Drawing.SolidBrush(
                                                                        System.Drawing.Color.DodgerBlue), 20);

            var cps = new SharpMap.Rendering.Symbolizer.CharacterPointSymbolizer
            {
                Halo = 1,
                HaloBrush = new System.Drawing.SolidBrush(System.Drawing.Color.WhiteSmoke),
                Foreground = new System.Drawing.SolidBrush(System.Drawing.Color.Black),
                Font = new System.Drawing.Font("Arial", 12),
                CharacterIndex = 65
            };

            var lps = new SharpMap.Rendering.Symbolizer.ListPointSymbolizer { pps, cps };

            layer.Style.PointSymbolizer = lps;
            var map = new SharpMap.Map(new System.Drawing.Size(720, 360));
            map.Layers.Add(layer);
            map.ZoomToExtents();
            map.GetMap().Save("ListPointSymbolizer1.bmp");
        }
Exemplo n.º 7
0
        public void TestXml1()
        {
            var xml         = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<root>
  <Points>
    <Point>
    <X>13457786.5961983</X>
    <Y>1629064.58490612</Y>
    </Point>
  </Points>
</root>";
            var xmlFileName = System.IO.Path.ChangeExtension(System.IO.Path.GetTempFileName(), "xml");

            using (var sw = new System.IO.StreamWriter(System.IO.File.OpenWrite(xmlFileName)))
                sw.Write(xml);

            var factory = new NetTopologySuite.Geometries.GeometryFactory();

            SharpMap.Data.Providers.FeatureProvider p = null;
            using (var fs = System.IO.File.OpenRead(xmlFileName))
            {
                p = new SharpMap.Data.Providers.FeatureProvider(PointsFromXml(factory, fs));
                NUnit.Framework.Assert.IsNotNull(p);
                NUnit.Framework.Assert.AreEqual(1, p.Features.Count);
            }

            System.IO.File.Delete(xmlFileName);
        }
Exemplo n.º 8
0
        public void TestXml1()
        {
            var xml = @"<?xml version=""1.0"" encoding=""utf-8"" ?>
<root>
  <Points>
    <Point>
    <X>13457786.5961983</X>
    <Y>1629064.58490612</Y>
    </Point>
  </Points>
</root>";
            var xmlFileName = System.IO.Path.ChangeExtension(System.IO.Path.GetTempFileName(), "xml");
            
            using (var sw = new System.IO.StreamWriter(System.IO.File.OpenWrite(xmlFileName)))
                sw.Write(xml);

            var factory = new NetTopologySuite.Geometries.GeometryFactory();

            SharpMap.Data.Providers.FeatureProvider p = null;
            using (var fs = System.IO.File.OpenRead(xmlFileName))
            {
                p = new SharpMap.Data.Providers.FeatureProvider(PointsFromXml(factory, fs));
                NUnit.Framework.Assert.IsNotNull(p);
                NUnit.Framework.Assert.AreEqual(1, p.Features.Count);
            }

            System.IO.File.Delete(xmlFileName);
        }
Exemplo n.º 9
0
        public void TestPathPointSymbolizer()
        {
            var fdt = CreatingData.CreatePointFeatureDataTableFromArrays(
                CreatingData.GetRandomOrdinates(50, -180, 180), CreatingData.GetRandomOrdinates(50, -90, 90), null);
            var geometryFeatureProvider = new SharpMap.Data.Providers.FeatureProvider(fdt);
            var layer = new SharpMap.Layers.VectorLayer("randompoints", geometryFeatureProvider);
            var pps =
                SharpMap.Rendering.Symbolizer.PathPointSymbolizer.CreateSquare(new System.Drawing.Pen(System.Drawing.Color.Red, 2),
                                                                    new System.Drawing.SolidBrush(
                                                                        System.Drawing.Color.DodgerBlue), 20);
            layer.Style.PointSymbolizer = pps;
            var map = new SharpMap.Map(new System.Drawing.Size(720, 360));
            map.Layers.Add(layer);
            map.ZoomToExtents();
            map.GetMap().Save("PathPointSymbolizer1.bmp");

            pps.Rotation = -30;
            map.GetMap().Save("PathPointSymbolizer2.bmp");

            pps.Rotation = 0f;
            pps.Offset = new System.Drawing.PointF(4, 4);
            map.GetMap().Save("PathPointSymbolizer3.bmp");

            var gpTriangle1 = new System.Drawing.Drawing2D.GraphicsPath();
            gpTriangle1.AddPolygon(new [] { new System.Drawing.Point(0, 0), new System.Drawing.Point(5, 10), new System.Drawing.Point(10, 0), new System.Drawing.Point(0, 0), });
            var gpTriangle2 = new System.Drawing.Drawing2D.GraphicsPath();
            gpTriangle2.AddPolygon(new[] { new System.Drawing.Point(0, 0), new System.Drawing.Point(-5, -10), new System.Drawing.Point(-10, 0), new System.Drawing.Point(0, 0), });
            pps = new
                SharpMap.Rendering.Symbolizer.PathPointSymbolizer(new[]
                                                        {
                                                            new SharpMap.Rendering.Symbolizer.PathPointSymbolizer.PathDefinition
                                                                {
                                                                    Path = gpTriangle1,
                                                                    Line =
                                                                        new System.Drawing.Pen(
                                                                        System.Drawing.Color.Red, 2),
                                                                    Fill =
                                                                        new System.Drawing.SolidBrush(
                                                                        System.Drawing.Color.DodgerBlue)
                                                                },
                                                            new SharpMap.Rendering.Symbolizer.PathPointSymbolizer.PathDefinition
                                                                {
                                                                    Path = gpTriangle2,
                                                                    Line =
                                                                        new System.Drawing.Pen(
                                                                        System.Drawing.Color.DodgerBlue, 2),
                                                                    Fill =
                                                                        new System.Drawing.SolidBrush(
                                                                        System.Drawing.Color.Red)
                                                                }

                                                        }){ Rotation = 45 };

            layer.Style.PointSymbolizer = pps;
            map.GetMap().Save("PathPointSymbolizer4.bmp");
            pps.Rotation = 180;
            map.GetMap().Save("PathPointSymbolizer5.bmp");

        }
Exemplo n.º 10
0
 public void TestSetUp()
 {
     using (var sf = new SharpMap.Data.Providers.ShapeFile(GetTestDataFilePath("roads_ugl.shp")))
     {
         sf.Open();
         var fds = new SharpMap.Data.FeatureDataSet();
         sf.ExecuteIntersectionQuery(sf.GetExtents(), fds);
         _provider = new SharpMap.Data.Providers.FeatureProvider(fds.Tables[0]);
     }
 }
        public void CreatingFeatureProviderWithSchema()
        {
            DataColumn[] columns = new DataColumn[]
                {
                    new DataColumn("Column1", typeof (Int32)),
                    new DataColumn("Column2", typeof (String)),
                    new DataColumn("Column3", typeof (DateTime)),
                };

            FProvider provider = new FProvider(null, columns);
            DataTable schema = provider.GetSchemaTable();
            Assert.Equal(3, schema.Rows.Count);
        }
Exemplo n.º 12
0
        public void DoTest()
        {
            SharpMap.Data.Providers.ShapeFile sf  = new SharpMap.Data.Providers.ShapeFile("cities.shp");
            SharpMap.Data.FeatureDataSet      fds = new SharpMap.Data.FeatureDataSet();
            sf.ExecuteIntersectionQuery(sf.GetExtents(), fds);
            SharpMap.Data.Providers.FeatureProvider gfp =
                new SharpMap.Data.Providers.FeatureProvider(fds.Tables[0]);

            System.Data.DataTable dt = new System.Data.DataTable("external");
            dt.Columns.Add("city", typeof(string));
            dt.Columns.Add("males", typeof(int));
            dt.Columns.Add("females", typeof(int));
        }
Exemplo n.º 13
0
        public void CreatingFeatureProviderWithSchema()
        {
            DataColumn[] columns = new DataColumn[]
            {
                new DataColumn("Column1", typeof(Int32)),
                new DataColumn("Column2", typeof(String)),
                new DataColumn("Column3", typeof(DateTime)),
            };

            FProvider provider = new FProvider(null, columns);
            DataTable schema   = provider.GetSchemaTable();

            Assert.Equal(3, schema.Rows.Count);
        }
Exemplo n.º 14
0
        public void TestRealData()
        {
            var fdt = GetRealFeatureDataTable();
            FillRealDataTable(fdt);

            var p = new SharpMap.Data.Providers.FeatureProvider(fdt);


            var m = new SharpMap.Map(new Size(640, 640));
            m.Layers.Add(new TileLayer(
                new OsmTileSource(new OsmRequest(KnownTileServers.Mapnik) /*, 
                                  new FileCache(@"d:\temp\OSM", "png")*/), "OSM"));

            var l = new HeatLayer(p, "Data", 0.001f);
            l.LayerName = "HEAT";
            m.Layers.Add(l);
#if DotSpatialProjections
            l.CoordinateTransformation = new DotSpatial.Projections.CoordinateTransformation
            {
                Source = ProjectionInfo.FromEpsgCode(4326), 
                Target = ProjectionInfo.FromEpsgCode(3857)
            };
#else
            var ctfac = new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory();
            l.CoordinateTransformation =
                ctfac.CreateFromCoordinateSystems(ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84,
                                                  ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WebMercator);
#endif
            l.ZoomMin = 0;// 0.01 * m.GetExtents().Width;
            l.ZoomMax = /*0.9 * */m.GetExtents().Width;
            l.OpacityMax = 1;
            l.OpacityMin = 0.3f;

            m.ZoomToBox(l.Envelope);
            for (var i = 0; i < 5; i++)
            {
                using (var img = m.GetMap())
                {
                    img.Save("RealDataHeat" + i + ".png");
                }
                m.Zoom /= 2;
            }
            m.ZoomToExtents();
            using (var img = m.GetMap())
            {
                img.Save("RealDataHeat.png");
            }

        }
        private void FormMovingObjectOverTileLayer_Load(object sender, EventArgs e)
        {

            //Lisbon...
#if DotSpatialProjections
            var mathTransform = LayerTools.Wgs84toGoogleMercator;
            var geom = GeometryTransform.TransformBox(
                new Envelope(-9.205626, -9.123736, 38.690993, 38.740837),
                mathTransform.Source, mathTransform.Target);
#else
            var mathTransform = LayerTools.Wgs84toGoogleMercator.MathTransform;
            GeoAPI.Geometries.Envelope geom = GeometryTransform.TransformBox(
                new Envelope(-9.205626, -9.123736, 38.690993, 38.740837),
                mathTransform);
#endif


            //Google Background
            TileAsyncLayer layer2 = new TileAsyncLayer(new OsmTileSource(), "TileLayer - OSM");


            this.mapBox1.Map.BackgroundLayer.Add(layer2);
            var gf = new GeometryFactory(new PrecisionModel(), 3857);

            //Adds a static layer
            var staticLayer = new VectorLayer("Fixed Marker");
            //position = geom.GetCentroid();
            var aux = new List<IGeometry>();
            aux.Add(gf.CreatePoint(geom.Centre));
            staticLayer.Style.Symbol = Resources.PumpSmall;
            var geoProviderFixed = new SharpMap.Data.Providers.FeatureProvider(aux);
            staticLayer.DataSource = geoProviderFixed;
            this.mapBox1.Map.Layers.Add(staticLayer);

            
            //Adds a moving variable layer
            VectorLayer pushPinLayer = new VectorLayer("PushPins");
            position = geom.Centre;
            geos.Add(gf.CreatePoint(position));
            pushPinLayer.Style.Symbol = Resources.OutfallSmall;
            var geoProvider = new SharpMap.Data.Providers.FeatureProvider(geos);
            pushPinLayer.DataSource = geoProvider;
            this.mapBox1.Map.VariableLayers.Add(pushPinLayer);

            this.mapBox1.Map.ZoomToBox(geom);
            this.mapBox1.Refresh();

        }
Exemplo n.º 16
0
        public static SharpMap.Map InitializeMap(float angle)
        {
            var fdt = GetRealFeatureDataTable();
            FillRealDataTable(fdt);

            var p = new SharpMap.Data.Providers.FeatureProvider(fdt);


            var m = new SharpMap.Map();
            m.BackgroundLayer.Add(new SharpMap.Layers.TileAsyncLayer(
                new BruTile.Web.OsmTileSource(
                                  new BruTile.Web.OsmRequest(BruTile.Web.KnownTileServers.Mapnik),
                                  new BruTile.Cache.FileCache(@"d:\temp\OSM", "png")), "OSM"));
            m.BackgroundLayer[0].LayerName = "TileLayer with HeatLayer";

            //var l = new SharpMap.Layers.HeatLayer(p, r => 0.02f) { LayerName = "HEAT" };
            var l = new SharpMap.Layers.HeatLayer(p, "Data", 0.00025f) { LayerName = "HEAT" };
            m.Layers.Add(l);

#if DotSpatialProjections
            l.CoordinateTransformation = new DotSpatial.Projections.CoordinateTransformation
            {
                Source = DotSpatial.Projections.ProjectionInfo.FromEpsgCode(4326),
                Target = DotSpatial.Projections.ProjectionInfo.FromEpsgCode(3857)
            };
#else
            var ctfac = new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory();
            l.CoordinateTransformation =
                ctfac.CreateFromCoordinateSystems(ProjNet.CoordinateSystems.GeographicCoordinateSystem.WGS84,
                                                  ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WebMercator);
#endif

            l.ZoomMin = 0;// 0.01 * m.GetExtents().Width;
            l.ZoomMax = /*0.9 * */m.GetExtents().Width;
            l.OpacityMax = 0.5f;
            l.OpacityMin = 0.9f;

            l.HeatColorBlend = SharpMap.Layers.HeatLayer.Classic;

            var env = l.Envelope;
            GeoAPI.Geometries.GeoAPIEx.Grow(env, env.Width * 0.05, env.Height * 0.05);
            //m.EnforceMaximumExtents = true;
            //m.MaximumExtents = env;
            m.ZoomToBox(env);

            return m;
        }
Exemplo n.º 17
0
        private void FormMovingObjectOverTileLayer_Load(object sender, EventArgs e)
        {
            //Lisbon...
#if DotSpatialProjections
            var mathTransform = LayerTools.Wgs84toGoogleMercator;
            var geom          = GeometryTransform.TransformBox(
                new Envelope(-9.205626, -9.123736, 38.690993, 38.740837),
                mathTransform.Source, mathTransform.Target);
#else
            var mathTransform = LayerTools.Wgs84toGoogleMercator.MathTransform;
            GeoAPI.Geometries.Envelope geom = GeometryTransform.TransformBox(
                new Envelope(-9.205626, -9.123736, 38.690993, 38.740837),
                mathTransform);
#endif


            //Google Background
            TileAsyncLayer layer2 = new TileAsyncLayer(new OsmTileSource(), "TileLayer - OSM");


            this.mapBox1.Map.BackgroundLayer.Add(layer2);
            var gf = new GeometryFactory(new PrecisionModel(), 3857);

            //Adds a static layer
            var staticLayer = new VectorLayer("Fixed Marker");
            //position = geom.GetCentroid();
            var aux = new List <IGeometry>();
            aux.Add(gf.CreatePoint(geom.Centre));
            staticLayer.Style.Symbol = Resources.PumpSmall;
            var geoProviderFixed = new SharpMap.Data.Providers.FeatureProvider(aux);
            staticLayer.DataSource = geoProviderFixed;
            this.mapBox1.Map.Layers.Add(staticLayer);


            //Adds a moving variable layer
            VectorLayer pushPinLayer = new VectorLayer("PushPins");
            position = geom.Centre;
            geos.Add(gf.CreatePoint(position));
            pushPinLayer.Style.Symbol = Resources.OutfallSmall;
            var geoProvider = new SharpMap.Data.Providers.FeatureProvider(geos);
            pushPinLayer.DataSource = geoProvider;
            this.mapBox1.Map.VariableLayers.Add(pushPinLayer);

            this.mapBox1.Map.ZoomToBox(geom);
            this.mapBox1.Refresh();
        }
Exemplo n.º 18
0
        protected override void OnMapControlChangedInternal(EventArgs e)
        {
            base.OnMapControlChangedInternal(e);

            if (MapControl == null)
            {
                _layer.Dispose();
                _layer  = null;
                Enabled = false;
                return;
            }

            _geometryProvider = new SharpMap.Data.Providers.FeatureProvider((GeoAPI.Geometries.IGeometry)null);
            _layer            = new SharpMap.Layers.VectorLayer("_tmp_Geometries", _geometryProvider);

            MapControl.ActiveToolChanged += OnMapControlActiveToolChanged;
            MapControl.GeometryDefined   += OnGeometryDefined;
        }
Exemplo n.º 19
0
        public void HeatLayerTest()
        {
            var m = new SharpMap.Map(new Size(640, 480));
            var data = CreatingData.CreatePointFeatureDataTableFromArrays(
                CreatingData.GetRandomOrdinates(150, 5, 6),
                CreatingData.GetRandomOrdinates(150, 52, 53), null,
                CreatingData.GetRandomOrdinates(150, 0, 1));

            var p = new SharpMap.Data.Providers.FeatureProvider(data);
            var l = new HeatLayer(p, "Data");

            m.Layers.Add(l);
            m.ZoomToBox(new Envelope(5.4, 5.8, 52.4, 52.6));
            //m.ZoomToExtents();

            var img = m.GetMap();
            img.Save("HeatMap.png", ImageFormat.Png);
            img.Dispose();
        }
Exemplo n.º 20
0
        public void TestRasterPointSymbolizer()
        {
            var fdt = TestData.CreatingData.CreatePointFeatureDataTableFromArrays(
                TestData.CreatingData.GetRandomOrdinates(50, -180, 180), TestData.CreatingData.GetRandomOrdinates(50, -90, 90), null);
            var geometryFeatureProvider = new SharpMap.Data.Providers.FeatureProvider(fdt);
            var layer = new SharpMap.Layers.VectorLayer("randompoints", geometryFeatureProvider);
            var rps   =
                new SharpMap.Rendering.Symbolizer.RasterPointSymbolizer {
                Symbol = Properties.Resources.Women
            };

            layer.Style.PointSymbolizer = rps;
            var map = new SharpMap.Map(new System.Drawing.Size(720, 360));

            map.Layers.Add(layer);
            map.ZoomToExtents();
            map.GetMap().Save("RasterPointSymbolizer1.bmp");

            rps.Rotation = 45;
            map.GetMap().Save("RasterPointSymbolizer2.bmp");
            rps.Rotation = 0;

            var cps = new SharpMap.Rendering.Symbolizer.CharacterPointSymbolizer
            {
                Halo       = 1,
                HaloBrush  = new System.Drawing.SolidBrush(System.Drawing.Color.WhiteSmoke),
                Foreground = new System.Drawing.SolidBrush(System.Drawing.Color.Black),
                Font       = new System.Drawing.Font("Arial", 12),
                Text       = "Anne",
                Offset     = new System.Drawing.PointF(0, rps.Size.Height * 0.5f)
            };

            var lps = new SharpMap.Rendering.Symbolizer.ListPointSymbolizer {
                rps, cps
            };

            layer.Style.PointSymbolizer = lps;
            map.Layers.Add(layer);
            map.ZoomToExtents();
            map.GetMap().Save("RasterPointSymbolizer3.bmp");
        }
Exemplo n.º 21
0
        public void DoTest()
        {
            SharpMap.Data.Providers.ShapeFile sf = new SharpMap.Data.Providers.ShapeFile("cities.shp");
            SharpMap.Data.FeatureDataSet fds = new SharpMap.Data.FeatureDataSet();
            sf.ExecuteIntersectionQuery(sf.GetExtents(), fds);
            SharpMap.Data.Providers.FeatureProvider gfp =
                new SharpMap.Data.Providers.FeatureProvider(fds.Tables[0]);

            System.Data.DataTable dt = new System.Data.DataTable("external");
            dt.Columns.Add("city", typeof (string));
            dt.Columns.Add("males", typeof (int));
            dt.Columns.Add("females", typeof (int));


        }
        protected override void OnMapControlChangedInternal(EventArgs e)
        {
            base.OnMapControlChangedInternal(e);

            if (MapControl == null)
            {
                _layer.Dispose();
                _layer = null;
                Enabled = false;
                return;
            }

            _geometryProvider = new SharpMap.Data.Providers.FeatureProvider((GeoAPI.Geometries.IGeometry)null);
            _layer = new SharpMap.Layers.VectorLayer("_tmp_Geometries", _geometryProvider);

            MapControl.ActiveToolChanged += OnMapControlActiveToolChanged;
            MapControl.GeometryDefined += OnGeometryDefined;


            
        }
Exemplo n.º 23
0
 public void TestLayer()
 {
     var map = new SharpMap.Map(new System.Drawing.Size(500, 500));
     var gp = new SharpMap.Data.Providers.FeatureProvider(
         new[]
             {
                 Factory.CreatePolygon(
                     ShapeFactory.CreateEllipse(Factory, new GeoAPI.Geometries.Coordinate(0, 0),
                                                new System.Drawing.SizeF(40, 30)),
                     new[]
                         {
                             ShapeFactory.CreateEllipse(Factory, new GeoAPI.Geometries.Coordinate(90, 55),
                                                        new System.Drawing.SizeF(40, 30)),
                             ShapeFactory.CreateEllipse(Factory, new GeoAPI.Geometries.Coordinate(77, 24),
                                                        new System.Drawing.SizeF(40, 30)),
                             ShapeFactory.CreateEllipse(Factory, new GeoAPI.Geometries.Coordinate(-80, 41),
                                                        new System.Drawing.SizeF(40, 30)),
                             ShapeFactory.CreateEllipse(Factory, new GeoAPI.Geometries.Coordinate(-45, -36),
                                                        new System.Drawing.SizeF(40, 30)),
                         })
             });
     var gl = new SharpMap.Layers.VectorLayer("GeometryLayer", gp);
     map.Layers.Add(gl);
     map.ZoomToExtents();
     var mapimage = map.GetMap();
     mapimage.Save("ellipse.png", System.Drawing.Imaging.ImageFormat.Png);
 }
Exemplo n.º 24
0
        public void TestPathPointSymbolizer()
        {
            var fdt = TestData.CreatingData.CreatePointFeatureDataTableFromArrays(
                TestData.CreatingData.GetRandomOrdinates(50, -180, 180), TestData.CreatingData.GetRandomOrdinates(50, -90, 90), null);
            var geometryFeatureProvider = new SharpMap.Data.Providers.FeatureProvider(fdt);
            var layer = new SharpMap.Layers.VectorLayer("randompoints", geometryFeatureProvider);
            var pps   =
                SharpMap.Rendering.Symbolizer.PathPointSymbolizer.CreateSquare(new System.Drawing.Pen(System.Drawing.Color.Red, 2),
                                                                               new System.Drawing.SolidBrush(
                                                                                   System.Drawing.Color.DodgerBlue), 20);

            layer.Style.PointSymbolizer = pps;
            var map = new SharpMap.Map(new System.Drawing.Size(720, 360));

            map.Layers.Add(layer);
            map.ZoomToExtents();
            map.GetMap().Save("PathPointSymbolizer1.bmp");

            pps.Rotation = -30;
            map.GetMap().Save("PathPointSymbolizer2.bmp");

            pps.Rotation = 0f;
            pps.Offset   = new System.Drawing.PointF(4, 4);
            map.GetMap().Save("PathPointSymbolizer3.bmp");

            var gpTriangle1 = new System.Drawing.Drawing2D.GraphicsPath();

            gpTriangle1.AddPolygon(new [] { new System.Drawing.Point(0, 0), new System.Drawing.Point(5, 10), new System.Drawing.Point(10, 0), new System.Drawing.Point(0, 0), });
            var gpTriangle2 = new System.Drawing.Drawing2D.GraphicsPath();

            gpTriangle2.AddPolygon(new[] { new System.Drawing.Point(0, 0), new System.Drawing.Point(-5, -10), new System.Drawing.Point(-10, 0), new System.Drawing.Point(0, 0), });
            pps = new
                  SharpMap.Rendering.Symbolizer.PathPointSymbolizer(new[]
            {
                new SharpMap.Rendering.Symbolizer.PathPointSymbolizer.PathDefinition
                {
                    Path = gpTriangle1,
                    Line =
                        new System.Drawing.Pen(
                            System.Drawing.Color.Red, 2),
                    Fill =
                        new System.Drawing.SolidBrush(
                            System.Drawing.Color.DodgerBlue)
                },
                new SharpMap.Rendering.Symbolizer.PathPointSymbolizer.PathDefinition
                {
                    Path = gpTriangle2,
                    Line =
                        new System.Drawing.Pen(
                            System.Drawing.Color.DodgerBlue, 2),
                    Fill =
                        new System.Drawing.SolidBrush(
                            System.Drawing.Color.Red)
                }
            })
            {
                Rotation = 45
            };

            layer.Style.PointSymbolizer = pps;
            map.GetMap().Save("PathPointSymbolizer4.bmp");
            pps.Rotation = 180;
            map.GetMap().Save("PathPointSymbolizer5.bmp");
        }
Exemplo n.º 25
0
        public void TestRasterPointSymbolizer()
        {
            var fdt = CreatingData.CreatePointFeatureDataTableFromArrays(
                CreatingData.GetRandomOrdinates(50, -180, 180), CreatingData.GetRandomOrdinates(50, -90, 90), null);
            var geometryFeatureProvider = new SharpMap.Data.Providers.FeatureProvider(fdt);
            var layer = new SharpMap.Layers.VectorLayer("randompoints", geometryFeatureProvider);
            var rps =
                new SharpMap.Rendering.Symbolizer.RasterPointSymbolizer {Symbol = new System.Drawing.Bitmap("women.png")};

            layer.Style.PointSymbolizer = rps;
            var map = new SharpMap.Map(new System.Drawing.Size(720, 360));
            map.Layers.Add(layer);
            map.ZoomToExtents();
            map.GetMap().Save("RasterPointSymbolizer1.bmp");

            rps.Rotation = 45;
            map.GetMap().Save("RasterPointSymbolizer2.bmp");
            rps.Rotation = 0;

            var cps = new SharpMap.Rendering.Symbolizer.CharacterPointSymbolizer
                          {
                              Halo = 1,
                              HaloBrush = new System.Drawing.SolidBrush(System.Drawing.Color.WhiteSmoke),
                              Foreground = new System.Drawing.SolidBrush(System.Drawing.Color.Black),
                              Font = new System.Drawing.Font("Arial", 12),
                              Text = "Anne",
                              Offset = new System.Drawing.PointF(0, rps.Size.Height*0.5f)
                
            };

            var lps = new SharpMap.Rendering.Symbolizer.ListPointSymbolizer { rps, cps };

            layer.Style.PointSymbolizer = lps;
            map.Layers.Add(layer);
            map.ZoomToExtents();
            map.GetMap().Save("RasterPointSymbolizer3.bmp");
        }
 public void CreatingFeatureProviderWithNoSchema()
 {
     FProvider provider = new FProvider(null);
     DataTable schema = provider.GetSchemaTable();
     Assert.Equal(0, schema.Rows.Count);
 }
 public void TestSetUp()
 {
     using (var sf = new SharpMap.Data.Providers.ShapeFile(GetTestDataFilePath("roads_ugl.shp")))
     {
         sf.Open();
         var fds = new SharpMap.Data.FeatureDataSet();
         sf.ExecuteIntersectionQuery(sf.GetExtents(), fds);
         _provider = new SharpMap.Data.Providers.FeatureProvider(fds.Tables[0]);
     }
 }