Exemple #1
0
    private List <Bitmap> GetTileImages(bool overlay)
    {
        List <Bitmap> tileImages = new List <Bitmap>();

        StringCollection visibleTiles = _appState.VisibleTiles[_appState.MapTab];
        double           pixelSize    = _appState.Extent.Width / _width;
        int level = Convert.ToInt32(Math.Log(Constants.BasePixelSize / pixelSize, 2));

        if (visibleTiles.Count > 0)
        {
            Configuration.MapTabRow mapTab = AppContext.GetConfiguration().MapTab.FindByMapTabID(_appState.MapTab);

            foreach (Configuration.MapTabTileGroupRow mapTabTileGroup in mapTab.GetMapTabTileGroupRows().Where(o => visibleTiles.Contains(o.TileGroupID)))
            {
                double opacity = mapTabTileGroup.IsOpacityNull() ? 1 : mapTabTileGroup.Opacity;

                foreach (Configuration.TileLayerRow tileLayer in mapTabTileGroup.TileGroupRow.GetTileLayerRows())
                {
                    bool isOverlay = !tileLayer.IsOverlayNull() && tileLayer.Overlay == 1;

                    if (isOverlay == overlay)
                    {
                        Bitmap tileImage = TileAggregator.GetImage(tileLayer.URL, _appState.Extent, level, opacity);
                        tileImages.Add(tileImage);
                    }
                }
            }
        }

        return(tileImages);
    }
Exemple #2
0
    private void CreatePdfTiles(PdfContentByte content, Configuration.PrintTemplateContentRow row, bool overlay)
    {
        int pixelWidth  = Convert.ToInt32(row.Width * PixelsPerInch);
        int pixelHeight = Convert.ToInt32(row.Height * PixelsPerInch);

        float originX = Convert.ToSingle(row.OriginX) * PointsPerInch;
        float originY = Convert.ToSingle(row.OriginY) * PointsPerInch;
        float width   = Convert.ToSingle(row.Width) * PointsPerInch;
        float height  = Convert.ToSingle(row.Height) * PointsPerInch;

        StringCollection visibleTiles = _appState.VisibleTiles[_appState.MapTab];
        int level = Convert.ToInt32(Math.Log(Constants.BasePixelSize / _pixelSize, 2));

        if (visibleTiles.Count > 0)
        {
            Configuration.MapTabRow mapTab = AppContext.GetConfiguration().MapTab.FindByMapTabID(_appState.MapTab);

            foreach (Configuration.MapTabTileGroupRow mapTabTileGroup in mapTab.GetMapTabTileGroupRows().Where(o => visibleTiles.Contains(o.TileGroupID)))
            {
                double opacity = mapTabTileGroup.IsOpacityNull() ? 1 : mapTabTileGroup.Opacity;

                foreach (Configuration.TileLayerRow tileLayer in mapTabTileGroup.TileGroupRow.GetTileLayerRows())
                {
                    bool isOverlay = !tileLayer.IsOverlayNull() && tileLayer.Overlay == 1;

                    if (isOverlay == overlay)
                    {
                        byte[] tileImage = TileAggregator.GetImageBytes(tileLayer.URL, _appState.Extent, level, opacity);

                        iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(tileImage);
                        image.SetAbsolutePosition(originX, originY);
                        image.ScaleAbsolute(width, height);

                        content.AddImage(image);
                    }
                }
            }
        }
    }