Example #1
0
    private void CreatePdfOverviewMap(PdfContentByte content, Configuration.PrintTemplateContentRow row)
    {
        AppState appState = new AppState();

        appState.Application = _appState.Application;
        Configuration.ApplicationRow application = AppContext.GetConfiguration().Application.First(o => o.ApplicationID == appState.Application);

        appState.MapTab = application.OverviewMapID;
        appState.Extent = application.GetFullExtentEnvelope();

        int pixelWidth  = Convert.ToInt32(row.Width * PixelsPerInch);
        int pixelHeight = Convert.ToInt32(row.Height * PixelsPerInch);

        MapMaker     mapMaker     = new MapMaker(appState, pixelWidth, pixelHeight, 2);
        MapImageData mapImageData = mapMaker.GetImage();

        System.Drawing.Bitmap bitmap      = new System.Drawing.Bitmap(new MemoryStream(mapImageData.Image));
        Transformation        trans       = new AffineTransformation(pixelWidth * 2, pixelHeight * 2, appState.Extent);
        MapGraphics           mapGraphics = MapGraphics.FromImage(bitmap, trans);

        double   minSize = (trans.Transform(new Coordinate(1, 0)).X - trans.Transform(new Coordinate(0, 0)).X) * 12;
        Envelope extent  = new Envelope(new Coordinate(_appState.Extent.MinX, _appState.Extent.MinY), new Coordinate(_appState.Extent.MaxX, _appState.Extent.MaxY));

        if (extent.Width < minSize)
        {
            extent = new Envelope(new Coordinate(extent.Centre.X - minSize * 0.5, extent.MinY), new Coordinate(extent.Centre.X + minSize * 0.5, extent.MaxY));
        }

        if (extent.Height < minSize)
        {
            extent = new Envelope(new Coordinate(extent.MinX, extent.Centre.Y - minSize * 0.5), new Coordinate(extent.MaxX, extent.Centre.Y + minSize * 0.5));
        }

        System.Drawing.Brush brush = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(64, System.Drawing.Color.Red));
        System.Drawing.Pen   pen   = new System.Drawing.Pen(System.Drawing.Color.Red, 4);

        mapGraphics.FillEnvelope(brush, extent);
        mapGraphics.DrawEnvelope(pen, extent);

        MemoryStream stream = new MemoryStream();

        bitmap.Save(stream, mapImageData.Type == CommonImageType.Png ? System.Drawing.Imaging.ImageFormat.Png : System.Drawing.Imaging.ImageFormat.Jpeg);
        byte[] mapImage = stream.ToArray();

        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;

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

        content.AddImage(image);

        CreatePdfBox(content, row, false);
    }
Example #2
0
    private void MakeOverviewImage()
    {
        AppState appState = new AppState();

        appState.Application = Request.Form["application"];
        Configuration.ApplicationRow application = Configuration.Application.First(o => o.ApplicationID == appState.Application);

        appState.MapTab = application.OverviewMapID;
        appState.Extent = application.GetFullExtentEnvelope();

        int width  = Convert.ToInt32(Math.Round(Convert.ToDouble(Request.Form["width"])));
        int height = Convert.ToInt32(Math.Round(Convert.ToDouble(Request.Form["height"])));

        ReturnJson(GetImageUrl(appState, width, height));
    }
Example #3
0
        public ApplicationData(Configuration config, Configuration.ApplicationRow app)
        {
            ApplicationID = app.ApplicationID;
            DisplayName   = app.DisplayName;

            DefaultMapTab = (!app.IsDefaultMapTabNull() ? app.DefaultMapTab : "");
            FullExtent    = app.GetFullExtentEnvelope().ToArray();

            MapTabs = new List <MapTabData>(config.ApplicationMapTab.Count);
            foreach (Configuration.ApplicationMapTabRow mapTab in config.ApplicationMapTab.Where(e => e.ApplicationID == ApplicationID))
            {
                var configMapTab = config.MapTab.FirstOrDefault(t => t.MapTabID == mapTab.MapTabID);
                if (configMapTab != null)
                {
                    MapTabs.Add(new MapTabData(configMapTab));
                }
            }
        }