Beispiel #1
0
        private Bitmap GetImage(double mapWestCorner, double mapNorthCorner, string path)
        {
            Tile tile = GetTile(mapWestCorner, mapNorthCorner);//GetTile(WestCorner, northCorner);

            MapServerParameters.BBOXN = tile.northCorner.ToString();
            MapServerParameters.BBOXW = tile.westCorner.ToString();
            string connectionString = _url + "-" + tile.column.ToString() + "-" + tile.row.ToString();
            Bitmap image            = ConnectToMapServer.ConnectToWMTS(connectionString, _username, _password);

            int    outputImageWidth  = image.Width * 4 + 1;
            int    outputImageHeight = image.Height * 4 + 1;
            Bitmap outputImage       = new Bitmap(outputImageWidth, outputImageHeight, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

            using (Graphics graphics = Graphics.FromImage(outputImage))
            {
                graphics.FillRectangle(Brushes.White, 0, 0, outputImage.Width, outputImage.Height);
                for (int j = 0; j < 4; j++)
                {
                    for (int i = 0; i < 4; i++)
                    {
                        connectionString = _url + "-" + (tile.column + j).ToString() + "-" + (tile.row + i).ToString();
                        image            = ConnectToMapServer.ConnectToWMTS(connectionString, _username, _password);
                        image.Save(path + "part" + i.ToString() + "-" + j.ToString() + ".png");
                        graphics.DrawImage(image, new Rectangle(new Point(j * (image.Width), i * (image.Height)), image.Size),
                                           new Rectangle(new Point(), image.Size), GraphicsUnit.Pixel);
                    }
                }
            }
            _tile = tile;
            return(outputImage);
        }
        public void Apply(string intermediatePath)
        {
            //tergetURL = "http://secure.futureclimateinfo.com/api/wms?request=GetMap&BBOX=314100,543800,314600,544300&SRS=EPSG:27700&WIDTH=1056&HEIGHT=1056&LAYERS=nls-sixinch&STYLES=&FORMAT=image/png";
            //tergetURL = "http://secure.futureclimateinfo.com/api/wms?SERVICE=WMS&VERSION=1.1.1&request=GetMap&BBOX=314100,543800,314600,544300&SRS=EPSG:27700&WIDTH=1056&HEIGHT=1056&LAYERS=nls-sixinch&STYLES=&FORMAT=image/pnG";
            //tergetURL = "http://secure.futureclimateinfo.com/api/wms?request=GetMap&BBOX=589400,194000,589900,194500&SRS=EPSG:27700&WIDTH=1056&HEIGHT=1056&LAYERS=nls-sixinch&STYLES=&FORMAT=image/png";
            //tergetURL = "http://secure.futureclimateinfo.com/api/wms?request=GetMap&BBOX=589400,194000,590400,195000&SRS=EPSG:27700&WIDTH=947&HEIGHT=947&LAYERS=nls-sixinch&STYLES=&FORMAT=image/pnG";
            //MapServerParameters.targetURL = "http://secure.futureclimateinfo.com/api/wms?&&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&BBOX=597528,209822,598528,210822&SRS=EPSG:27700&WIDTH=1500&HEIGHT=1500&LAYERS=nls-sixinch:&STYLES=&FORMAT=image/png&DPI=96&MAP_RESOLUTION=96&FORMAT_OPTIONS=dpi:96&TRANSP...
            Bitmap SourceImage = ConnectToMapServer.ConnectToWMS(MapServerParameters.targetURL);

            SourceImage.Save(intermediatePath + StraboParameters.sourceMapFileName);
            ColorHistogram ch = new ColorHistogram();

            if (!ch.CheckImageColors(SourceImage, 2))
            {
                Exception e = new Exception("The returned image is invalid, it has less than two colors.");
                Log.WriteLine("The returned image is invalid, it has less than two colors.");
                throw e;
            }
        }