Exemple #1
0
        public void PaintTree(GeoSquareData node)
        {
            var rec = new Rectangle
            {
                Height = node.Height,
                Width  = node.Width
            };
            var varyingColorBrush = new SolidColorBrush(Color.FromArgb(255, 255, 0, 0));

            rec.StrokeThickness = 0.7;
            rec.Stroke          = varyingColorBrush;
            rec.Fill            = new SolidColorBrush(Colors.Transparent);
            Canvas.SetTop(rec, node.Y);
            Canvas.SetLeft(rec, node.X);
            mapCanvas.Children.Add(rec);
        }
Exemple #2
0
        public void BuildTreeFromDot(GeoSquareData currentNode, SetCollection <GeoSquareData> geoRepo, Dot dot, int maxLevel = 5)
        {
            geoRepo.Add(currentNode);
            if (currentNode.level == maxLevel)
            {
                return;
            }

            if (currentNode.level % 2 == 0)
            {
                if (dot.position.Y >= currentNode.center.Y)
                {
                    var Higherleaf = new GeoSquareData
                    {
                        level      = currentNode.level + 1,
                        Id         = currentNode.Id << 1 | 1,
                            center = new Vector(currentNode.center.X, currentNode.center.Y + (currentNode.Height / 4)),
                            Height = currentNode.Height / 2,
                            Width  = currentNode.Width
                    };
                    dot.geoId = Higherleaf.Id;
                    BuildTreeFromDot(Higherleaf, geoRepo, dot, maxLevel);
                }
                else
                {
                    var Lowerleaf = new GeoSquareData
                    {
                        level      = currentNode.level + 1,
                        Id         = currentNode.Id << 1 | 0,
                            center = new Vector(currentNode.center.X, currentNode.center.Y - (currentNode.Height / 4)),
                            Height = currentNode.Height / 2,
                            Width  = currentNode.Width
                    };
                    dot.geoId = Lowerleaf.Id;
                    BuildTreeFromDot(Lowerleaf, geoRepo, dot, maxLevel);
                }
            }
            else
            {
                if (dot.position.X >= currentNode.center.X)
                {
                    var Higherleaf = new GeoSquareData
                    {
                        level      = currentNode.level + 1,
                        Id         = currentNode.Id << 1 | 1,
                            center = new Vector(currentNode.center.X + (currentNode.Width / 4), currentNode.center.Y),
                            Height = currentNode.Height,
                            Width  = currentNode.Width / 2
                    };
                    dot.geoId = Higherleaf.Id;
                    BuildTreeFromDot(Higherleaf, geoRepo, dot, maxLevel);
                }
                else
                {
                    var Lowerleaf = new GeoSquareData
                    {
                        level      = currentNode.level + 1,
                        Id         = currentNode.Id << 1 | 0,
                            center = new Vector(currentNode.center.X - (currentNode.Width / 4), currentNode.center.Y),
                            Height = currentNode.Height,
                            Width  = currentNode.Width / 2
                    };
                    dot.geoId = Lowerleaf.Id;
                    BuildTreeFromDot(Lowerleaf, geoRepo, dot, maxLevel);
                }
            }
        }