예제 #1
0
        /// <summary>
        ///     Updates a map with the latest ground / air data
        /// </summary>
        /// <param name="map">The map to update</param>
        /// <returns></returns>
        public async Task UpdateMapData(IMap map)
        {
            if (!IsSignedIn)
            {
                return;
            }

            RectLatLng area = map.GetViewArea();
            await _messagesService.AddMessageAsync($"Map area {area.Top}, {area.Bottom}, {area.Left}, {area.Right}");

            AAFeatureCollection mapData = await _aaClient.GetMapData(area);

            // build the filter list
            mapData.GetFilters();

            // this ensures the user sees the results before its saved
            _missionPlanner.SaveSetting("AAWings.Filters", JsonConvert.SerializeObject(FilteredOut));

            await _messagesService.AddMessageAsync($"Map area Loaded {area.Top}, {area.Bottom}, {area.Left}, {area.Right}");

            // add all items to cache
            mapData.Features.ForEach(feature => cache[feature.Id] = feature);

            // Only get the features that are enabled by default, and have not been filtered out
            IEnumerable <Feature> features = mapData.Features.Where(feature => feature.IsEnabledByDefault() && feature.IsFilterOutItem(FilteredOut)).ToList();

            ProcessFeatures(map, features);
        }
예제 #2
0
        /// <summary>
        ///     Updates a map with the latest ground / air data
        /// </summary>
        /// <param name="map">The map to update</param>
        /// <returns></returns>
        private async Task UpdateMapData(IMap map)
        {
            if (!IsSignedIn)
            {
                return;
            }

            try
            {
                RectLatLng area = map.GetViewArea();
                await _messagesService.AddMessageAsync($"Map area {area.Top}, {area.Bottom}, {area.Left}, {area.Right}");

                AAFeatureCollection mapData = await _client.GetMapData(area);

                // build the filter list
                mapData.GetFilters();

                // this ensures the user sees the results before its saved
                _settings.MapFilters = FilteredOut;

                await _messagesService.AddMessageAsync($"Map area Loaded {area.Top}, {area.Bottom}, {area.Left}, {area.Right}");

                // add all items to cache
                MapFeatureCache.Clear();
                mapData.Features.ForEach(feature => MapFeatureCache[feature.Id] = feature);

                // Only get the features that are enabled by default, and have not been filtered out
                IEnumerable <Feature> features = mapData.Features.Where(feature => feature.IsEnabledByDefault() && feature.IsFilterOutItem(FilteredOut)).ToList();

                ProcessFeatures(map, features);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }