2424 using WhMgr . Services ;
2525 using WhMgr . Services . Alarms . Embeds ;
2626 using WhMgr . Services . Geofence ;
27+ using WhMgr . Services . Geofence . Geocoding ;
2728 using WhMgr . Services . Icons ;
2829 using WhMgr . Services . StaticMap ;
2930
@@ -197,41 +198,36 @@ public DiscordEmbed GenerateEmbedMessage(ulong guildId, DiscordClient client, Ne
197198
198199 public dynamic GetProperties ( DiscordGuild guild , Nest nest , string pokemonImageUrl )
199200 {
201+ var config = _config . Instance ;
200202 var pkmnInfo = GameMaster . GetPokemon ( nest . PokemonId ) ;
201203 var pkmnImage = pokemonImageUrl ;
202204 var nestName = nest . Name ?? "Unknown" ;
203- var type1 = pkmnInfo ? . Types ? [ 0 ] ;
204- var type2 = pkmnInfo ? . Types ? . Count > 1 ? pkmnInfo . Types ? [ 1 ] : PokemonType . None ;
205- var type1Emoji = pkmnInfo ? . Types ? [ 0 ] . GetTypeEmojiIcons ( ) ;
206- var type2Emoji = pkmnInfo ? . Types ? . Count > 1 ? pkmnInfo ? . Types ? [ 1 ] . GetTypeEmojiIcons ( ) : string . Empty ;
207- var typeEmojis = $ "{ type1Emoji } { type2Emoji } ";
205+ var types = pkmnInfo ? . Types ;
206+ var type1 = types ? . Count >= 1
207+ ? types [ 0 ]
208+ : PokemonType . None ;
209+ var type2 = types ? . Count > 1
210+ ? types [ 1 ]
211+ : PokemonType . None ;
212+ var typeEmojis = types ? . GetTypeEmojiIcons ( ) ?? string . Empty ;
208213 var gmapsLink = string . Format ( Strings . Defaults . GoogleMaps , nest . Latitude , nest . Longitude ) ;
209214 var appleMapsLink = string . Format ( Strings . Defaults . AppleMaps , nest . Latitude , nest . Longitude ) ;
210215 var wazeMapsLink = string . Format ( Strings . Defaults . WazeMaps , nest . Latitude , nest . Longitude ) ;
211- var scannerMapsLink = string . Format ( _config . Instance . Urls . ScannerMap , nest . Latitude , nest . Longitude ) ;
216+ var scannerMapsLink = string . Format ( config . Urls . ScannerMap , nest . Latitude , nest . Longitude ) ;
217+ var address = ReverseGeocodingLookup . Instance . GetAddressAsync ( new Coordinate ( nest ) ) . Result ;
212218
213- //pkmnImage,
214219 var osmNest = _osmManager . GetNest ( nest . Name ) ? . FirstOrDefault ( ) ;
215220 var polygonPath = OsmManager . MultiPolygonToLatLng ( osmNest ? . Geometry ? . Coordinates , true ) ;
216- var staticMapConfig = _config . Instance . StaticMaps ;
217- var staticMap = new StaticMapGenerator ( new StaticMapOptions
218- {
219- BaseUrl = staticMapConfig . Url ,
220- MapType = StaticMapType . Nests ,
221- TemplateType = staticMapConfig . Type == StaticMapTemplateType . StaticMap
222- ? StaticMapTemplateType . StaticMap
223- : StaticMapTemplateType . MultiStaticMap ,
224- Latitude = nest . Latitude ,
225- Longitude = nest . Longitude ,
226- SecondaryImageUrl = pokemonImageUrl ,
227- PolygonPath = polygonPath ,
228- Pregenerate = staticMapConfig . Pregenerate ,
229- Regeneratable = true ,
230- } ) ;
231- var staticMapLink = staticMap . GenerateLink ( ) ;
232- var geofence = GeofenceService . GetGeofence ( _config . Instance . Servers [ guild . Id ] . Geofences , new Coordinate ( nest ) ) ;
221+ var staticMapLink = config . StaticMaps ? . GenerateStaticMap (
222+ StaticMapType . Nests ,
223+ nest ,
224+ pokemonImageUrl ,
225+ null ,
226+ null ,
227+ polygonPath
228+ ) ;
229+ var geofence = GeofenceService . GetGeofence ( config . Servers [ guild . Id ] . Geofences , new Coordinate ( nest ) ) ;
233230 var city = geofence ? . Name ?? "Unknown" ;
234- //var address = new Coordinate(city, nest.Latitude, nest.Longitude).GetAddress(_config.Instance);
235231
236232 var dict = new
237233 {
@@ -244,8 +240,6 @@ public dynamic GetProperties(DiscordGuild guild, Nest nest, string pokemonImageU
244240 nest_name = nestName ,
245241 type_1 = Convert . ToString ( type1 ) ,
246242 type_2 = Convert . ToString ( type2 ) ,
247- type_1_emoji = type1Emoji ,
248- type_2_emoji = type2Emoji ,
249243 types = $ "{ type1 } | { type2 } ",
250244 types_emojis = typeEmojis ,
251245
@@ -265,7 +259,7 @@ public dynamic GetProperties(DiscordGuild guild, Nest nest, string pokemonImageU
265259 wazemaps_url = wazeMapsLink ,
266260 scanmaps_url = scannerMapsLink ,
267261
268- // address = address?.Address ,
262+ address = address ?? string . Empty ,
269263
270264 // Discord Guild properties
271265 guild_name = guild ? . Name ,
0 commit comments