Esempio n. 1
0
        internal static SharpMap.Map InitializeMap(float angle, string[] filenames)
        {
            var map = new SharpMap.Map();

            try
            {
                foreach (var filename in filenames)
                {
                    var connectionString = string.Format("Data Source={0}", filename);
                    foreach (var provider in SharpMap.Data.Providers.SpatiaLite.GetSpatialTables(connectionString))
                    {
                        map.Layers.Add(
                            new SharpMap.Layers.VectorLayer(
                                string.Format("{0} - {1}", provider.Table, provider.GeometryColumn), provider)
                        {
                            Style = LayerTools.GetRandomVectorStyle()
                        });
                    }
                }
                if (map.Layers.Count > 0)
                {
                    map.ZoomToExtents();

                    System.Drawing.Drawing2D.Matrix mat = new System.Drawing.Drawing2D.Matrix();
                    mat.RotateAt(angle, map.WorldToImage(map.Center));
                    map.MapTransform = mat;
                    return(map);
                }
            }
            catch (System.Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }
            return(null);
        }
Esempio n. 2
0
        internal static Map InitializeMap(float angle, string[] filenames)
        {
            if (filenames == null)
            {
                return(null);
            }

            Map map = new Map();

            try
            {
                foreach (string filename in filenames)
                {
                    string connectionString = string.Format("Data Source={0}", filename);
                    foreach (SpatiaLite provider in SpatiaLite.GetSpatialTables(connectionString))
                    {
                        map.Layers.Add(
                            new VectorLayer(
                                string.Format("{0} - {1}", provider.Table, provider.GeometryColumn), provider)
                        {
                            Style = LayerTools.GetRandomVectorStyle()
                        });
                    }
                }
                if (map.Layers.Count > 0)
                {
                    map.ZoomToExtents();

                    Matrix mat = new Matrix();
                    mat.RotateAt(angle, map.WorldToImage(map.Center));
                    map.MapTransform = mat;
                    return(map);
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
            return(null);
        }