public ActionResult ClusterData(int zoom) { MongoService mongoService = new MongoService(); var data = mongoService.GetAllLocations(); var zoomLevel = GetZoomLevel(zoom); var radius = GetClusterRadius(zoom); var clusters = new List <PokemonLocation>(); foreach (var location in data) { if (!mongoService.IsClusterWithinDistance(location.Location, radius, zoomLevel)) { mongoService.AddCluster(new Cluster() { Location = location.Location, ZoomLevel = zoomLevel }); } } foreach (var location in data) { var nearestCluster = mongoService.FindNearestCluster(location.Location, radius, zoomLevel); if (zoomLevel == ZoomLevel.OneThroughFive) { location.FirstClusterId = nearestCluster.Id; } if (zoomLevel == ZoomLevel.SixThroughSeven) { location.SecondClusterId = nearestCluster.Id; } if (zoomLevel == ZoomLevel.EightThroughTen) { location.ThirdClusterId = nearestCluster.Id; } if (zoomLevel == ZoomLevel.ElevenThroughThirteen) { location.FourthClusterId = nearestCluster.Id; } mongoService.UpdateInstances(location); } return(View()); }
//http://localhost:53822/List?bottomLeftLongitude=43.14225085508007&bottomLeftLatitude=-77.56777719608152&topRightLongitude=43.161036088374466&topRightLatitude=-77.60640100589598 public ActionResult Index(double bottomLeftLongitude = 0.0, double bottomLeftLatitude = 0.0, double topRightLongitude = 0.0, double topRightLatitude = 0.0) { var mongoService = new MongoService(); var pokemon = new List <PokemonLocation>(); if (bottomLeftLongitude > 0.0) { pokemon = mongoService.GetFilteredLocations(bottomLeftLongitude, bottomLeftLatitude, topRightLongitude, topRightLatitude); } else { pokemon = mongoService.GetAllLocations(); } var model = new PokemonListViewModel { Data = pokemon }; return(View(model)); }