Exemplo n.º 1
0
        public Path AsBitmapUsingOpenTK(List <SqlGeometry> geometries, List <string> labels, double mapScale, sb.BoundingBox boundingBox, double width, double height, Func <Point, Point> mapToScreen, RectangleGeometry area)
        {
            if (geometries == null)
            {
                return(null);
            }

            //Pen pen = new Pen(this.VisualParameters.Stroke, this.VisualParameters.StrokeThickness);
            var pen = this.VisualParameters.GetGdiPlusPen();

            Brush brush = this.VisualParameters.Fill;

            //var color = ((SolidColorBrush)this.VisualParameters.Stroke)?.Color ?? ((SolidColorBrush)this.VisualParameters.Fill).Color;

            //var image = new SqlSpatialToOpenTKBitmap().ParseSqlGeometry(
            //    geometries,
            //    width,
            //    height,
            //    mapToScreen,
            //    new System.Drawing.Pen(System.Drawing.Color.FromArgb(color.A, color.R, color.G, color.B), (int)this.VisualParameters.StrokeThickness),
            //    System.Drawing.Brushes.SkyBlue);

            var image = new SqlSpatialToOpenTKBitmap().ParseSqlGeometry(
                geometries,
                width,
                height,
                mapToScreen,
                pen,
                System.Drawing.Brushes.SkyBlue);

            if (image == null)
            {
                return(null);
            }

            if (labels != null)
            {
                SqlSpatialToGdiBitmap.DrawLabels(labels, geometries, image, mapToScreen, Labels);
            }

            BitmapImage bitmapImage = IRI.Jab.Common.Helpers.ImageUtility.AsBitmapImage(image, System.Drawing.Imaging.ImageFormat.Png);

            //Try #3
            Path path = new Path()
            {
                Data = area,
                Tag  = new Model.LayerTag(mapScale)
                {
                    Layer = this, Tile = null, IsDrawn = true, IsNew = true
                }
            };

            this.Element = path;

            path.Fill = new ImageBrush(bitmapImage);


            return(path);
        }
Exemplo n.º 2
0
        //OpenTK Approach
        public Path AsTileUsinOpenTK(List <SqlGeometry> geometries, List <string> labels, double mapScale, TileInfo region, double tileWidth, double tileHeight, RectangleGeometry area, Func <Point, Point> viewTransform, sb.BoundingBox totalExtent)
        {
            if (geometries == null)
            {
                return(null);
            }

            //Brush brush = this.VisualParameters.Fill;

            //var color = ((SolidColorBrush)this.VisualParameters.Stroke)?.Color ?? ((SolidColorBrush)this.VisualParameters.Fill).Color;

            //var pen = new System.Drawing.Pen(System.Drawing.Color.FromArgb(color.A, color.R, color.G, color.B), (int)this.VisualParameters.StrokeThickness);

            //if (this.VisualParameters.DashStyle != null)
            //{
            //    pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
            //}
            var pen = this.VisualParameters.GetGdiPlusPen();

            var brush = this.VisualParameters.GetGdiPlusFillBrush();

            var transform = MapToTileScreenWpf(totalExtent, region.WebMercatorExtent, viewTransform);

            var image = new SqlSpatialToOpenTKBitmap().ParseSqlGeometry(
                geometries,
                tileWidth,
                tileHeight,
                transform,
                pen,
                brush);

            if (image == null)
            {
                return(null);
            }

            if (labels != null)
            {
                SqlSpatialToGdiBitmap.DrawLabels(labels, geometries, image, transform, this.Labels);
            }

            BitmapImage bitmapImage = IRI.Jab.Common.Helpers.ImageUtility.AsBitmapImage(image, System.Drawing.Imaging.ImageFormat.Png);

            Path path = new Path()
            {
                Data = area,
                Tag  = new LayerTag(mapScale)
                {
                    Layer = this, IsTiled = true, Tile = region, IsDrawn = true, IsNew = true
                }
            };

            this.Element = path;

            path.Fill = new ImageBrush(bitmapImage);

            return(path);
        }