Exemplo n.º 1
0
        private static void Main()
        {
            var gss = new NtsGeometryServices();
            var css = new SharpMap.CoordinateSystems.CoordinateSystemServices(
                new CoordinateSystemFactory(),
                new CoordinateTransformationFactory(),
                SharpMap.Converters.WellKnownText.SpatialReference.GetAllReferenceSystems());

            // plug-in WebMercator so that correct spherical definition is directly available to Layer Transformations using SRID
            var pcs = (ProjectedCoordinateSystem)ProjectedCoordinateSystem.WebMercator;

            css.AddCoordinateSystem((int)pcs.AuthorityCode, pcs);

            GeoAPI.GeometryServiceProvider.Instance = gss;
            SharpMap.Session.Instance
            .SetGeometryServices(gss)
            .SetCoordinateSystemServices(css)
            .SetCoordinateSystemRepository(css);

            // for SqlServerSample referencing SharpMap.SqlServerSpatialObjects
            //SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new DlgSamplesMenu());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Static constructor to perform 1-time initialisation.
        /// </summary>
        static MapView()
        {
            System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
            GeoAPI.GeometryServiceProvider.Instance = new NtsGeometryServices();
            var css = new SharpMap.CoordinateSystems.CoordinateSystemServices(
                new ProjNet.CoordinateSystems.CoordinateSystemFactory(System.Text.Encoding.Unicode),
                new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory(),
                SharpMap.Converters.WellKnownText.SpatialReference.GetAllReferenceSystems());

            SharpMap.Session.Instance
            .SetGeometryServices(GeoAPI.GeometryServiceProvider.Instance)
            .SetCoordinateSystemServices(css)
            .SetCoordinateSystemRepository(css);
        }
Exemplo n.º 3
0
        public void SetUp()
        {
            var gss = new NetTopologySuite.NtsGeometryServices();
            var css = new SharpMap.CoordinateSystems.CoordinateSystemServices(
                new ProjNet.CoordinateSystems.CoordinateSystemFactory(System.Text.Encoding.ASCII),
                new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory(),
                SharpMap.Converters.WellKnownText.SpatialReference.GetAllReferenceSystems());

            GeoAPI.GeometryServiceProvider.Instance = gss;
            SharpMap.Session.Instance
            .SetGeometryServices(gss)
            .SetCoordinateSystemServices(css)
            .SetCoordinateSystemRepository(css);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Static constructor to perform 1-time initialisation.
        /// </summary>
        static MapView()
        {
            System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
            GeoAPI.GeometryServiceProvider.Instance = new NtsGeometryServices();
            var coordFactory = new ProjNet.CoordinateSystems.CoordinateSystemFactory(System.Text.Encoding.Unicode);
            var css          = new SharpMap.CoordinateSystems.CoordinateSystemServices(coordFactory,
                                                                                       new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory());

            css.AddCoordinateSystem(3857, coordFactory.CreateFromWkt("PROJCS[\"WGS 84 / Pseudo-Mercator\", GEOGCS[\"WGS 84\", DATUM[\"WGS_1984\", SPHEROID[\"WGS 84\", 6378137, 298.257223563, AUTHORITY[\"EPSG\", \"7030\"]], AUTHORITY[\"EPSG\", \"6326\"]], PRIMEM[\"Greenwich\", 0, AUTHORITY[\"EPSG\", \"8901\"]], UNIT[\"degree\", 0.0174532925199433, AUTHORITY[\"EPSG\", \"9122\"]], AUTHORITY[\"EPSG\", \"4326\"]], UNIT[\"metre\", 1, AUTHORITY[\"EPSG\", \"9001\"]], PROJECTION[\"Mercator_1SP\"], PARAMETER[\"latitude_of_origin\", 0], PARAMETER[\"central_meridian\", 0], PARAMETER[\"scale_factor\", 1], PARAMETER[\"false_easting\", 0], PARAMETER[\"false_northing\", 0], AUTHORITY[\"EPSG\", \"3857\"]]"));
            css.AddCoordinateSystem(4326, coordFactory.CreateFromWkt("GEOGCS[\"WGS 84\", DATUM[\"WGS_1984\", SPHEROID[\"WGS 84\", 6378137, 298.257223563, AUTHORITY[\"EPSG\", \"7030\"]], AUTHORITY[\"EPSG\", \"6326\"]], PRIMEM[\"Greenwich\", 0, AUTHORITY[\"EPSG\", \"8901\"]], UNIT[\"degree\", 0.0174532925199433, AUTHORITY[\"EPSG\", \"9122\"]], AUTHORITY[\"EPSG\", \"4326\"]]"));
            SharpMap.Session.Instance
            .SetGeometryServices(GeoAPI.GeometryServiceProvider.Instance)
            .SetCoordinateSystemServices(css)
            .SetCoordinateSystemRepository(css);
        }
Exemplo n.º 5
0
        public MainWindow()
        {
            InitializeComponent();

            var gss = GeoAPI.GeometryServiceProvider.Instance;
            var css = new SharpMap.CoordinateSystems.CoordinateSystemServices(
                new ProjNet.CoordinateSystems.CoordinateSystemFactory(System.Text.Encoding.ASCII),
                new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory(),
                SharpMap.Converters.WellKnownText.SpatialReference.GetAllReferenceSystems());

            GeoAPI.GeometryServiceProvider.Instance = gss;
            SharpMap.Session.Instance
            .SetGeometryServices(gss)
            .SetCoordinateSystemServices(css)
            .SetCoordinateSystemRepository(css);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Method to configure the SharpMap session.
        /// </summary>
        public static void Configure()
        {
            var gss = new NtsGeometryServices();
            var css = new SharpMap.CoordinateSystems.CoordinateSystemServices(
                new CoordinateSystemFactory(),
                new CoordinateTransformationFactory(),
                Converters.WellKnownText.SpatialReference.GetAllReferenceSystems());

            // plug-in WebMercator so that correct spherical definition is directly available to Layer Transformations using SRID
            var pcs = ProjectedCoordinateSystem.WebMercator;

            css.AddCoordinateSystem((int)pcs.AuthorityCode, pcs);
            Session.Instance
            .SetGeometryServices(gss)
            .SetCoordinateSystemServices(css)
            .SetCoordinateSystemRepository(css);
        }
Exemplo n.º 7
0
        static void Main()
        {
            var gss = new NtsGeometryServices();
            var css = new SharpMap.CoordinateSystems.CoordinateSystemServices(
                new CoordinateSystemFactory(),
                new CoordinateTransformationFactory(),
                SharpMap.Converters.WellKnownText.SpatialReference.GetAllReferenceSystems());

            GeoAPI.GeometryServiceProvider.Instance = gss;
            SharpMap.Session.Instance
            .SetGeometryServices(gss)
            .SetCoordinateSystemServices(css)
            .SetCoordinateSystemRepository(css);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }
Exemplo n.º 8
0
        public void RunBeforeAnyTests()
        {
            var gss = new NetTopologySuite.NtsGeometryServices();
            var css = new SharpMap.CoordinateSystems.CoordinateSystemServices(
                new ProjNet.CoordinateSystems.CoordinateSystemFactory(),
                new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory(),
                SharpMap.Converters.WellKnownText.SpatialReference.GetAllReferenceSystems());

            GeoAPI.GeometryServiceProvider.Instance = gss;
            SharpMap.Session.Instance
            .SetGeometryServices(gss)
            .SetCoordinateSystemServices(css)
            .SetCoordinateSystemRepository(css);

            _stopWatch = new System.Diagnostics.Stopwatch();
            System.Diagnostics.Trace.WriteLine("Starting tests");
            _stopWatch.Start();
        }
Exemplo n.º 9
0
        public Form1()
        {
            var gss = new NtsGeometryServices();
            var css = new SharpMap.CoordinateSystems.CoordinateSystemServices(
                new CoordinateSystemFactory(),
                new CoordinateTransformationFactory(),
                SharpMap.Converters.WellKnownText.SpatialReference.GetAllReferenceSystems());

            GeoAPI.GeometryServiceProvider.Instance = gss;

            SharpMap.Session.Instance
            .SetGeometryServices(gss)
            .SetCoordinateSystemServices(css)
            .SetCoordinateSystemRepository(css);

            InitializeComponent();

            mapBox1.ActiveTool = MapBox.Tools.Pan;
            mapBox1.Map.SRID   = 3857;

            LoadMap();
        }
Exemplo n.º 10
0
        public void RunBeforeAnyTests()
        {
            var gss = new NetTopologySuite.NtsGeometryServices();
            var css = new SharpMap.CoordinateSystems.CoordinateSystemServices(
                new ProjNet.CoordinateSystems.CoordinateSystemFactory(),
                new ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory(),
                SharpMap.Converters.WellKnownText.SpatialReference.GetAllReferenceSystems());

            GeoAPI.GeometryServiceProvider.Instance = gss;
            SharpMap.Session.Instance
            .SetGeometryServices(gss)
            .SetCoordinateSystemServices(css)
            .SetCoordinateSystemRepository(css);

            // plug-in WebMercator so that correct spherical definition is directly available to Layer Transformations using SRID
            var pcs = (ProjNet.CoordinateSystems.ProjectedCoordinateSystem)ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WebMercator;

            css.AddCoordinateSystem((int)pcs.AuthorityCode, pcs);

            _stopWatch = new System.Diagnostics.Stopwatch();
            System.Diagnostics.Trace.WriteLine("Starting tests");
            _stopWatch.Start();
        }
Exemplo n.º 11
0
        protected void Application_Start(object sender, EventArgs e)
        {
            var gss = new NtsGeometryServices();
            var css = new SharpMap.CoordinateSystems.CoordinateSystemServices(
                new CoordinateSystemFactory(),
                new CoordinateTransformationFactory(),
                SharpMap.Converters.WellKnownText.SpatialReference.GetAllReferenceSystems());

            GeoAPI.GeometryServiceProvider.Instance = gss;
            SharpMap.Session.Instance
            .SetGeometryServices(gss)
            .SetCoordinateSystemServices(css)
            .SetCoordinateSystemRepository(css);

            string        settingsfile = Server.MapPath("~/App_Data/settings.xml");
            XmlSerializer serializer   = new XmlSerializer(typeof(SharpMapContext));

            if (!System.IO.File.Exists(settingsfile))
            {
                /*create default settings*/
                SharpMapContext ctx = new SharpMapContext();
                ctx.Capabilities = new WmsCapabilities()
                {
                    Title    = "SharpMap Demo Server",
                    Abstract = "This is an example SharpMap server",
                    Keywords = "SharpMap,WMS"
                };

                ctx.Users = new List <User>();
                ctx.Users.Add(new User {
                    UserName = "******", Password = "******"
                });

                /*add default layer*/
                ctx.Layers = new List <SharpMapServer.Model.WmsLayer>();
                ctx.Layers.Add(new SharpMapServer.Model.WmsLayer()
                {
                    Name = "States", Description = "Demo data over US States", Provider = "Shapefile", DataSource = "states.shp"
                });
                FileStream fs = File.Create(settingsfile);
                serializer.Serialize(fs, ctx);
                fs.Close();
            }

            FileStream settingsStream = File.OpenRead(settingsfile);
            var        settings       = (SharpMapContext)serializer.Deserialize(settingsStream);

            settingsStream.Close();

            WMSServer.m_Capabilities = new SharpMap.Web.Wms.Capabilities.WmsServiceDescription
            {
                Abstract          = settings.Capabilities.Abstract,
                AccessConstraints = settings.Capabilities.AccessConstraints,
                Fees           = settings.Capabilities.Fees,
                Keywords       = settings.Capabilities.Keywords.Split(','),
                LayerLimit     = settings.Capabilities.LayerLimit,
                MaxHeight      = settings.Capabilities.MaxHeight,
                MaxWidth       = settings.Capabilities.MaxWidth,
                OnlineResource = settings.Capabilities.OnlineResource,
                Title          = settings.Capabilities.Title
            };

            WMSServer.m_Map = new SharpMap.Map();
            foreach (var l in settings.Layers)
            {
                switch (l.Provider)
                {
                case "Shapefile":
                    VectorLayer lay = new VectorLayer(l.Name);
                    string      ds  = l.DataSource;
                    if (!Path.IsPathRooted(ds))
                    {
                        ds = Server.MapPath(ds);
                    }

                    lay.DataSource = new SharpMap.Data.Providers.ShapeFile(ds);
                    lay.SRID       = 4326;
                    WMSServer.m_Map.Layers.Add(lay);
                    break;
                }
            }
        }