当前位置: 首页>>代码示例>>C#>>正文


C# IMap.GetViewArea方法代码示例

本文整理汇总了C#中IMap.GetViewArea方法的典型用法代码示例。如果您正苦于以下问题:C# IMap.GetViewArea方法的具体用法?C# IMap.GetViewArea怎么用?C# IMap.GetViewArea使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMap的用法示例。


在下文中一共展示了IMap.GetViewArea方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateMapData

        /// <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);

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

            IOverlay airOverlay = map.GetOverlay("AAMapData.Air", true);
            IOverlay groundOverlay = map.GetOverlay("AAMapData.Ground", true);

            bool groundDataExcluded = mapData.ExcludedData.Any(i => i.SelectToken("detail.name")?.Value<string>() == "Ground Hazards");
            groundOverlay.IsVisible = GroundDataDisplay;
            airOverlay.IsVisible = AirDataDisplay;

            // Only get the features that have no lower alt or start below 152m. Ignoring datum for now...
            IEnumerable<Feature> features = mapData.Features.ToList();


            foreach (Feature feature in features)
            {
                IOverlay overlay = string.Equals((string)feature.Properties.Get("category"), "airspace")
                    ? airOverlay
                    : groundOverlay;

                var altitude = ((JObject)feature.Properties.Get("altitudeFloor"))?.ToObject<Altitude>();

                if (altitude == null || altitude.Meters <= 152)
                {
                    if (!GroundDataDisplay)
                    {
                        if (overlay.PolygonExists(feature.Id))

                            continue;
                    }
                }
                else
                {
                    if (!AirDataDisplay)
                    {
                        continue;
                    }
                }

                switch (feature.Geometry.Type)
                {
                    case GeoJSONObjectType.Point:
                        break;
                    case GeoJSONObjectType.MultiPoint:
                        break;
                    case GeoJSONObjectType.LineString:
                        {
                            if (!overlay.LineExists(feature.Id))
                            {
                                var line = (LineString)feature.Geometry;
                                List<PointLatLng> coordinates = line.Coordinates.OfType<GeographicPosition>()
                                                                    .Select(c => new PointLatLng(c.Latitude, c.Longitude))
                                                                    .ToList();
                                overlay.AddLine(feature.Id, coordinates, new ColorInfo { StrokeColor = 0xFFFF0000 }, feature);
                            }
                        }
                        break;

                    case GeoJSONObjectType.MultiLineString:
                        break;
                    case GeoJSONObjectType.Polygon:
                        {
                            if (!overlay.PolygonExists(feature.Id))
                            {
                                var poly = (Polygon)feature.Geometry;
                                List<PointLatLng> coordinates =
                                    poly.Coordinates[0].Coordinates.OfType<GeographicPosition>()
                                                       .Select(c => new PointLatLng(c.Latitude, c.Longitude))
                                                       .ToList();

                                ColorInfo colorInfo = feature.ToColorInfo();
                                colorInfo.StrokeColor = 0xFFFF0000;
                                overlay.AddPolygon(feature.Id, coordinates, colorInfo, feature);
                            }
                        }
                        break;
                    case GeoJSONObjectType.MultiPolygon:
                        break;
                    case GeoJSONObjectType.GeometryCollection:
                        break;
                    case GeoJSONObjectType.Feature:
                        break;
                    case GeoJSONObjectType.FeatureCollection:
                        break;
                    default:
                        throw new ArgumentOutOfRangeException();
//.........这里部分代码省略.........
开发者ID:nitbot,项目名称:MissionPlanner,代码行数:101,代码来源:AltitudeAngelService.cs

示例2: UpdateMapData

        /// <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);
        }
开发者ID:ArduPilot,项目名称:MissionPlanner,代码行数:31,代码来源:AltitudeAngelService.cs


注:本文中的IMap.GetViewArea方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。