Beispiel #1
0
        public TileWorker(EmsgGisReportParameter emsgGisReportParameter, TileDefinition tile, int dpi, IGISReportService gISReportService, HttpContext current, bool isPreview)
        {
            this.dpi = dpi;

            this.tile = tile;
            this.emsgGisReportParameter = emsgGisReportParameter;
            this.gISReportService       = gISReportService;
            this.current   = current;
            this.exception = null;
            this.isPreview = isPreview;
        }
Beispiel #2
0
        private void AddTileToBitmap(Bitmap map, List <Stream> tileStreamList, ReportDefintion reportDefinition, TileDefinition tile, List <TileDefinition> tiles)
        {
            int x = tiles.Where(t => (t.col < tile.col) && (t.row == tile.row)).Sum(t => t.TileWidth);
            int y = tiles.Where(t => (t.row > tile.row) && (t.col == tile.col)).Sum(t => t.TileHeight);

            foreach (Stream tileStream in tileStreamList)
            {
                using (Graphics graphics = Graphics.FromImage(map))
                {
                    graphics.SmoothingMode = SmoothingMode.HighQuality;
                    Bitmap temp = new Bitmap(tileStream);
                    //graphics.DrawImage(temp, tilePosition.xPos, tilePosition.yPos, map.Width / reportDefinition.numberOfTiles, map.Height / reportDefinition.numberOfTiles);
                    graphics.DrawImage(temp, x, y, tile.TileWidth, tile.TileHeight);
                    temp.Dispose();
                    tileStream.Close();
                    tileStream.Dispose();
                }
            }
        }
Beispiel #3
0
        public List <Stream> PrepareAndSendWMSRequests(EmsgGisReportParameter emsgGisReportParameter, TileDefinition tile, int dpi, bool isPreview)
        {
            List <Stream>        responseStreamList = new List <Stream>();
            List <Thread>        threads            = new List <Thread>();
            List <RequestWorker> workers            = new List <RequestWorker>();

            #region request background tile
            if (!string.IsNullOrEmpty(emsgGisReportParameter.BackgroundLayers))
            {
                WMSParameter wmsBackrParameter = new WMSParameter(LAYERS: emsgGisReportParameter.BackgroundLayers,
                                                                  BBOX: tile.ExtentToString(),
                                                                  HEIGHT: tile.TileHeight.ToString(),
                                                                  WIDTH: tile.TileWidth.ToString(),
                                                                  FORMAT: isPreview ? "jpeg" : "png24");
                //HttpResponseObject tileResponseBackground = createWMSRequest.WMSRequest(WMSRequestType.BackgroundLayer, wmsBackrParameter);
                RequestWorker worker = new RequestWorker(0, wmsBackrParameter, this.createWMSRequest, HttpContext.Current, WMSRequestType.BackgroundLayer);
                Thread        thread = new Thread(new ThreadStart(worker.Run));
                thread.Start();
                threads.Add(thread);
                workers.Add(worker);
                //if (ValidateResponse(tileResponseBackground))
                //    responseStreamList.Add(tileResponseBackground.responseStream);
            }
            else
            {
                WMSParameter wmsAVBackgroundParameter = new WMSParameter(LAYERS: emsgGisReportParameter.LayersAVBackground,
                                                                         BBOX: tile.ExtentToString(),
                                                                         HEIGHT: tile.TileHeight.ToString(),
                                                                         WIDTH: tile.TileWidth.ToString(),
                                                                         FORMAT: "image/png");

                //HttpResponseObject tileResponseAVBackground = createWMSRequest.WMSRequest(WMSRequestType.AVCLayer, wmsAVBackgroundParameter);
                RequestWorker worker = new RequestWorker(0, wmsAVBackgroundParameter, this.createWMSRequest, HttpContext.Current, WMSRequestType.AVCLayer);
                Thread        thread = new Thread(new ThreadStart(worker.Run));
                thread.Start();
                threads.Add(thread);
                workers.Add(worker);
                //if(ValidateResponse(tileResponseAVBackground))
                //    responseStreamList.Add(tileResponseAVBackground.responseStream);
            }
            #endregion



            #region request AV tile
            if (emsgGisReportParameter.LayersAV != null)
            {
                var reportDefinition = new ReportDefintion(dpi);

                bool containsHausnummernLayer = false;

                var avLayer = emsgGisReportParameter.LayersAV.Split(',').ToList();

                containsHausnummernLayer = avLayer.Remove(new ServerConfigurationProvider().AvUeberlagerndLayers);

                //the Layer "Hausnummer" aka "ch.bfs.gebaeude_wohnungs_register-label" this layer only contains labels Because we request high resolution images this labels become unreadable small so this layer is requested with "low dpi" and then resized
                #region request Hausnummer tile
                if (containsHausnummernLayer)
                {
                    int reducedTileHeight = (int)Math.Ceiling((tile.TileHeight / reportDefinition.dpi * 120d));
                    int reducedTileWidth  = (int)Math.Ceiling((tile.TileWidth / reportDefinition.dpi * 120d));

                    WMSParameter wmsAVHNParameter = new WMSParameter(LAYERS: new ServerConfigurationProvider().AvUeberlagerndLayers,
                                                                     BBOX: tile.ExtentToString(),
                                                                     HEIGHT: reducedTileHeight.ToString(),
                                                                     WIDTH: reducedTileWidth.ToString());

                    //HttpResponseObject tileResponseAVHN = createWMSRequest.WMSRequest(WMSRequestType.AVLayer, wmsAVHNParameter);
                    RequestWorker worker = new RequestWorker(1, wmsAVHNParameter, this.createWMSRequest, HttpContext.Current, WMSRequestType.AVLayer);
                    Thread        thread = new Thread(new ThreadStart(worker.Run));
                    thread.Start();
                    threads.Add(thread);
                    workers.Add(worker);
                    //if (ValidateResponse(tileResponseAVHN))
                    //    responseStreamList.Add(resizeBitmap(tileResponseAVHN.responseStream, tile.TileHeight, tile.TileWidth));
                }


                string avLayerToDownload = string.Join(",", avLayer);

                WMSParameter wmsAVParameter = new WMSParameter(LAYERS: avLayerToDownload,
                                                               BBOX: tile.ExtentToString(),
                                                               HEIGHT: tile.TileHeight.ToString(),
                                                               WIDTH: tile.TileWidth.ToString());

                //HttpResponseObject tileResponseAV = createWMSRequest.WMSRequest(WMSRequestType.AVLayer, wmsAVParameter);
                RequestWorker avworker = new RequestWorker(2, wmsAVParameter, this.createWMSRequest, HttpContext.Current, WMSRequestType.AVLayer);
                Thread        avthread = new Thread(new ThreadStart(avworker.Run));
                avthread.Start();
                threads.Add(avthread);
                workers.Add(avworker);
                //if (ValidateResponse(tileResponseAV))
                //    responseStreamList.Add(resizeBitmap(tileResponseAV.responseStream, tile.TileHeight, tile.TileWidth));



                #endregion request Hausnummer tile
            }
            #endregion

            #region request EMSG feature tile
            if (emsgGisReportParameter.Layers != null)
            {
                var emsgLayers = emsgGisReportParameter.Layers.Split(',').ToList();
                emsgLayers.Reverse();
                string emsgLayersToDownload = string.Join(",", emsgLayers);

                WMSRestParameter wmsParameter = new WMSRestParameter(emsgLayersToDownload,
                                                                     tile.ExtentToString(),
                                                                     tile.TileSizeToString(),
                                                                     layerdefs: emsgGisReportParameter.LayerDefs,
                                                                     dpi: dpi.ToString());

                //HttpResponseObject tileResponseEMSGFeatures = createWMSRequest.WMSRequest(WMSRequestType.OverlayEMSGLayer, wmsParameter);
                RequestWorker worker = new RequestWorker(3, wmsParameter, this.createWMSRequest, HttpContext.Current, WMSRequestType.OverlayEMSGLayer);
                Thread        thread = new Thread(new ThreadStart(worker.Run));
                thread.Start();
                threads.Add(thread);
                workers.Add(worker);

                //if (ValidateResponse(tileResponseEMSGFeatures))
                //    responseStreamList.Add(tileResponseEMSGFeatures.responseStream);
            }
            #endregion


            foreach (Thread thread in threads)
            {
                thread.Join();
            }
            workers = workers.OrderBy(w => w.order).ToList();
            foreach (RequestWorker worker in workers)
            {
                if (worker.exception != null)
                {
                    throw worker.exception;
                }
                if (ValidateResponse(worker.response))
                {
                    responseStreamList.Add(worker.response.responseStream);
                }
            }


            return(responseStreamList);
        }