Exemplo n.º 1
0
        private async Task <List <Coordinate> > Bootstrap()
        {
            // Get all unknown spawnpoints within geofence areas
            var list = new List <Coordinate>();

            foreach (var geofence in Geofences)
            {
                var fence = Geofence.FromPolygon(geofence);
                var bbox  = new BoundingBox
                {
                    MinimumLatitude  = geofence.Min(x => x.Latitude),
                    MaximumLatitude  = geofence.Max(x => x.Latitude),
                    MinimumLongitude = geofence.Min(x => x.Longitude),
                    MaximumLongitude = geofence.Max(x => x.Longitude),
                };
                var spawnpoints = await _spawnpointRepository.GetAllAsync(
                    bbox.MinimumLatitude,
                    bbox.MinimumLongitude,
                    bbox.MaximumLatitude,
                    bbox.MaximumLongitude,
                    true
                    ).ConfigureAwait(false);

                var spawnCoords = spawnpoints.Select(x => new Coordinate(x.Latitude, x.Longitude));
                list.AddRange(spawnCoords);
            }
            return(list);
        }
        public async Task <List <Coordinate> > GenerateOptimizedRoute(Geofence geofence, double circleSize = 70)
        {
            // remove unused warn
            if (circleSize == (double)70) // default..
            {
                //notting...
            }
            var polygon = geofence.Feature.Geometry.Coordinates;
            //var line = geometryFactory.CreateLineString(polygon);
            var bboxCoords = geofence.BBox.Coordinates;
            var minLat     = bboxCoords.Min(x => x.X);
            var minLon     = bboxCoords.Min(x => x.Y);
            var maxLat     = bboxCoords.Max(x => x.X);
            var maxLon     = bboxCoords.Max(x => x.Y);
            var bbox       = new BoundingBox
            {
                MinimumLatitude  = minLat,
                MinimumLongitude = minLon,
                MaximumLatitude  = maxLat,
                MaximumLongitude = maxLon,
            };
            var spawnpoints = (await _spawnpointsRepository.GetAllAsync().ConfigureAwait(false)).ToList();
            var pokestops   = await _pokestopRepository.GetAllAsync(bbox.MinimumLatitude, bbox.MinimumLongitude, bbox.MaximumLatitude, bbox.MaximumLongitude).ConfigureAwait(false);

            var gyms = await _gymRepository.GetAllAsync(bbox.MinimumLatitude, bbox.MinimumLongitude, bbox.MaximumLatitude, bbox.MaximumLongitude).ConfigureAwait(false);

            var cells = await _cellRepository.GetAllAsync(bbox.MinimumLatitude, bbox.MinimumLongitude, bbox.MaximumLatitude, bbox.MaximumLongitude).ConfigureAwait(false);

            var list = new List <Coordinate>();

            spawnpoints.ForEach(x => list.Add(new Coordinate(x.Latitude, x.Longitude)));
            pokestops.ForEach(x => list.Add(new Coordinate(x.Latitude, x.Longitude)));
            gyms.ForEach(x => list.Add(new Coordinate(x.Latitude, x.Longitude)));
            //cells.ForEach(x => list.Add(new Coordinate(x.Latitude, x.Longitude)));
            var s2cells = GetS2Cells(bbox);

            list.AddRange(s2cells);
            // TODO: Filter if within geofence area
            return(list);
        }