public ISubMapLayer CreateNewSubLayer(BaseMapLayer ParentLayer)
            {
                SubMapLayer NewLayer = new SubMapLayer();

                ((MapLayer)ParentLayer).ListSubLayer.Add(NewLayer);
                return(NewLayer);
            }
        private async void btnFindOptimalPlacement_Click(object sender, RoutedEventArgs e)
        {
            // Call the AI for Earth land cover API
            Bitmap returnImage = await AIforEarthLandCoverMappingAnalyze(imageFilePath);

            classifiedImg.Source = ConvertBitmapToBitmapImage(returnImage);

            if (classifiedImg.Source != null)
            {
                //Add the image to the map if location information is available.
                if (imagePosition != null && imagePosition.Count == 4)
                {
                    classifiedMapLayer = new ImageLayer(classifiedImg.Source as BitmapImage, new AzureMapsWpfControl.Data.Path(imagePosition))
                    {
                        Opacity = 0
                    };
                    MyMap.Layers.Add(classifiedMapLayer);

                    MapLayerOpacity.IsEnabled = true;
                }

                // Using the land cover information, find the optimal spot to place Project Premonition traps.
                FindBestPlacement(returnImage);
            }
        }
        public virtual void Init()
        {
            if (Owner.IsOfflineOrServer)
            {
                int PlayerIndex = 1;
                foreach (Player ActivePlayer in Owner.ListPlayer)
                {
                    if (ActivePlayer.Inventory == null)
                    {
                        continue;
                    }

                    string PlayerTag       = PlayerIndex.ToString();
                    int    SpawnSquadIndex = 0;
                    for (int L = 0; L < Owner.LayerManager.ListLayer.Count; L++)
                    {
                        BaseMapLayer ActiveLayer = Owner.LayerManager[L];
                        for (int S = 0; S < ActiveLayer.ListMultiplayerSpawns.Count; S++)
                        {
                            if (ActiveLayer.ListMultiplayerSpawns[S].Tag == PlayerTag)
                            {
                                if (ActivePlayer.Inventory.ActiveLoadout.ListSquad[SpawnSquadIndex] == null)
                                {
                                    ++SpawnSquadIndex;
                                    continue;
                                }

                                for (int U = 0; U < ActivePlayer.Inventory.ActiveLoadout.ListSquad[SpawnSquadIndex].UnitsInSquad; ++U)
                                {
                                    ActivePlayer.Inventory.ActiveLoadout.ListSquad[SpawnSquadIndex].At(U).ReinitializeMembers(Owner.DicUnitType[ActivePlayer.Inventory.ActiveLoadout.ListSquad[SpawnSquadIndex].At(U).UnitTypeName]);
                                }

                                ActivePlayer.Inventory.ActiveLoadout.ListSquad[SpawnSquadIndex].ReloadSkills(Owner.DicUnitType, Owner.DicRequirement, Owner.DicEffect, Owner.DicAutomaticSkillTarget, Owner.DicManualSkillTarget);
                                Owner.SpawnSquad(PlayerIndex - 1, ActivePlayer.Inventory.ActiveLoadout.ListSquad[SpawnSquadIndex], 0, ActiveLayer.ListMultiplayerSpawns[S].Position, L);
                                ++SpawnSquadIndex;

                                if (SpawnSquadIndex >= ActivePlayer.Inventory.ActiveLoadout.ListSquad.Count)
                                {
                                    break;
                                }
                            }
                        }

                        if (SpawnSquadIndex >= ActivePlayer.Inventory.ActiveLoadout.ListSquad.Count)
                        {
                            break;
                        }
                    }

                    ++PlayerIndex;
                }

                Owner.CursorPosition = Owner.ListPlayer[0].ListSquad[0].Position;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Adds the specified base map.
        /// </summary>
        /// <param name="baseMap">The base map.</param>
        public static void Add(BaseMapLayer baseMap)
        {
            string url  = "";
            string name = "";

            try
            {
                switch (baseMap)
                {
                case BaseMapLayer.Imagery:
                    url  = "http://services.arcgisonline.com/arcgis/rest/services/ESRI_Imagery_World_2D/MapServer";
                    name = "影像图";
                    break;

                default:
                    url  = "http://cache1.arcgisonline.cn/arcgis/rest/services/ChinaOnlineCommunity/MapServer";
                    name = "街区图";
                    break;
                }
                if (BaseMap.IsExists(name))
                {
                    return;
                }
                MapServerRESTLayer restLayer = new MapServerRESTLayer();
                restLayer.Connect(url);
                //Add the layer to the map.
                ILayer layer = restLayer as ILayer;
                layer.Name = name;
                EnviVars.instance.MapControl.AddLayer(layer, EnviVars.instance.MapControl.LayerCount);
                Zom2China();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public void RemoveSubLayer(BaseMapLayer ParentLayer, ISubMapLayer SubLayer)
 {
     ((MapLayer)ParentLayer).ListSubLayer.Remove((SubMapLayer)SubLayer);
 }
        private void LoadMapDataForImage()
        {
            if (isMapLoaded)
            {
                if (originalMapLayer != null)
                {
                    MyMap.Layers.Remove(originalMapLayer);
                    classifiedMapLayer = null;

                    MapLayerOpacity.Value = 0;

                    if (classifiedMapLayer != null)
                    {
                        MyMap.Layers.Remove(classifiedMapLayer);
                        classifiedMapLayer        = null;
                        MapLayerOpacity.IsEnabled = false;
                    }

                    if (trapLayer != null)
                    {
                        MyMap.Layers.Remove(trapLayer);
                    }

                    (hospitalLayer.Source as GeoJsonSource).Clear();
                }

                var      locs   = ImageLocationExactor.GetCoordinates(imageFilePath, img.Source as BitmapImage);
                Position center = null;

                if (locs != null && locs.Count > 0)
                {
                    if (locs.Count == 1)
                    {
                        //Only have a single location, create a pin.
                        originalMapLayer = new SymbolLayer()
                        {
                            Source = new GeoJsonSource()
                            {
                                new GeoPoint(locs[0])
                            }
                        };

                        center = locs[0];
                    }
                    else if (locs.Count == 4)
                    {
                        //Have all four corners of image; top-left, top-right, bottom-right, bottom-left.
                        originalMapLayer = new ImageLayer(img.Source as BitmapImage, new AzureMapsWpfControl.Data.Path(locs));

                        imagePosition = locs;

                        center = new Position((locs[0].Longitude + locs[2].Longitude) / 2, (locs[0].Latitude + locs[2].Latitude) / 2);
                    }
                }

                if (originalMapLayer != null)
                {
                    MyMap.Layers.Add(originalMapLayer);

                    MyMap.SetCamera(new CameraOptions()
                    {
                        Center = center,
                        Zoom   = 15
                    }, new AnimationOptions()
                    {
                        AnimationType = AnimationType.Fly,
                        Duration      = new TimeSpan(0, 0, 2)
                    });

                    LoadNearbyPOIs(center);
                }
            }
        }