示例#1
0
        /// <summary> Reads the earthquakes from a csv file and adds them to a clusterer. The clusterer then groups
        /// them to clusters. </summary>
        /// <returns> Documentation in progress... </returns>
        public static TileBasedPointClusterer <Post> ReadCSVFile()
        {
            var clusterer = new TileBasedPointClusterer <Post>(MapView.LogicalSize, 0, 19);
            var filePath  = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Resources\ClusterData") + @"\wikilocations.csv";

            using (var reader = new CsvFileReader(filePath, (char)0x09))
            {
                var row = new CsvRow();
                while (reader.ReadRow(row))
                {
                    if (row.Count < 3)
                    {
                        continue;
                    }

                    double x, y;
                    bool   parsed = Double.TryParse(row[2], NumberStyles.Float, CultureInfo.InvariantCulture, out x);
                    x      = parsed ? x : Double.NaN;
                    parsed = Double.TryParse(row[1], NumberStyles.Float, CultureInfo.InvariantCulture, out y);
                    y      = parsed ? y : Double.NaN;
                    var post = new Post {
                        Title = row[0], Location = new Point(x, y)
                    };
                    post.TransformedLocation = GeoTransform.WGSToPtvMercator(post.Location);
                    clusterer.AddPoint(post.TransformedLocation.X, post.TransformedLocation.Y, 1, post);
                }
            }

            #region doc:clusterer.Cluster method call
            clusterer.Cluster();
            return(clusterer);

            #endregion //doc:clusterer.Cluster method call
        }
示例#2
0
        /// <summary> Initializes a new instance of the <see cref="LocalizedWikiDemo"/> class. Reads in the earthquakes
        /// from a file and displays them on the map. </summary>
        /// <param name="mapView"> The map to be used for display. </param>
        /// <param name="clusterer"> The clusterer containing the clusters. </param>
        public LocalizedWikiDemo(MapView mapView, TileBasedPointClusterer <Post> clusterer)
            : base(mapView)
        {
            adjustTransform = new ScaleTransform();
            this.clusterer  = clusterer;

            logicalScaleFactor = 0.65;
            UpdateBalls();
        }