private void refreshMap() { if (resultsTreeView.SelectedItem == null) { return; } var location = ((GeographicPosition)((TreeViewItem)resultsTreeView.SelectedItem).Tag); var map = new StaticMap(); map.Center = location.Latitude.ToString() + "," + location.Longitude; map.Zoom = zoomSlider.Value.ToString("0"); map.Size = "332x332"; map.Markers = map.Center; map.MapType = ((ComboBoxItem)mapTypeComboBox.SelectedItem).Content.ToString(); map.Sensor = "false"; var image = new BitmapImage(); image.BeginInit(); image.CacheOption = BitmapCacheOption.OnDemand; image.UriSource = map.ToUri(); image.DownloadFailed += new EventHandler <ExceptionEventArgs>(image_DownloadFailed); image.EndInit(); image1.Source = image; }
public void TestThatConstructorInitializeStaticMap() { var staticMap = new StaticMap <int, string>(); Assert.That(staticMap, Is.Not.Null); Assert.That(staticMap.ExceptionInfo, Is.Not.Null); Assert.That(staticMap.ExceptionInfo, Is.Not.Empty); Assert.That(staticMap.ExceptionInfo, Is.EqualTo(string.Format("{0}, TSource={1}, TTarget={2}", staticMap.GetType().Name, typeof(int).Name, typeof(string).Name))); Assert.That(staticMap.MappingObject, Is.Not.Null); Assert.That(staticMap.MappingObject, Is.EqualTo(staticMap)); Assert.That(staticMap.MappingObjectData, Is.Null); }
public Uri GenerateStaticMapUrl(GeocodingResult searchResult) { var map = new StaticMap(); map.Center = searchResult.FormattedAddress; // or a lat/lng coordinate //map.Path = searchResult.FormattedAddress + "|" + "9 Snowball Place Wanniassa"; map.Zoom = "14"; map.Size = "400x400"; map.Sensor = "true"; map.Markers = searchResult.FormattedAddress; Uri url = map.ToUri(); return url; }
// a simple intuitive public access point for the client to get a map from Google, by coordinates. public string GetMap(string i_Coordinates) { var map = new StaticMap(); map.Center = i_Coordinates; map.Language = "hebrew"; map.Zoom = "14"; map.Size = "400x400"; map.Sensor = "false"; map.Markers = map.Center; string url = map.ToUri().ToString(); return(url); }
public void CanMapToMqtt(string googleValue, object value, string expectedResult) { // Arrange var mapper = new StaticMap { Google = googleValue }; // Act var matches = mapper.MatchesGoogle(value); var result = mapper.ConvertToMqtt(value); // Assert Assert.True(matches); Assert.Equal(expectedResult, result); }
static StaticMap[,] SetAdjacentLand(StaticMap[,] map) { int sizex = map.GetLength(0); int sizey = map.GetLength(1); StaticMap[,] new_map = new StaticMap[sizex, sizey]; for (int y = 0; y < sizey; y++) { for (int x = 0; x < sizex; x++) { new_map[x, y] = map[x, y]; } } for (int y = 0; y < sizey; y++) { for (int x = 0; x < sizex; x++) { if (new_map[x, y].type == 1) { Vector2[] neighbours = new Vector2[4]; neighbours[0] = new Vector2(x + 1, y); neighbours[1] = new Vector2(x - 1, y); neighbours[2] = new Vector2(x, y + 1); neighbours[3] = new Vector2(x, y - 1); List <Vector2> found = new List <Vector2>(); for (int i = 0; i < neighbours.Length; i++) { int xindex = (int)neighbours[i].x; int yindex = (int)neighbours[i].y; if (CheckIfCellExists(new_map, xindex, yindex)) { if (new_map[xindex, yindex].type == 1) { found.Add(new Vector2(xindex, yindex)); } } } new_map[x, y].adjacent_land = found.ToArray(); } } } return(new_map); }
private void updateMap() { var result = (GeocodingResult)currentSelectedLocation; fullAddress.Text = result.FormattedAddress; var location = result.Geometry.Location; var map = new StaticMap(); map.Center = location.Latitude.ToString() + "," + location.Longitude.ToString(); txtLatitude.Text = location.Latitude.ToString(); txtLongtitude.Text = location.Longitude.ToString(); map.Zoom = (zoomLevels.SelectedItem == null) ? "10" : zoomLevels.Text.ToString(); map.Markers = map.Center; map.Size = "1000" + "x" + "485"; map.MapType = (mapTypeColombo.SelectedItem == null) ? "roadmap" : mapTypeColombo.Text.ToString(); map.Sensor = "false"; String urlToMap = map.ToUri().AbsoluteUri.ToString(); webBrowser1.Navigate(urlToMap); }
private void refreshMap() { if (resultsTreeView.SelectedItem == null) return; var location = ((GeographicPosition)((TreeViewItem)resultsTreeView.SelectedItem).Tag); var map = new StaticMap(); map.Center = location.Latitude.ToString(CultureInfo.InvariantCulture) + "," + location.Longitude.ToString(CultureInfo.InvariantCulture); map.Zoom = zoomSlider.Value.ToString("0"); map.Size = "332x332"; map.Markers = map.Center; map.MapType = ((ComboBoxItem)mapTypeComboBox.SelectedItem).Content.ToString(); map.Sensor = "false"; var image = new BitmapImage(); image.BeginInit(); image.CacheOption = BitmapCacheOption.OnDemand; image.UriSource = map.ToUri(); image.DownloadFailed += new EventHandler<ExceptionEventArgs>(image_DownloadFailed); image.EndInit(); image1.Source = image; }
static StaticMap[,] GenerateMap(int size) { //Generates a map with perlin noise //No smoothness or validity StaticMap[,] new_map = new StaticMap[size * 2, size]; float xseed = Random.Range(0f, 100f); float yseed = Random.Range(0f, 100f); xseed = Random.Range(0f, 1f); yseed = Random.Range(0f, 1f); for (int y = 0; y < size; y++) { for (int x = 0; x < size * 2; x++) { new_map[x, y] = new StaticMap(); float cell_perlin = Mathf.PerlinNoise(((float)x / 35) + xseed, ((float)y / 35) + yseed) * 2; new_map[x, y].perlin = cell_perlin; } } xseed = Random.Range(0f, 100f); yseed = Random.Range(0f, 100f); for (int y = 0; y < size; y++) { for (int x = 0; x < size * 2; x++) { float cell_perlin = Mathf.PerlinNoise(new_map[x, y].perlin * x / 15 + xseed, y / 15 + yseed) * new_map[x, y].perlin; new_map[x, y].perlin = cell_perlin; if (cell_perlin >= 0.4f) { new_map[x, y].type = 1; } else { new_map[x, y].type = 0; } } } return(new_map); }
public LocationMapState() : base() { this.currentMap = new StaticMap(TmxMapDeserializer.Deserialize("Content/Maps/town.tmx")); // Create one entity per tile for (var i = 0; i < this.currentMap.Tiles.Length; i++) { var sourceTile = this.currentMap.Tiles[i]; this.Add(new CobaltEntity() .Tile(this.currentMap.Tileset, sourceTile.SourceTileX, sourceTile.SourceTileY, this.currentMap.TileWidth, this.currentMap.TileHeight) .Move(sourceTile.X, sourceTile.Y)); } this.player = new CobaltEntity().Sprite("Content/Images/Player.png") .MoveToKeyboard(100) .Move( // Locate just two tiles above the exit. this.currentMap.ExitLocationX, this.currentMap.ExitLocationY - 2 * this.currentMap.TileHeight); this.Add(this.player); }
private IReadOnlyDictionary <string, string> GetProperties(DiscordGuild guild, WhConfig whConfig, string city, string raidImageUrl) { var pkmnInfo = MasterFile.GetPokemon(PokemonId, Form); var name = IsEgg ? "Egg" /*TODO: Localize*/ : Translator.Instance.GetPokemonName(PokemonId); var form = Translator.Instance.GetFormName(Form); var costume = Translator.Instance.GetCostumeName(Costume); var evo = Translator.Instance.GetEvolutionName(Evolution); var gender = Gender.GetPokemonGenderIcon(); var level = Level; var move1 = Translator.Instance.GetMoveName(FastMove); var move2 = Translator.Instance.GetMoveName(ChargeMove); var types = pkmnInfo?.Types; var type1 = types?[0]; var type2 = types?.Count > 1 ? types?[1] : PokemonType.None; var type1Emoji = types?[0].GetTypeEmojiIcons(); var type2Emoji = pkmnInfo?.Types?.Count > 1 ? types?[1].GetTypeEmojiIcons() : string.Empty; var typeEmojis = $"{type1Emoji} {type2Emoji}"; var weaknesses = Weaknesses == null ? string.Empty : string.Join(", ", Weaknesses); var weaknessesEmoji = types?.GetWeaknessEmojiIcons(); var perfectRange = PokemonId.MaxCpAtLevel(20); var boostedRange = PokemonId.MaxCpAtLevel(25); var worstRange = PokemonId.MinCpAtLevel(20); var worstBoosted = PokemonId.MinCpAtLevel(25); var exEmojiId = MasterFile.Instance.Emojis["ex"]; var exEmoji = exEmojiId > 0 ? $"<:ex:{exEmojiId}>" : "EX"; var teamEmojiId = MasterFile.Instance.Emojis[Team.ToString().ToLower()]; var teamEmoji = teamEmojiId > 0 ? $"<:{Team.ToString().ToLower()}:{teamEmojiId}>" : Team.ToString(); var gmapsLink = string.Format(Strings.GoogleMaps, Latitude, Longitude); var appleMapsLink = string.Format(Strings.AppleMaps, Latitude, Longitude); var wazeMapsLink = string.Format(Strings.WazeMaps, Latitude, Longitude); var scannerMapsLink = string.Format(whConfig.Urls.ScannerMap, Latitude, Longitude); var staticMapLink = StaticMap.GetUrl(whConfig.Urls.StaticMap, whConfig.StaticMaps["raids"], Latitude, Longitude, raidImageUrl, Team); var gmapsLocationLink = UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, gmapsLink); var appleMapsLocationLink = UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, appleMapsLink); var wazeMapsLocationLink = UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, wazeMapsLink); var scannerMapsLocationLink = UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, scannerMapsLink); var address = new Location(null, city, Latitude, Longitude).GetAddress(whConfig); //var staticMapLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? staticMapLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, staticMapLink); var now = DateTime.UtcNow.ConvertTimeFromCoordinates(Latitude, Longitude); var startTimeLeft = now.GetTimeRemaining(StartTime).ToReadableStringNoSeconds(); var endTimeLeft = now.GetTimeRemaining(EndTime).ToReadableStringNoSeconds(); const string defaultMissingValue = "?"; var dict = new Dictionary <string, string> { //Raid boss properties { "pkmn_id", PokemonId.ToString() }, { "pkmn_id_3", PokemonId.ToString("D3") }, { "pkmn_name", name }, { "pkmn_img_url", raidImageUrl }, { "evolution", evo }, { "evolution_id", Convert.ToInt32(Evolution).ToString() }, { "evolution_id_3", Evolution.ToString("D3") }, { "form", form }, { "form_id", Form.ToString() }, { "form_id_3", Form.ToString("D3") }, { "costume", costume }, { "costume_id", Costume.ToString() }, { "costume_id_3", Costume.ToString("D3") }, { "is_egg", Convert.ToString(IsEgg) }, { "is_ex", Convert.ToString(IsExEligible) }, { "ex_emoji", exEmoji }, { "team", Team.ToString() }, { "team_id", Convert.ToInt32(Team).ToString() }, { "team_emoji", teamEmoji }, { "cp", CP ?? defaultMissingValue }, { "lvl", level ?? defaultMissingValue }, { "gender", gender ?? defaultMissingValue }, { "move_1", move1 ?? defaultMissingValue }, { "move_2", move2 ?? defaultMissingValue }, { "moveset", $"{move1}/{move2}" }, { "type_1", type1?.ToString() ?? defaultMissingValue }, { "type_2", type2?.ToString() ?? defaultMissingValue }, { "type_1_emoji", type1Emoji }, { "type_2_emoji", type2Emoji }, { "types", $"{type1}/{type2}" }, { "types_emoji", typeEmojis }, { "weaknesses", weaknesses }, { "weaknesses_emoji", weaknessesEmoji }, { "perfect_cp", perfectRange.ToString() }, { "perfect_cp_boosted", boostedRange.ToString() }, { "worst_cp", worstRange.ToString() }, { "worst_cp_boosted", worstBoosted.ToString() }, //Time properties { "start_time", StartTime.ToLongTimeString() }, { "start_time_24h", StartTime.ToString("HH:mm:ss") }, { "start_time_left", startTimeLeft }, { "end_time", EndTime.ToLongTimeString() }, { "end_time_24h", EndTime.ToString("HH:mm:ss") }, { "end_time_left", endTimeLeft }, //Location properties { "geofence", city ?? defaultMissingValue }, { "lat", Latitude.ToString() }, { "lng", Longitude.ToString() }, { "lat_5", Latitude.ToString("0.00000") }, { "lng_5", Longitude.ToString("0.00000") }, //Location links { "tilemaps_url", staticMapLink }, { "gmaps_url", gmapsLocationLink }, { "applemaps_url", appleMapsLocationLink }, { "wazemaps_url", wazeMapsLocationLink }, { "scanmaps_url", scannerMapsLocationLink }, { "address", address?.Address }, //Gym properties { "gym_id", GymId }, { "gym_name", GymName }, { "gym_url", GymUrl }, // Discord Guild properties { "guild_name", guild?.Name }, { "guild_img_url", guild?.IconUrl }, { "date_time", DateTime.Now.ToString() }, //Misc properties { "br", "\r\n" } }; return(dict); }
public ProposalDocumentViewModel ProposalDocumentData() { string QRFID = Request.Query["QRFId"]; ProposalDocumentViewModel model = new ProposalDocumentViewModel(); if (!string.IsNullOrEmpty(QRFID)) { try { #region fetching all data from service COProviders objCOProvider = new COProviders(_configuration); QuoteAgentGetReq objQRFAgentRequest = new QuoteAgentGetReq() { QRFID = QRFID }; ProposalDocumentGetRes objProposalRes = objCOProvider.GetProposalDocumentDetailsByQRFID(objQRFAgentRequest, token).Result; model.COHeaderViewModel = COCommonLibrary.GetProposalDocumentHeaderDetails(QRFID, Request, Response, token); model.Itinerary = objProposalRes.Itinerary; model.Proposal = objProposalRes.Proposal; model.QRFQuote = objProposalRes.QRFQuote; model.ProductImages = objProposalRes.ProductImages; model.GenericImages = objProposalRes.GenericImages; model.CountryImageInitial = _configuration.GetValue <string>("SystemSettings:CountryImageInitial"); model.URLinitial = model.COHeaderViewModel.URLinitial = HttpContext.Request.Scheme + "://" + HttpContext.Request.Host.Value; model.RoutingCities.AddRange(objProposalRes.Itinerary.ItineraryDays.Select(a => a.City + "," + a.Country)); model.RoutingCities.AddRange(objProposalRes.Itinerary.ItineraryDays.Select(a => a.ToCityName + "," + a.ToCountryName)); model.RoutingCities = model.RoutingCities.Distinct().ToList(); model.RoutingCities.RemoveAll(a => string.IsNullOrEmpty(a) || a == ","); model.Itinerary.ItineraryDays.ForEach(a => a.Hotel = a.Hotel.Where(b => b.IsDeleted == false).ToList()); model.Itinerary.ItineraryDays.ForEach(a => a.Meal = a.Meal.Where(b => b.IsDeleted == false).ToList()); if (model.Proposal != null && model.Proposal.ProposalIncludeRegions == null) { model.Proposal.ProposalIncludeRegions = new ProposalIncludeRegions(); } #endregion #region creating dates list for date range DateTime date; string month; var list = new List <ProposalDepartDate>(); foreach (var item in model.QRFQuote.Departures.OrderBy(a => a.Date)) { date = Convert.ToDateTime(item.Date); month = date.ToString("MMMM"); list.Add(new ProposalDepartDate { Day = date.Day.ToString(), Month = month, Year = date.Year.ToString() }); } var list2 = new List <ProposalDepartDate>(); foreach (var item in list) { month = item.Month + " " + item.Year; if (list2.Where(a => a.Month == month).Count() > 0) { list2.Where(a => a.Month == month).FirstOrDefault().Day += (", " + item.Day); } else { list2.Add(new ProposalDepartDate { Month = month, Day = item.Day }); } } model.DatesList = list2; #endregion #region google maps section StaticMap._configuration = _configuration; //GeocoderLocation geocoder = StaticMap.Locate(model.QRFQuote.AgentProductInfo.Destination.Split('|')[1]); string mapURL = "https://maps.googleapis.com/maps/api/staticmap?center={0}&zoom=3&size=233x206&maptype=roadmap&key=GoogleAPIKey&markers=color:red|label:AA|{0}"; mapURL = string.Format(mapURL, model.QRFQuote.AgentProductInfo.Destination.Split('|')[1]); if (StaticMap.RenderImage(mapURL, QRFID + "_ProposalDocument_smallmap.png", out string output)) { model.SmallMapURL = output; } mapURL = "https://maps.googleapis.com/maps/api/staticmap?size=773x682&maptype=roadmap&key=GoogleAPIKey"; foreach (string city in model.RoutingCities) { //geocoder = StaticMap.Locate(city); mapURL += "&markers=color:red|label:AA|{0}"; mapURL = string.Format(mapURL, city); } if (StaticMap.RenderImage(mapURL, QRFID + "_ProposalDocument_bigmap.png", out output)) { model.BigMapURL = output; } string ProdId = ""; for (int i = 0; i < model.Itinerary.ItineraryDays.Count; i++) { for (int j = 0; j < model.Itinerary.ItineraryDays[i].Hotel.Count; j++) { if (!string.IsNullOrEmpty(model.Itinerary.ItineraryDays[i].Hotel[j].Lat) && !string.IsNullOrEmpty(model.Itinerary.ItineraryDays[i].Hotel[j].Long) && model.Itinerary.ItineraryDays[i].Hotel[j].IsDeleted == false) { ProdId = !string.IsNullOrEmpty(model.Itinerary.ItineraryDays[i].Hotel[j].HotelId) ? model.Itinerary.ItineraryDays[i].Hotel[j].HotelId : model.Itinerary.ItineraryDays[i].Hotel[j].PositionId; mapURL = "https://maps.googleapis.com/maps/api/staticmap?zoom=10&size=284x191&maptype=roadmap&key=GoogleAPIKey"; mapURL += "&markers=color:red|label:AA|{0},{1}"; mapURL = string.Format(mapURL, model.Itinerary.ItineraryDays[i].Hotel[j].Lat, model.Itinerary.ItineraryDays[i].Hotel[j].Long); if (StaticMap.RenderImage(mapURL, ProdId + "_ProposalDocument_hotelmap.png", out output)) { model.Itinerary.ItineraryDays[i].Hotel[j].HotelMapURL = output; } } } } #endregion #region Proposal Terms string templatePath = _configuration.GetValue <string>("Pages:ProposalTermsTemplate"); var pathToFile = Path.Combine(Directory.GetCurrentDirectory(), templatePath); var builder = new StringBuilder(); using (StreamReader SourceReader = System.IO.File.OpenText(pathToFile)) { builder.Append(SourceReader.ReadToEnd()); model.Proposal.Terms += Environment.NewLine + builder.ToString(); } #endregion #region fetching hotel images from expedia string HotelMapImage; List <ArrProductResources> HotelRes = new List <ArrProductResources>(); foreach (var days in model.Itinerary.ItineraryDays) { foreach (var hotel in days.Hotel) { if (hotel.ProdResources != null) { HotelRes = hotel.ProdResources.Where(a => a.ResourceType == "Image").OrderBy(a => a.OrderNr).ToList(); } if (hotel.ProdResources == null || HotelRes == null || HotelRes.Count < 1 || (HotelRes.Count > 0 && string.IsNullOrEmpty(HotelRes[0].ImageSRC))) { if (StaticMap.RenderExpediaImage(hotel.HotelCode, ProdId + "_ProposalDocument_hotelimage.png", out output)) { HotelMapImage = output; } } } } #endregion #region replacing image urls from resources to ImageResources foreach (var ItineraryDay in model.Itinerary.ItineraryDays) { if (ItineraryDay.Hotel != null) { foreach (var Hotel in ItineraryDay.Hotel) { if (Hotel.ProdResources != null) { foreach (var ProdResource in Hotel.ProdResources) { if (ProdResource.ImageSRC != null) { ProdResource.ImageSRC = ProdResource.ImageSRC.Replace("resources/", "ImageResources/"); } } } } } } #endregion #region Get Hotel Summary details from Itinerary ProposalGetReq req = new ProposalGetReq(); ProposalGetRes res = new ProposalGetRes(); req.QRFID = QRFID; res = objCOProvider.GetHotelSummaryByQrfId(req, token).Result; var hotellist = res.Hotels; model.HotelList = hotellist.Select(x => new Hotel { HotelName = x.HotelName, Location = string.IsNullOrWhiteSpace(x.Location) ? "" : x.Location.Split(',')[0], Stars = x.Stars, Duration = x.Duration }).ToList(); #endregion } catch (Exception ex) { throw; //Console.WriteLine(ex.Message); } } return(model); }
private IReadOnlyDictionary <string, string> GetProperties(DiscordGuild guild, WhConfig whConfig, string city, string questRewardImageUrl) { var questMessage = this.GetQuestMessage(); var questConditions = this.GetConditions(); var questReward = this.GetReward(); var gmapsLink = string.Format(Strings.GoogleMaps, Latitude, Longitude); var appleMapsLink = string.Format(Strings.AppleMaps, Latitude, Longitude); var wazeMapsLink = string.Format(Strings.WazeMaps, Latitude, Longitude); var scannerMapsLink = string.Format(whConfig.Urls.ScannerMap, Latitude, Longitude); var staticMapLink = StaticMap.GetUrl(whConfig.Urls.StaticMap, whConfig.StaticMaps["quests"], Latitude, Longitude, questRewardImageUrl); var gmapsLocationLink = UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, gmapsLink); var appleMapsLocationLink = UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, appleMapsLink); var wazeMapsLocationLink = UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, wazeMapsLink); var scannerMapsLocationLink = UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, scannerMapsLink); var address = new Location(null, city, Latitude, Longitude).GetAddress(whConfig); //var staticMapLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? staticMapLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, staticMapLink); const string defaultMissingValue = "?"; var dict = new Dictionary <string, string> { //Main properties { "quest_task", questMessage }, { "quest_conditions", questConditions }, { "quest_reward", questReward }, { "quest_reward_img_url", questRewardImageUrl }, { "has_quest_conditions", Convert.ToString(!string.IsNullOrEmpty(questConditions)) }, { "is_ditto", Convert.ToString(IsDitto) }, { "is_shiny", Convert.ToString(IsShiny) }, //Location properties { "geofence", city ?? defaultMissingValue }, { "lat", Latitude.ToString() }, { "lng", Longitude.ToString() }, { "lat_5", Latitude.ToString("0.00000") }, { "lng_5", Longitude.ToString("0.00000") }, //Location links { "tilemaps_url", staticMapLink }, { "gmaps_url", gmapsLocationLink }, { "applemaps_url", appleMapsLocationLink }, { "wazemaps_url", wazeMapsLocationLink }, { "scanmaps_url", scannerMapsLocationLink }, { "address", address?.Address }, //Pokestop properties { "pokestop_id", PokestopId ?? defaultMissingValue }, { "pokestop_name", PokestopName ?? defaultMissingValue }, { "pokestop_url", PokestopUrl ?? defaultMissingValue }, // Discord Guild properties { "guild_name", guild?.Name }, { "guild_img_url", guild?.IconUrl }, { "date_time", DateTime.Now.ToString() }, //Misc properties { "br", "\r\n" } }; return(dict); }
public IReadOnlyDictionary <string, string> GetProperties(DiscordGuild guild, Nest nest, string pokemonImageUrl) { var pkmnInfo = MasterFile.GetPokemon(nest.PokemonId, 0); var pkmnImage = pokemonImageUrl; var nestName = nest.Name ?? "Unknown"; var type1 = pkmnInfo?.Types?[0]; var type2 = pkmnInfo?.Types?.Count > 1 ? pkmnInfo.Types?[1] : PokemonType.None; var type1Emoji = pkmnInfo?.Types?[0].GetTypeEmojiIcons(); var type2Emoji = pkmnInfo?.Types?.Count > 1 ? pkmnInfo?.Types?[1].GetTypeEmojiIcons() : string.Empty; var typeEmojis = $"{type1Emoji} {type2Emoji}"; var gmapsLink = string.Format(Strings.GoogleMaps, nest.Latitude, nest.Longitude); var appleMapsLink = string.Format(Strings.AppleMaps, nest.Latitude, nest.Longitude); var wazeMapsLink = string.Format(Strings.WazeMaps, nest.Latitude, nest.Longitude); var scannerMapsLink = string.Format(_dep.WhConfig.Urls.ScannerMap, nest.Latitude, nest.Longitude); var staticMapLink = StaticMap.GetUrl(_dep.WhConfig.Urls.StaticMap, _dep.WhConfig.StaticMaps["nests"], nest.Latitude, nest.Longitude, pkmnImage, Net.Models.PokemonTeam.All, _dep.OsmManager.GetNest(nest.Name)?.FirstOrDefault()); var geofence = _dep.Whm.GetGeofence(guild.Id, nest.Latitude, nest.Longitude); var city = geofence?.Name ?? "Unknown"; var address = new Location(null, city, nest.Latitude, nest.Longitude).GetAddress(_dep.WhConfig); var dict = new Dictionary <string, string> { //Main properties { "pkmn_id", Convert.ToString(nest.PokemonId) }, { "pkmn_id_3", nest.PokemonId.ToString("D3") }, { "pkmn_name", pkmnInfo?.Name }, { "pkmn_img_url", pkmnImage }, { "avg_spawns", Convert.ToString(nest.Average) }, { "nest_name", nestName }, { "type_1", Convert.ToString(type1) }, { "type_2", Convert.ToString(type2) }, { "type_1_emoji", type1Emoji }, { "type_2_emoji", type2Emoji }, { "types", $"{type1} | {type2}" }, { "types_emojis", typeEmojis }, //Location properties { "geofence", city }, { "lat", Convert.ToString(nest.Latitude) }, { "lng", Convert.ToString(nest.Longitude) }, { "lat_5", Convert.ToString(Math.Round(nest.Latitude, 5)) }, { "lng_5", Convert.ToString(Math.Round(nest.Longitude, 5)) }, //Location links { "tilemaps_url", staticMapLink }, { "gmaps_url", gmapsLink }, { "applemaps_url", appleMapsLink }, { "wazemaps_url", wazeMapsLink }, { "scanmaps_url", scannerMapsLink }, { "address", address?.Address }, // Discord Guild properties { "guild_name", guild?.Name }, { "guild_img_url", guild?.IconUrl }, { "date_time", DateTime.Now.ToString() }, //Misc properties { "br", "\r\n" } }; return(dict); }
static DynamicMap[,] SmoothDynamicMap(DynamicMap[,] smoothing_map, StaticMap[,] static_map) { int xsize = smoothing_map.GetLength(0); int ysize = smoothing_map.GetLength(1); DynamicMap[,] result = new DynamicMap[xsize, ysize]; for (int y = 0; y < ysize; y++) { for (int x = 0; x < xsize; x++) { result[x, y] = smoothing_map[x, y]; } } for (int y = 0; y < ysize; y++) { for (int x = 0; x < xsize; x++) { //Get influences over this cell and store it DynamicMap d = result[x, y]; StaticMap s = static_map[x, y]; List <Influence> influences = new List <Influence>(); Vector2[] adjacents = { new Vector2(0, 1), new Vector2(1, 1), new Vector2(1, 0), new Vector2(1, -1), new Vector2(0, -1), new Vector2(-1, -1), new Vector2(-1, 0), new Vector2(-1, 1) }; //if(s.adjacent_land != null){ if (d.owner_id != -1) { for (int i = 0; i < adjacents.Length; i++) { int cx = (int)(adjacents[i].x + d.coordinates.x); int cy = (int)(adjacents[i].y + d.coordinates.y); if (CheckIfCellExists(static_map, cx, cy)) { if (result[cx, cy].owner_id != -1) { DynamicMap c = result[cx, cy]; bool created_already = false; for (int o = 0; o < influences.Count; o++) { if (influences[o].owner_id == c.owner_id) { influences[o] = new Influence { owner_id = influences[o].owner_id, quantity = influences[o].quantity + 1 }; created_already = true; } } if (!created_already) { influences.Add(new Influence { owner_id = c.owner_id, quantity = 0 }); } } } } } //Find the most influential player on this cell Influence influencer = new Influence { owner_id = d.owner_id, quantity = -1 }; for (int i = 0; i < influences.Count; i++) { if (influences[i].quantity > influencer.quantity) { influencer = influences[i]; } else if (influences[i].quantity == influencer.quantity) { int coin = Random.Range(0, 2); if (coin == 0) { influencer = influences[i]; } } } d.owner_id = influencer.owner_id; //} } } return(result); }
private void ShowStaticMap(double lat, double lon) { picBox.LoadAsync(StaticMap.GetMapUrl(lat, lon, picBox.Width, picBox.Height)); }
private IReadOnlyDictionary <string, string> GetProperties(DiscordGuild guild, WhConfig whConfig, string city, string weatherImageUrl) { var weather = Translator.Instance.GetWeather(GameplayCondition); var weatherKey = $"weather_{Convert.ToInt32(GameplayCondition)}"; var weatherEmoji = MasterFile.Instance.Emojis.ContainsKey(weatherKey) && GameplayCondition != WeatherCondition.None ? GameplayCondition.GetWeatherEmojiIcon() : string.Empty; var hasWeather = GameplayCondition != WeatherCondition.None; var gmapsLink = string.Format(Strings.GoogleMaps, Latitude, Longitude); var appleMapsLink = string.Format(Strings.AppleMaps, Latitude, Longitude); var wazeMapsLink = string.Format(Strings.WazeMaps, Latitude, Longitude); var scannerMapsLink = string.Format(whConfig.Urls.ScannerMap, Latitude, Longitude); var staticMapLink = StaticMap.GetUrl(whConfig.Urls.StaticMap, whConfig.StaticMaps["weather"], Latitude, Longitude, weatherImageUrl, PokemonTeam.All, null, Polygon); var gmapsLocationLink = UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, gmapsLink); var appleMapsLocationLink = UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, appleMapsLink); var wazeMapsLocationLink = UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, wazeMapsLink); var scannerMapsLocationLink = UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, scannerMapsLink); var address = new Location(null, city, Latitude, Longitude).GetAddress(whConfig); //var staticMapLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? staticMapLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, staticMapLink); const string defaultMissingValue = "?"; var dict = new Dictionary <string, string> { //Main properties { "id", Id.ToString() }, { "weather_condition", weather }, { "has_weather", Convert.ToString(hasWeather) }, { "weather", weather ?? defaultMissingValue }, { "weather_emoji", weatherEmoji ?? defaultMissingValue }, { "weather_img_url", weatherImageUrl }, { "wind_direction", WindDirection.ToString() }, { "wind_level", WindLevel.ToString() }, { "raid_level", RainLevel.ToString() }, { "cloud_level", CloudLevel.ToString() }, { "fog_level", FogLevel.ToString() }, { "snow_level", SnowLevel.ToString() }, { "warn_weather", Convert.ToString(WarnWeather ?? false) }, { "special_effect_level", SpecialEffectLevel.ToString() }, { "severity", Severity.ToString() }, //Location properties { "geofence", city ?? defaultMissingValue }, { "lat", Latitude.ToString() }, { "lng", Longitude.ToString() }, { "lat_5", Latitude.ToString("0.00000") }, { "lng_5", Longitude.ToString("0.00000") }, //Location links { "tilemaps_url", staticMapLink }, { "gmaps_url", gmapsLocationLink }, { "applemaps_url", appleMapsLocationLink }, { "wazemaps_url", wazeMapsLocationLink }, { "scanmaps_url", scannerMapsLocationLink }, { "address", address?.Address }, // Discord Guild properties { "guild_name", guild?.Name }, { "guild_img_url", guild?.IconUrl }, { "date_time", DateTime.Now.ToString() }, //Misc properties { "br", "\r\n" } }; return(dict); }
static StaticMap[,] SmoothStaticMap(StaticMap[,] smoothing_map) { Debug.Log("Smoothing map"); //Generates a map with perlin noise //No smoothness or validity int sy = smoothing_map.GetLength(1); int sx = smoothing_map.GetLength(0); StaticMap[,] smoothen_map = new StaticMap[sx, sy]; for (int y = 0; y < sy; y++) { for (int x = 0; x < sx; x++) { smoothen_map[x, y] = smoothing_map[x, y]; } } for (int y = 0; y < sy; y++) { for (int x = 0; x < sx; x++) { bool is_edge = false; Vector2[] neighbours = new Vector2[8]; neighbours[0] = new Vector2(x + 1, y); neighbours[1] = new Vector2(x - 1, y); neighbours[2] = new Vector2(x, y + 1); neighbours[3] = new Vector2(x, y - 1); neighbours[2] = new Vector2(x + 1, y + 1); neighbours[3] = new Vector2(x - 1, y - 1); neighbours[2] = new Vector2(x + 1, y - 1); neighbours[3] = new Vector2(x - 1, y + 1); //Clear cell if it is on edge foreach (Vector2 v in neighbours) { if (!CheckIfCellExists(smoothen_map, (int)v.x, (int)v.y)) { is_edge = true; } } if (is_edge) { smoothen_map[x, y].type = 0; } else { int land_around = 0; foreach (Vector2 v in neighbours) { if (smoothen_map[(int)v.x, (int)v.y].type == 1) { land_around++; } } bool is_water = false; int r = Random.Range(0, 100); int maximum; if (land_around == 0) { maximum = 100; } else if (land_around == 1) { maximum = 90; } else if (land_around == 2) { maximum = 70; } else if (land_around == 3) { maximum = 10; } //else if(land_around == 4) // maximum = 0; //else if(land_around == 5) // maximum = 0; //else if(land_around == 6) // maximum = 0; //else if(land_around == 7) // maximum = 0; else { maximum = 0; } if (r < maximum) { is_water = true; } if (is_water) { smoothen_map[x, y].type = 0; } } } } return(smoothen_map); }
private IReadOnlyDictionary <string, string> GetProperties(DiscordGuild guild, WhConfig whConfig, string city, GymDetailsData oldGym) { var exEmojiId = MasterFile.Instance.Emojis["ex"]; var exEmoji = string.IsNullOrEmpty(MasterFile.Instance.CustomEmojis["ex"]) ? exEmojiId > 0 ? string.Format(Strings.EmojiSchema, "ex", exEmojiId): "EX" : MasterFile.Instance.CustomEmojis["ex"]; var teamEmojiId = MasterFile.Instance.Emojis[Team.ToString().ToLower()]; var teamEmoji = string.IsNullOrEmpty(MasterFile.Instance.CustomEmojis[Team.ToString().ToLower()]) ? teamEmojiId > 0 ? string.Format(Strings.EmojiSchema, Team.ToString().ToLower(), teamEmojiId) : Team.ToString() : MasterFile.Instance.CustomEmojis[Team.ToString().ToLower()]; var oldTeamEmojiId = MasterFile.Instance.Emojis[oldGym?.Team.ToString().ToLower()]; var oldTeamEmoji = string.IsNullOrEmpty(MasterFile.Instance.CustomEmojis[oldGym?.Team.ToString().ToLower()]) ? oldTeamEmojiId > 0 ? string.Format(Strings.EmojiSchema, oldGym?.Team.ToString().ToLower(), oldTeamEmojiId) : oldGym?.Team.ToString() : MasterFile.Instance.CustomEmojis[oldGym.Team.ToString().ToLower()]; var gmapsLink = string.Format(Strings.GoogleMaps, Latitude, Longitude); var appleMapsLink = string.Format(Strings.AppleMaps, Latitude, Longitude); var wazeMapsLink = string.Format(Strings.WazeMaps, Latitude, Longitude); var scannerMapsLink = string.Format(whConfig.Urls.ScannerMap, Latitude, Longitude); var gymImageUrl = $"https://raw.githubusercontent.com/nileplumb/PkmnHomeIcons/ICONS/ICONS/gym/{Convert.ToInt32(Team)}.png"; // TODO: Build gym image url var staticMapLink = StaticMap.GetUrl(whConfig.Urls.StaticMap, whConfig.StaticMaps["gyms"], Latitude, Longitude, gymImageUrl); //var staticMapLink = string.Format(whConfig.Urls.StaticMap, Latitude, Longitude);//whConfig.Urls.StaticMap.Gyms.Enabled ? string.Format(whConfig.Urls.StaticMap.Gyms.Url, Latitude, Longitude) : string.Empty var gmapsLocationLink = UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, gmapsLink); var appleMapsLocationLink = UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, appleMapsLink); var wazeMapsLocationLink = UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, wazeMapsLink); var scannerMapsLocationLink = UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, scannerMapsLink); var address = new Location(null, city, Latitude, Longitude).GetAddress(whConfig); //var staticMapLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? staticMapLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, staticMapLink); const string defaultMissingValue = "?"; var dict = new Dictionary <string, string> { //Main properties { "gym_id", GymId }, { "gym_name", GymName }, { "gym_url", Url }, { "gym_team", Team.ToString() }, { "gym_team_id", Convert.ToInt32(Team).ToString() }, { "gym_team_emoji", teamEmoji }, { "old_gym_team", oldGym.Team.ToString() }, { "old_gym_team_id", Convert.ToInt32(oldGym.Team).ToString() }, { "old_gym_team_emoji", oldTeamEmoji }, { "team_changed", Convert.ToString(oldGym?.Team != Team) }, { "in_battle", Convert.ToString(InBattle) }, { "under_attack", Convert.ToString(InBattle) }, { "is_ex", Convert.ToString(SponsorId) }, { "ex_emoji", exEmoji }, { "slots_available", SlotsAvailable == 0 ? "Full" : SlotsAvailable == 6 ? "Empty" : SlotsAvailable.ToString("N0") }, //Location properties { "geofence", city ?? defaultMissingValue }, { "lat", Latitude.ToString() }, { "lng", Longitude.ToString() }, { "lat_5", Latitude.ToString("0.00000") }, { "lng_5", Longitude.ToString("0.00000") }, //Location links { "tilemaps_url", staticMapLink }, { "gmaps_url", gmapsLocationLink }, { "applemaps_url", appleMapsLocationLink }, { "wazemaps_url", wazeMapsLocationLink }, { "scanmaps_url", scannerMapsLocationLink }, { "address", address?.Address }, // Discord Guild properties { "guild_name", guild?.Name }, { "guild_img_url", guild?.IconUrl }, { "date_time", DateTime.Now.ToString() }, //Misc properties { "br", "\r\n" } }; return(dict); }
private IReadOnlyDictionary <string, string> GetProperties(MessageProperties properties)// DiscordGuild guild, WhConfig whConfig, string city, string pokemonImageUrl) { var pkmnInfo = MasterFile.GetPokemon(Id, FormId); var pkmnName = Translator.Instance.GetPokemonName(Id); var form = Translator.Instance.GetFormName(FormId); var costume = Translator.Instance.GetCostumeName(Costume); var gender = Gender.GetPokemonGenderIcon(); var genderEmoji = Gender.GetGenderEmojiIcon(); var level = Level; var size = Size?.ToString(); var weather = Weather?.ToString(); var hasWeather = Weather.HasValue && Weather != WeatherCondition.None; var isWeatherBoosted = pkmnInfo?.IsWeatherBoosted(Weather ?? WeatherCondition.None); var weatherKey = $"weather_{Convert.ToInt32(Weather ?? WeatherCondition.None)}"; var weatherEmoji = string.IsNullOrEmpty(MasterFile.Instance.CustomEmojis[weatherKey]) ? MasterFile.Instance.CustomEmojis.ContainsKey(weatherKey) && Weather != WeatherCondition.None ? (Weather ?? WeatherCondition.None).GetWeatherEmojiIcon() : string.Empty : MasterFile.Instance.CustomEmojis[weatherKey]; var move1 = int.TryParse(FastMove, out var fastMoveId) ? Translator.Instance.GetMoveName(fastMoveId) : "Unknown"; var move2 = int.TryParse(ChargeMove, out var chargeMoveId) ? Translator.Instance.GetMoveName(chargeMoveId) : "Unknown"; var type1 = pkmnInfo?.Types?[0]; var type2 = pkmnInfo?.Types?.Count > 1 ? pkmnInfo.Types?[1] : PokemonType.None; var type1Emoji = pkmnInfo?.Types?[0].GetTypeEmojiIcons(); var type2Emoji = pkmnInfo?.Types?.Count > 1 ? pkmnInfo?.Types?[1].GetTypeEmojiIcons() : string.Empty; var typeEmojis = $"{type1Emoji} {type2Emoji}"; var catchPokemon = IsDitto ? Translator.Instance.GetPokemonName(DisplayPokemonId ?? Id) : pkmnName; var isShiny = Shiny ?? false; var height = double.TryParse(Height, out var realHeight) ? Math.Round(realHeight).ToString() : ""; var weight = double.TryParse(Weight, out var realWeight) ? Math.Round(realWeight).ToString() : ""; var gmapsLink = string.Format(Strings.GoogleMaps, Latitude, Longitude); var appleMapsLink = string.Format(Strings.AppleMaps, Latitude, Longitude); var wazeMapsLink = string.Format(Strings.WazeMaps, Latitude, Longitude); var scannerMapsLink = string.Format(properties.Config.Urls.ScannerMap, Latitude, Longitude); var staticMapLink = StaticMap.GetUrl(properties.Config.Urls.StaticMap, properties.Config.StaticMaps["pokemon"], Latitude, Longitude, properties.ImageUrl); var gmapsLocationLink = UrlShortener.CreateShortUrl(properties.Config.ShortUrlApiUrl, gmapsLink); var appleMapsLocationLink = UrlShortener.CreateShortUrl(properties.Config.ShortUrlApiUrl, appleMapsLink); var wazeMapsLocationLink = UrlShortener.CreateShortUrl(properties.Config.ShortUrlApiUrl, wazeMapsLink); var scannerMapsLocationLink = UrlShortener.CreateShortUrl(properties.Config.ShortUrlApiUrl, scannerMapsLink); var address = new Location(null, properties.City, Latitude, Longitude).GetAddress(properties.Config); //var staticMapLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? staticMapLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, staticMapLink); var pokestop = Pokestop.Pokestops.ContainsKey(PokestopId) ? Pokestop.Pokestops[PokestopId] : null; var greatLeagueEmoji = PvPLeague.Great.GetLeagueEmojiIcon(); var ultraLeagueEmoji = PvPLeague.Ultra.GetLeagueEmojiIcon(); var pvpStats = GetPvP(); const string defaultMissingValue = "?"; var dict = new Dictionary <string, string> { // Main properties { "pkmn_id", Convert.ToString(Id) }, { "pkmn_id_3", Id.ToString("D3") }, { "pkmn_name", pkmnName }, { "pkmn_img_url", properties.ImageUrl }, { "form", form }, { "form_id", Convert.ToString(FormId) }, { "form_id_3", FormId.ToString("D3") }, { "costume", costume ?? defaultMissingValue }, { "costume_id", Convert.ToString(Costume) }, { "costume_id_3", Costume.ToString("D3") }, { "cp", CP ?? defaultMissingValue }, { "lvl", level ?? defaultMissingValue }, { "gender", gender }, { "gender_emoji", genderEmoji }, { "size", size ?? defaultMissingValue }, { "move_1", move1 ?? defaultMissingValue }, { "move_2", move2 ?? defaultMissingValue }, { "moveset", $"{move1}/{move2}" }, { "type_1", type1?.ToString() ?? defaultMissingValue }, { "type_2", type2?.ToString() ?? defaultMissingValue }, { "type_1_emoji", type1Emoji }, { "type_2_emoji", type2Emoji }, { "types", $"{type1} | {type2}" }, { "types_emoji", typeEmojis }, { "atk_iv", Attack ?? defaultMissingValue }, { "def_iv", Defense ?? defaultMissingValue }, { "sta_iv", Stamina ?? defaultMissingValue }, { "iv", IV ?? defaultMissingValue }, { "iv_rnd", IVRounded ?? defaultMissingValue }, { "is_shiny", Convert.ToString(isShiny) }, // Catch rate properties { "has_capture_rates", Convert.ToString(CatchRate1.HasValue && CatchRate2.HasValue && CatchRate3.HasValue) }, { "capture_1", CatchRate1.HasValue ? Math.Round(CatchRate1.Value * 100).ToString() : string.Empty }, { "capture_2", CatchRate2.HasValue ? Math.Round(CatchRate2.Value * 100).ToString() : string.Empty }, { "capture_3", CatchRate3.HasValue ? Math.Round(CatchRate3.Value * 100).ToString() : string.Empty }, { "capture_1_emoji", CaptureRateType.PokeBall.GetCaptureRateEmojiIcon() }, { "capture_2_emoji", CaptureRateType.GreatBall.GetCaptureRateEmojiIcon() }, { "capture_3_emoji", CaptureRateType.UltraBall.GetCaptureRateEmojiIcon() }, // PvP stat properties { "is_great", Convert.ToString(MatchesGreatLeague) }, { "is_ultra", Convert.ToString(MatchesUltraLeague) }, { "is_pvp", Convert.ToString(MatchesGreatLeague || MatchesUltraLeague) }, //{ "great_league_stats", greatLeagueStats }, //{ "ultra_league_stats", ultraLeagueStats }, { "great_league_emoji", greatLeagueEmoji }, { "ultra_league_emoji", ultraLeagueEmoji }, { "pvp_stats", pvpStats }, // Other properties { "height", height ?? defaultMissingValue }, { "weight", weight ?? defaultMissingValue }, { "is_ditto", Convert.ToString(IsDitto) }, { "original_pkmn_id", Convert.ToString(DisplayPokemonId) }, { "original_pkmn_id_3", (DisplayPokemonId ?? 0).ToString("D3") }, { "original_pkmn_name", catchPokemon }, { "is_weather_boosted", Convert.ToString(isWeatherBoosted) }, { "has_weather", Convert.ToString(hasWeather) }, { "weather", weather ?? defaultMissingValue }, { "weather_emoji", weatherEmoji ?? defaultMissingValue }, { "username", Username ?? defaultMissingValue }, { "spawnpoint_id", SpawnpointId ?? defaultMissingValue }, { "encounter_id", EncounterId ?? defaultMissingValue }, // Time properties { "despawn_time", DespawnTime.ToString("hh:mm:ss tt") }, { "despawn_time_24h", DespawnTime.ToString("HH:mm:ss") }, { "despawn_time_verified", DisappearTimeVerified ? "" : "~" }, { "is_despawn_time_verified", Convert.ToString(DisappearTimeVerified) }, { "time_left", SecondsLeft.ToReadableString(true) ?? defaultMissingValue }, // Location properties { "geofence", properties.City ?? defaultMissingValue }, { "lat", Convert.ToString(Latitude) }, { "lng", Convert.ToString(Longitude) }, { "lat_5", Latitude.ToString("0.00000") }, { "lng_5", Longitude.ToString("0.00000") }, // Location links { "tilemaps_url", staticMapLink }, { "gmaps_url", gmapsLocationLink }, { "applemaps_url", appleMapsLocationLink }, { "wazemaps_url", wazeMapsLocationLink }, { "scanmaps_url", scannerMapsLocationLink }, { "address", address?.Address }, // Pokestop properties { "near_pokestop", Convert.ToString(pokestop != null) }, { "pokestop_id", PokestopId ?? defaultMissingValue }, { "pokestop_name", pokestop?.Name ?? defaultMissingValue }, { "pokestop_url", pokestop?.Url ?? defaultMissingValue }, // Discord Guild properties { "guild_name", properties.Guild?.Name }, { "guild_img_url", properties.Guild?.IconUrl }, // Event properties { "is_event", Convert.ToString(IsEvent.HasValue && IsEvent.Value) }, { "date_time", DateTime.Now.ToString() }, // Misc properties { "br", "\r\n" } }; return(dict); }
public IActionResult _Accomodation(string ProductId) { ProductsPDPViewModel model = new ProductsPDPViewModel(); //model.MenuViewModel.QRFID = Request.Query["QRFId"].ToString(); //model.MenuViewModel.MenuName = "Accomodation"; model.ImageInitial = _configuration.GetValue <string>("SystemSettings:CountryImageInitial"); #region Get Costing Officer Tour Info Header By QRFId //NewQuoteViewModel modelQuote = new NewQuoteViewModel { QRFID = "255" }; //model.COHeaderViewModel = coCommonLibrary.GetCOTourInfoHeader(ref modelQuote, token); //model.MenuViewModel.EnquiryPipeline = modelQuote.mdlMenuViewModel.EnquiryPipeline; #endregion #region Get Product Info from service //string ProductId = Request.Query["ProductId"].ToString(); ProductPDPSearchRes ProductPDP = productProviders.GetProductPDPDetails(new List <string> { ProductId }, token).Result; if (ProductPDP.ProductDetails?.Count > 0) { model.Products = ProductPDP.ProductDetails.FirstOrDefault(); } model.KeyFacilities = GetKeyFacilities(); StaticMap._configuration = _configuration; //GeocoderLocation geocoder = null; string Landmark, mapURL = "https://maps.googleapis.com/maps/api/staticmap?zoom=10&size=640x416&maptype=roadmap&key=GoogleAPIKey"; mapURL += "&markers=color:red|label:" + model.Products.ProductName.Substring(0, 1) + "|{0},{1}"; mapURL = string.Format(mapURL, model.Products.Lat, model.Products.Long); //model.Products.InAndAround.Add(new InAndAround //{ // LandmarkName = "British Museum", // LandmarkType = "Attraction", // Direction = "south", // Distance = "10", // DistanceUnit = "km", //}); foreach (var item in model.Products.InAndAround) { Landmark = item.LandmarkName + "," + model.Products.CityName + "," + model.Products.CountryName; //geocoder = StaticMap.Locate(Landmark); //if (geocoder.Latitude != 0 && geocoder.Longitude != 0) //{ mapURL += "&markers=color:blue|label:" + item.LandmarkName.Substring(0, 1) + "|" + Landmark; //mapURL = string.Format(mapURL, geocoder.Latitude, geocoder.Longitude); //} } if (StaticMap.RenderImage(mapURL, model.Products.VoyagerProduct_Id + "_PDP_hotelmap.png", out string output)) { model.ProductMapUrl = output; } #endregion #region replacing image urls from resources to ImageResources if (model.Products != null) { foreach (var ProdResource in model.Products.ProductResources) { if (ProdResource.ImageSRC != null) { ProdResource.ImageSRC = ProdResource.ImageSRC.Replace("resources/", "ImageResources/"); } } } #endregion return(View(model)); }
public void ConstructorSetsSolidTileValueFromTileset() { var map = new StaticMap(new TmxMap(PathToSolidTilesetMap)); Assert.That(map.Tiles.Any(t => t.IsSolid)); }
/// <summary> /// Get key values for a given key. /// </summary> /// <param name="keyFields">Fields in the key.</param> /// <param name="data">Data from which to get key values.</param> /// <param name="excludeNulls">>Indicates whether to exclude key values where the last field value is null.</param> /// <param name="keyValueBuilder">String builder which can build key values.</param> /// <returns>Key values for the key.</returns> public static IEnumerable <string> GetKeyValues(IEnumerable <IField> keyFields, IEnumerable <IEnumerable <IDataObjectBase> > data, bool excludeNulls, StringBuilder keyValueBuilder = null) { if (keyFields == null) { throw new ArgumentNullException("keyFields"); } if (data == null) { throw new ArgumentNullException("data"); } if (keyValueBuilder == null) { keyValueBuilder = new StringBuilder(); } var getFields = new List <IField>(keyFields); try { var keyValues = new Collection <string>(); foreach (var dataRow in data) { var dataObjects = new List <IDataObjectBase>(dataRow); try { keyValueBuilder.Clear(); foreach (var field in getFields) { var dataObject = GetDataObject(dataObjects, field); var dataObjectType = dataObject.Field.DatatypeOfTarget; IMap mapper = null; if (excludeNulls && field.Equals(getFields.Last())) { if (dataObjectType == typeof(string)) { mapper = new StaticMap <string, string>(); ((IStaticMap <string, string>)mapper).AddRule(string.Empty, null); } if (dataObjectType.IsGenericType && dataObjectType.GetGenericTypeDefinition() == typeof(Nullable <>)) { mapper = (IMap)Activator.CreateInstance(typeof(StaticMap <,>).MakeGenericType(new[] { dataObjectType, dataObjectType })); var addRuleMethod = mapper.GetType().GetMethod("AddRule", new[] { dataObjectType, dataObjectType }); if (dataObjectType == typeof(long?)) { const long defaultValue = 0; addRuleMethod.Invoke(mapper, new object[] { defaultValue, null }); } else if (dataObjectType == typeof(int?)) { const int defaultValue = 0; addRuleMethod.Invoke(mapper, new object[] { defaultValue, null }); } else { throw new DeliveryEngineSystemException(Resource.GetExceptionMessage(ExceptionMessage.DataTypeNotSupported, dataObjectType.Name)); } } } var getValueMethod = dataObject.GetType() .GetMethod("GetTargetValue", new[] { typeof(IMap) }) .MakeGenericMethod(new[] { dataObjectType }); if (keyValueBuilder.Length > 0) { keyValueBuilder.Append('|'); } try { var value = getValueMethod.Invoke(dataObject, new object[] { mapper }); if (Equals(value, null)) { keyValueBuilder.Append("{null}"); continue; } keyValueBuilder.Append(value); } catch (TargetInvocationException ex) { var deliveryEngineException = ex.InnerException as DeliveryEngineExceptionBase; if (deliveryEngineException != null) { throw ex.InnerException; } throw new DeliveryEngineSystemException(Resource.GetExceptionMessage(ExceptionMessage.UnableToGetValueForField, dataObject.Field.NameTarget, dataObject.Field.Table.NameTarget, ex.InnerException.Message), ex.InnerException); } } var keyValue = (string)keyValueBuilder.ToString().Clone(); if (excludeNulls == false || keyValue.EndsWith("{null}") == false) { keyValues.Add(keyValue); } } finally { while (dataObjects.Count > 0) { dataObjects.Clear(); } } } return(keyValues); } finally { while (getFields.Count > 0) { getFields.Clear(); } } }
private IReadOnlyDictionary <string, string> GetProperties(DiscordGuild guild, WhConfig whConfig, string city, bool useLure, bool useInvasion) { var lureImageUrl = IconFetcher.Instance.GetLureIcon(whConfig.Servers[guild.Id].IconStyle, LureType); var invasionImageUrl = IconFetcher.Instance.GetInvasionIcon(whConfig.Servers[guild.Id].IconStyle, GruntType); var imageUrl = useInvasion ? invasionImageUrl : useLure ? lureImageUrl : Url; var gmapsLink = string.Format(Strings.GoogleMaps, Latitude, Longitude); var appleMapsLink = string.Format(Strings.AppleMaps, Latitude, Longitude); var wazeMapsLink = string.Format(Strings.WazeMaps, Latitude, Longitude); var scannerMapsLink = string.Format(whConfig.Urls.ScannerMap, Latitude, Longitude); var staticMapLink = StaticMap.GetUrl(whConfig.Urls.StaticMap, useInvasion ? whConfig.StaticMaps["invasions"] : useLure ? whConfig.StaticMaps["lures"] : /* TODO: */ "", Latitude, Longitude, imageUrl); var gmapsLocationLink = UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, gmapsLink); var appleMapsLocationLink = UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, appleMapsLink); var wazeMapsLocationLink = UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, wazeMapsLink); var scannerMapsLocationLink = UrlShortener.CreateShortUrl(whConfig.ShortUrlApiUrl, scannerMapsLink); var address = new Location(null, city, Latitude, Longitude).GetAddress(whConfig); //var staticMapLocationLink = string.IsNullOrEmpty(whConfig.ShortUrlApiUrl) ? staticMapLink : NetUtil.CreateShortUrl(whConfig.ShortUrlApiUrl, staticMapLink); var invasion = MasterFile.Instance.GruntTypes.ContainsKey(GruntType) ? MasterFile.Instance.GruntTypes[GruntType] : null; var leaderString = Translator.Instance.Translate("grunt_" + Convert.ToInt32(GruntType)); var pokemonType = MasterFile.Instance.GruntTypes.ContainsKey(GruntType) ? Notifications.GetPokemonTypeFromString(invasion?.Type) : PokemonType.None; var invasionTypeEmoji = pokemonType == PokemonType.None ? leaderString : pokemonType.GetTypeEmojiIcons(); var invasionEncounters = GruntType > 0 ? invasion.GetPossibleInvasionEncounters() : string.Empty; var now = DateTime.UtcNow.ConvertTimeFromCoordinates(Latitude, Longitude); var lureExpireTimeLeft = now.GetTimeRemaining(LureExpireTime).ToReadableStringNoSeconds(); var invasionExpireTimeLeft = now.GetTimeRemaining(InvasionExpireTime).ToReadableStringNoSeconds(); const string defaultMissingValue = "?"; var dict = new Dictionary <string, string> { //Main properties { "has_lure", Convert.ToString(HasLure) }, { "lure_type", LureType.ToString() }, { "lure_expire_time", LureExpireTime.ToLongTimeString() }, { "lure_expire_time_24h", LureExpireTime.ToString("HH:mm:ss") }, { "lure_expire_time_left", lureExpireTimeLeft }, { "has_invasion", Convert.ToString(HasInvasion) }, { "grunt_type", invasion?.Type }, { "grunt_type_emoji", invasionTypeEmoji }, { "grunt_gender", invasion?.Grunt }, { "invasion_expire_time", InvasionExpireTime.ToLongTimeString() }, { "invasion_expire_time_24h", InvasionExpireTime.ToString("HH:mm:ss") }, { "invasion_expire_time_left", invasionExpireTimeLeft }, { "invasion_encounters", $"**Encounter Reward Chance:**\r\n" + invasionEncounters }, //Location properties { "geofence", city ?? defaultMissingValue }, { "lat", Latitude.ToString() }, { "lng", Longitude.ToString() }, { "lat_5", Latitude.ToString("0.00000") }, { "lng_5", Longitude.ToString("0.00000") }, //Location links { "tilemaps_url", staticMapLink }, { "gmaps_url", gmapsLocationLink }, { "applemaps_url", appleMapsLocationLink }, { "wazemaps_url", wazeMapsLocationLink }, { "scanmaps_url", scannerMapsLocationLink }, //Pokestop properties { "pokestop_id", PokestopId ?? defaultMissingValue }, { "pokestop_name", Name ?? defaultMissingValue }, { "pokestop_url", Url ?? defaultMissingValue }, { "lure_img_url", lureImageUrl }, { "invasion_img_url", invasionImageUrl }, { "address", address?.Address }, // Discord Guild properties { "guild_name", guild?.Name }, { "guild_img_url", guild?.IconUrl }, { "date_time", DateTime.Now.ToString() }, //Misc properties { "br", "\r\n" } }; return(dict); }
private void updateMap() { var result = (GeocodingResult)currentSelectedLocation; fullAddress.Text = result.FormattedAddress; var location = result.Geometry.Location; var map = new StaticMap(); map.Center = location.Latitude.ToString() + "," +location.Longitude.ToString(); txtLatitude.Text = location.Latitude.ToString(); txtLongitude.Text = location.Longitude.ToString(); map.Zoom = (zoomLevels.SelectedItem == null) ? "10" : zoomLevels.Text.ToString(); map.Markers = map.Center; map.Size = "1000" + "x" + "485"; map.MapType = (mapTypeCombo.SelectedItem == null) ? "roadmap" : mapTypeCombo.Text.ToString(); map.Sensor = "false"; String urlToMap = map.ToUri().AbsoluteUri.ToString(); mapViewer.Navigate(urlToMap); }