Esempio n. 1
0
        ////StreamGeometry Approach
        //public Path AsTileUsingStreamGeometry(List<SqlGeometry> geometries, double mapScale, TileInfo region, double tileWidth, double tileHeight, RectangleGeometry area,
        //    Transform viewTransform, sb.BoundingBox totalExtent, TranslateTransform viewTransformForPoints)
        //{
        //    if (geometries == null)
        //        return null;

        //    StreamGeometry geo;

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

        //    if (this.Type.HasFlag(LayerType.Point))
        //    {
        //        geo = SqlSpatialToStreamGeometry.ParseSqlGeometry(geometries, p => viewTransform.Transform(p), this.GeometryPointSymbol);

        //        geo.FillRule = FillRule.Nonzero;

        //        //geo.Transform = viewTransform;
        //    }
        //    else
        //    {
        //        geo = SqlSpatialToStreamGeometry.ParseSqlGeometry(geometries, p => viewTransform.Transform(p));

        //        //geo.Transform = viewTransform;
        //    }

        //    geo.Transform = viewTransformForPoints;

        //    GeometryDrawing drawing = new GeometryDrawing();

        //    Path path = new Path() { Data = geo, Tag = new LayerTag(mapScale) { Tile = region, Layer = this, IsTiled = true }, Stroke = VisualParameters.Stroke, Fill = VisualParameters.Fill, StrokeThickness = VisualParameters.StrokeThickness };
        //    //path.RenderTransform = viewTransform;
        //    this.Element = path;

        //    return path;
        //}

        //private static Func<sb.Point, sb.Point> MapToTileScreen(sb.BoundingBox totalExtent, sb.BoundingBox mapBoundingBoxOfTile, Transform viewTransform)
        //{
        //    var mapShift = mapBoundingBoxOfTile.Center - new sb.Point(totalExtent.TopLeft.X + mapBoundingBoxOfTile.Width / 2.0, totalExtent.TopLeft.Y - mapBoundingBoxOfTile.Height / 2.0);

        //    return p => { return viewTransform.Transform(new Point(p.X - mapShift.X, p.Y - mapShift.Y)).AsPoint(); };
        //}
        private static Func <Point, Point> MapToTileScreenWpf(sb.BoundingBox totalExtent, sb.BoundingBox mapBoundingBoxOfTile, Func <Point, Point> viewTransform)
        {
            //var mapShift = (mapBoundingBoxOfTile.TopLeft - new sb.Point(totalExtent.TopLeft.X + mapBoundingBoxOfTile.Width / 2.0, totalExtent.TopLeft.Y - mapBoundingBoxOfTile.Height / 2.0)).AsWpfPoint();

            //var mapShift = new Point(mapBoundingBoxOfTile.TopLeft.X - totalExtent.TopLeft.X, mapBoundingBoxOfTile.BottomRight.Y - totalExtent.BottomRight.Y);

            return(p => { return viewTransform(new Point(p.X - mapBoundingBoxOfTile.TopLeft.X + totalExtent.TopLeft.X, p.Y - mapBoundingBoxOfTile.BottomRight.Y + totalExtent.BottomRight.Y)); });
        }
Esempio n. 2
0
        public BalancedKdTreeNode(T point, Trees.NodeColor color)
        {
            this.Point = point;

            this.Color = color;

            this.LeftChild  = BalancedKdTree <T> .NilNode;
            this.RightChild = BalancedKdTree <T> .NilNode;

            var pointValue = BalancedKdTree <T> .PointFunc(point);

            this.MinimumBoundingBox = new BoundingBox(pointValue.X, pointValue.Y, pointValue.X, pointValue.Y);
        }
Esempio n. 3
0
        public GeometryLabelPairs GetGeometryLabelPair(double mapScale, sb.BoundingBox mapExtent)
        {
            List <SqlGeometry> geometries; List <string> labels = null;

            if (this.IsLabeled(mapScale))
            {
                var geoLabelPairs = this.DataSource.GetGeometryLabelPairs(mapExtent);

                geometries = geoLabelPairs.Select(i => i.Geometry).ToList();

                labels = geoLabelPairs.Select(i => i.Label).ToList();
            }
            else
            {
                geometries = this.GetGeometries(mapScale, mapExtent);
            }

            return(new GeometryLabelPairs(geometries, labels));
        }
Esempio n. 4
0
        public async Task <List <SqlGeometry> > GetGeometriesAsync(double mapScale, sb.BoundingBox boundingBox)
        {
            List <SqlGeometry> geometries = new List <SqlGeometry>();

            if (this.DataSource is MemoryScaleDependentDataSource <object> )
            {
                geometries = await((MemoryScaleDependentDataSource <object>) this.DataSource).GetGeometriesAsync(mapScale, boundingBox);
            }
            else
            {
                geometries = await this.DataSource.GetGeometriesAsync(boundingBox);
            }

            if (geometries.Count == 0)
            {
                return(null);
            }

            return(geometries);
        }
Esempio n. 5
0
        public List <SqlGeometry> GetGeometries(double mapScale, sb.BoundingBox boundingBox)
        {
            List <SqlGeometry> geometries = new List <SqlGeometry>();

            if (this.DataSource is IScaleDependentDataSource)
            {
                geometries = ((IScaleDependentDataSource)this.DataSource).GetGeometries(mapScale, boundingBox);
            }
            else
            {
                geometries = this.DataSource.GetGeometries(boundingBox);
            }

            if (geometries.Count == 0)
            {
                return(null);
            }

            return(geometries);
        }
Esempio n. 6
0
        //StreamGeometry Approach
        public Path AsShape(List <SqlGeometry> geometries, double mapScale, sb.BoundingBox exactCurrentExtent, double width,
                            double height, TransformGroup viewTransform, TranslateTransform viewTransformForPoints, Func <Point, Point> mapToScreen)
        {
            StreamGeometry geo;

            if (this.Type.HasFlag(LayerType.Point))
            {
                geo = SqlSpatialToStreamGeometry.ParseSqlGeometry(geometries, mapToScreen, this.PointSymbol.GeometryPointSymbol);

                geo.FillRule = FillRule.Nonzero;

                geo.Transform = viewTransformForPoints;
            }
            else
            {
                geo = SqlSpatialToStreamGeometry.ParseSqlGeometry(geometries, p => p);

                geo.Transform = viewTransform;
            }

            //GeometryDrawing drawing = new GeometryDrawing();

            Path path = new Path()
            {
                StrokeDashArray = VisualParameters.DashType,
                Data            = geo,
                Tag             = new LayerTag(-1)
                {
                    Layer = this, IsTiled = false
                },
                Stroke          = VisualParameters.Stroke,
                Fill            = VisualParameters.Fill,
                StrokeThickness = VisualParameters.StrokeThickness
            };

            this.Element = path;

            return(path);
        }
Esempio n. 7
0
        private static Func <sb.Point, sb.Point> MapToTileScreen(sb.BoundingBox totalExtent, sb.BoundingBox mapBoundingBoxOfTile, Transform viewTransform)
        {
            var mapShift = (mapBoundingBoxOfTile.Center - new sb.Point(totalExtent.TopLeft.X + mapBoundingBoxOfTile.Width / 2.0, totalExtent.TopLeft.Y - mapBoundingBoxOfTile.Height / 2.0)).AsWpfPoint();

            return(p => { return viewTransform.Transform(new Point(p.X - mapShift.X, p.Y - mapShift.Y)).AsPoint(); });
        }
Esempio n. 8
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);
        }
Esempio n. 9
0
        //Writeable Bitmap Approach
        //Consider Labeling
        public Path AsTileUsingWriteableBitmap(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 transform = MapToTileScreenWpf(totalExtent, region.WebMercatorExtent, viewTransform);

            var image = new SqlSpatialToWriteableBitmap().ParseSqlGeometry(
                geometries,
                transform,
                (int)tileWidth,
                (int)tileHeight,
                this.VisualParameters.Stroke.AsSolidColor().Value,
                this.VisualParameters.Fill.AsSolidColor().Value);

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

            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(image);

            return(path);
        }
Esempio n. 10
0
        internal MultiPoint(IRI.Ham.SpatialBase.BoundingBox boundingBox, EsriPoint[] points)
        {
            this.boundingBox = boundingBox;

            this.points = points;
        }
Esempio n. 11
0
        //DrawingVisual Approach
        public Path AsTileUsingDrawingVisual(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);
            }

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

            //if (this.VisualParameters.DashStyle != null)
            //{
            //    pen.DashStyle = this.VisualParameters.DashStyle;
            //}
            var pen = this.VisualParameters.GetWpfPen();

            Brush brush = this.VisualParameters.Fill;

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

            var drawingVisual = new SqlSpatialToDrawingVisual().ParseSqlGeometry(geometries, transform, pen, brush, this.VisualParameters.PointSize, this.PointSymbol);

            RenderTargetBitmap image = new RenderTargetBitmap((int)tileWidth, (int)tileHeight, 96, 96, PixelFormats.Pbgra32);

            image.Render(drawingVisual);

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

            image.Freeze();

            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(image);

            return(path);
        }
Esempio n. 12
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);
        }
Esempio n. 13
0
        //Consider Labels
        public Path AsBitmapUsingWriteableBitmap(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);
            }

            var image = new SqlSpatialToWriteableBitmap().ParseSqlGeometry(
                geometries,
                mapToScreen,
                (int)width,
                (int)height,
                this.VisualParameters.Stroke.AsSolidColor().Value,
                this.VisualParameters.Fill.AsSolidColor().Value);

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

            //if (labels != null)
            //{
            //    this.DrawLabel(labels, geometries, image, transform);
            //}

            //BitmapImage bitmapImage = IRI.Jab.Common.Imaging.ImageUtility.AsBitmapImage(image);

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

            this.Element = path;

            path.Fill = new ImageBrush(image);

            return(path);
        }
Esempio n. 14
0
        public Path AsBitmapUsingGdiPlus(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);
            }

            var borderBrush = this.VisualParameters.Stroke.AsGdiBrush();

            var pen = this.VisualParameters.GetGdiPlusPen();

            var image = SqlSpatialToGdiBitmap.ParseSqlGeometry(
                geometries,
                width,
                height,
                mapToScreen,
                pen,
                this.VisualParameters.Fill.AsGdiBrush(),
                this.VisualParameters.PointSize,
                this.PointSymbol);

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

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

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

            image.Dispose();

            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);

            bitmapImage.Freeze();

            return(path);
        }
Esempio n. 15
0
        //DrawingVisual Approach
        public Path AsDrawingVisual(List <SqlGeometry> geometries, List <string> labels, double mapScale, sb.BoundingBox exactCurrentExtent, 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);

            //pen.DashStyle = this.VisualParameters.DashStyle;

            var pen = this.VisualParameters.GetWpfPen();

            Brush brush = this.VisualParameters.Fill;

            DrawingVisual drawingVisual = new SqlSpatialToDrawingVisual().ParseSqlGeometry(geometries, i => mapToScreen(i), pen, brush, this.VisualParameters.PointSize, this.PointSymbol);

            RenderTargetBitmap image = new RenderTargetBitmap((int)width, (int)height, 96, 96, PixelFormats.Pbgra32);

            image.Render(drawingVisual);

            if (this.IsLabeled(mapScale))
            {
                this.DrawLabels(labels, geometries, image, mapToScreen);
            }

            image.Freeze();

            Path path = new Path()
            {
                Data = area,
                Tag  = new LayerTag(mapScale)
                {
                    Layer = this, IsTiled = false
                }
            };

            this.Element = path;

            path.Fill = new ImageBrush(image);

            return(path);
        }
Esempio n. 16
0
        //Gdi+ Approach
        public Path AsTileUsingGdiPlusAsync(List <SqlGeometry> geometries, List <string> labels, double mapScale, TileInfo region, double tileWidth, double tileHeight, RectangleGeometry area, Func <Point, Point> transform, sb.BoundingBox totalExtent)
        {
            if (geometries == null)
            {
                return(null);
            }

            //var pen = this.VisualParameters.Stroke != null ? new System.Drawing.Pen(this.VisualParameters.Stroke.AsGdiBrush(), (int)this.VisualParameters.StrokeThickness) : null;

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

            var pen = this.VisualParameters.GetGdiPlusPen();

            var shiftX = region.WebMercatorExtent.Center.X - totalExtent.TopLeft.X - region.WebMercatorExtent.Width / 2.0;
            var shiftY = region.WebMercatorExtent.Center.Y - totalExtent.TopLeft.Y + region.WebMercatorExtent.Height / 2.0;
            //;

            //var transform = MapToTileScreenWpf(totalExtent, region.MercatorExtent, viewTransform);
            //var mapShift = new Point(region.MercatorExtent.Center.X - totalExtent.TopLeft.X, region.MercatorExtent.Center.Y - totalExtent.BottomRight.Y);
            //var mapShift = (mapBoundingBoxOfTile.Center - new sb.Point(totalExtent.TopLeft.X + mapBoundingBoxOfTile.Width / 2.0, totalExtent.TopLeft.Y - mapBoundingBoxOfTile.Height / 2.0)).AsWpfPoint();


            var image = SqlSpatialToGdiBitmap.ParseSqlGeometry(
                geometries,
                tileWidth,
                tileHeight,
                //transform,
                p => transform(new Point(p.X - shiftX, p.Y - shiftY)),
                pen,
                this.VisualParameters.Fill.AsGdiBrush(),
                this.VisualParameters.PointSize,
                this.PointSymbol);

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

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

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

            image.Dispose();

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

            this.Element = path;

            path.Fill = new ImageBrush(bitmapImage);

            return(path);
        }
Esempio n. 17
0
        public MultiPoint(EsriPoint[] points)
        {
            this.boundingBox = IRI.Ham.SpatialBase.BoundingBox.CalculateBoundingBox(points.Cast <IRI.Ham.SpatialBase.IPoint>());

            this.points = points;
        }