public override Pushpin RenderCluster(ClusteredPoint cluster)
        {
            var p = new Pushpin();

            MapLayer.SetPosition(p, cluster.Location);
            p.Content = "+";
            p.Tag     = cluster;
            p.ToolTip = new ToolTip()
            {
                Content = string.Format("{0} Clustered Entities", cluster.EntityIds.Count)
            };

            return(p);
        }
Пример #2
0
        public override ColoredPushpin RenderCluster(ClusteredPoint cluster)
        {
            var p = new ColoredPushpin();

            MapLayer.SetPosition(p, cluster.Location);
            p.Content = "+";
            p.Tag     = cluster;
            p.ToolTip = new ToolTip()
            {
                Content = string.Format("{0} Clustered Entities", cluster.EntityIds.Count)
            };

            //ControlTemplate myTemplate = (ControlTemplate)Application.Current.FindResource("PushpinColorTemplate");
            //p.Template = myTemplate;
            //p.ApplyTemplate();

            return(p);
        }
Пример #3
0
        private MapOverlay CreateItemPushpin(object item, ClusteredPoint clusterInfo)
        {
            MapOverlay newo = new MapOverlay();

            var obj = (ItemLocation)item;

            var bpoi = (BuildingPoi)obj.Item;
            var poi = new BuildingPoi { Coordinate = bpoi.Coordinate, Buid = bpoi.Buid};
            var imagePoiLocation = new Image
            {
                Source = new BitmapImage(new Uri("/Assets/MapPin.png", UriKind.Relative)),
                DataContext = poi
            };

            imagePoiLocation.Tap += loadClickedBuilding;
            newo.Content = imagePoiLocation;
            newo.PositionOrigin = new Point(0.5, 0.5);
            newo.GeoCoordinate = bpoi.Coordinate;

            return newo;
        }
Пример #4
0
        private MapOverlay CreateClusteredItemPushpin(ClusteredPoint clusterInfo)
        {
            MapOverlay newo = new MapOverlay();
            var poi = new BuildingPoi { Coordinate = clusterInfo.Location, Buid = "adf" };
            var imagePoiLocation = new Image
            {
                Source = new BitmapImage(new Uri("/Assets/location.png", UriKind.Relative)),
                DataContext = poi
            };

            imagePoiLocation.Tap += loadClickedBuilding;
            newo.Content = imagePoiLocation;
            newo.PositionOrigin = new Point(0.5, 0.5);
            newo.GeoCoordinate = clusterInfo.Location;

            Ellipse el = new Ellipse();
            el.Width = 50;
            el.Height = 50;
            el.Fill = new SolidColorBrush(Colors.Red);
            el.Stroke = new SolidColorBrush(Colors.Black);
            el.HorizontalAlignment = HorizontalAlignment.Center;
            el.VerticalAlignment = VerticalAlignment.Center;

            var grid = new Grid();
            grid.Children.Add(el);
            grid.Children.Add(new TextBlock { Text = clusterInfo.ItemIndices.Count.ToString(), HorizontalAlignment=HorizontalAlignment.Center, VerticalAlignment=VerticalAlignment.Center });
            newo.Content = grid;

            return newo;
        }
Пример #5
0
        public void GetModelTest()
        {
            var firstPoint = new Point {
                PointId = 1, HorizontalDisplacement = 0, VerticalDisplacement = 0
            };
            var secondPoint = new Point {
                PointId = 2, HorizontalDisplacement = 0, VerticalDisplacement = 2
            };
            var thirdPoint = new Point {
                PointId = 3, HorizontalDisplacement = 3, VerticalDisplacement = 3
            };

            var firstModeledPoint = new ClusteredPoint
            {
                PointId = firstPoint.PointId,
                HorizontalDisplacement = firstPoint.HorizontalDisplacement,
                VerticalDisplacement   = firstPoint.VerticalDisplacement,
                ClusterSnapshots       = new List <ClusterSnapshot>
                {
                    new ClusterSnapshot
                    {
                        ClusterId    = 1,
                        ClusterCount = 3
                    },
                    new ClusterSnapshot
                    {
                        ClusterId    = 1,
                        ClusterCount = 2
                    },
                    new ClusterSnapshot
                    {
                        ClusterId    = 1,
                        ClusterCount = 1
                    },
                }
            };

            var secondModeledPoint = new ClusteredPoint
            {
                PointId = secondPoint.PointId,
                HorizontalDisplacement = secondPoint.HorizontalDisplacement,
                VerticalDisplacement   = secondPoint.VerticalDisplacement,
                ClusterSnapshots       = new List <ClusterSnapshot>
                {
                    new ClusterSnapshot
                    {
                        ClusterId    = 2,
                        ClusterCount = 3
                    },
                    new ClusterSnapshot
                    {
                        ClusterId    = 1,
                        ClusterCount = 2
                    },
                    new ClusterSnapshot
                    {
                        ClusterId    = 1,
                        ClusterCount = 1
                    },
                }
            };

            var thirdModeledPoint = new ClusteredPoint
            {
                PointId = thirdPoint.PointId,
                HorizontalDisplacement = thirdPoint.HorizontalDisplacement,
                VerticalDisplacement   = thirdPoint.VerticalDisplacement,
                ClusterSnapshots       = new List <ClusterSnapshot>
                {
                    new ClusterSnapshot
                    {
                        ClusterId    = 3,
                        ClusterCount = 3
                    },
                    new ClusterSnapshot
                    {
                        ClusterId    = 3,
                        ClusterCount = 2
                    },
                    new ClusterSnapshot
                    {
                        ClusterId    = 1,
                        ClusterCount = 1
                    },
                }
            };

            var modeledPoints = new AgglomerativeHierarchicalClusteringService(this._distanceService).GetModel(new List <Point>
            {
                firstPoint, secondPoint, thirdPoint
            });
            var expectedModeledPoints = new List <ClusteredPoint>
            {
                firstModeledPoint, secondModeledPoint, thirdModeledPoint
            };

            Assert.IsTrue(ListComparer.Compare(modeledPoints, expectedModeledPoints));
        }
Пример #6
0
        public void RecordClustersTest()
        {
            var firstPoint = new ClusteredPoint
            {
                PointId = 1,
                HorizontalDisplacement = 2,
                VerticalDisplacement   = 3,
                ClusterSnapshots       = new List <ClusterSnapshot>
                {
                    new ClusterSnapshot
                    {
                        ClusterCount = 2,
                        ClusterId    = 1
                    }
                }
            };
            var secondPoint = new ClusteredPoint
            {
                PointId = 2,
                HorizontalDisplacement = 4,
                VerticalDisplacement   = 5,
                ClusterSnapshots       = new List <ClusterSnapshot>
                {
                    new ClusterSnapshot
                    {
                        ClusterCount = 3,
                        ClusterId    = 2
                    }
                }
            };
            var thirdPoint = new ClusteredPoint
            {
                PointId = 3,
                HorizontalDisplacement = 6,
                VerticalDisplacement   = 7,
                ClusterSnapshots       = new List <ClusterSnapshot>
                {
                    new ClusterSnapshot
                    {
                        ClusterCount = 4,
                        ClusterId    = 1
                    }
                }
            };

            var clusters = new List <Cluster <ClusteredPoint> >
            {
                new Cluster <ClusteredPoint>
                {
                    ClusterId = 1,
                    Points    = new List <ClusteredPoint>
                    {
                        firstPoint, secondPoint
                    }
                },
                new Cluster <ClusteredPoint>
                {
                    ClusterId = 2,
                    Points    = new List <ClusteredPoint>
                    {
                        thirdPoint
                    }
                }
            };

            var actualRecordedClusters = AgglomerativeHierarchicalClusteringService.RecordClusters(clusters);
            var recordedFirstPoint     = firstPoint.GetShallowCopy();
            var recordedSecondPoint    = secondPoint.GetShallowCopy();
            var recordedThirdPoint     = thirdPoint.GetShallowCopy();

            recordedFirstPoint.ClusterSnapshots.Append(new ClusterSnapshot
            {
                ClusterId    = 1,
                ClusterCount = 3
            });

            recordedSecondPoint.ClusterSnapshots.Append(new ClusterSnapshot
            {
                ClusterId    = 2,
                ClusterCount = 3
            });

            recordedThirdPoint.ClusterSnapshots.Append(new ClusterSnapshot
            {
                ClusterId    = 2,
                ClusterCount = 3
            });

            var expectedRecordedClusters = new List <Cluster <ClusteredPoint> >
            {
                new Cluster <ClusteredPoint>
                {
                    ClusterId = 1,
                    Points    = new List <ClusteredPoint>
                    {
                        recordedFirstPoint, recordedSecondPoint
                    }
                },
                new Cluster <ClusteredPoint>
                {
                    ClusterId = 2,
                    Points    = new List <ClusteredPoint>
                    {
                        recordedThirdPoint
                    }
                }
            };

            Assert.IsTrue(ListComparer.Compare(actualRecordedClusters, expectedRecordedClusters));
        }