/// <summary> /// Create a new geographical coordinate or position on a map. /// </summary> /// <param name="Latitude">The Latitude (south to nord).</param> /// <param name="Longitude">The Longitude (parallel to equator).</param> /// <param name="Altitude">The (optional) Altitude.</param> /// <param name="Name">An optional name for this geo location.</param> public AdditionalGeoLocation(Latitude Latitude, Longitude Longitude, Altitude? Altitude = null, I18NString Name = null) { this.Name = Name != null ? Name : new I18NString(); }
public Arc( Longitude longitudeDifference, Latitude latitudeDifference) { LongitudeDifference = longitudeDifference; LatitudeDifference = latitudeDifference; }
/// <summary> /// Create a new abstract shape. /// </summary> /// <param name="Id">The Id of the shape.</param> /// <param name="Latitude">The latitude of the shape center.</param> /// <param name="Longitude">The longitude of the shape center.</param> /// <param name="Altitude">The altitude of the shape center.</param> /// <param name="GeoWidth">The geographical width of the shape center.</param> /// <param name="GeoHeight">The geographical height of the shape center.</param> public AShape(String[] Geometries, Latitude Latitude, Longitude Longitude, Altitude Altitude, Latitude Latitude2, Longitude Longitude2, Color StrokeColor, Double StrokeThickness, Color FillColor) { this.Id = Id; this.Latitude = Latitude; this.Longitude = Longitude; this.Altitude = Altitude; this.Latitude2 = Latitude2; this.Longitude2 = Longitude2; var PathGeometry16 = PathGeometry.Parse(Geometries[8]); var GD16 = new GeometryDrawing(new SolidColorBrush(FillColor), new Pen(new SolidColorBrush(StrokeColor), StrokeThickness), PathGeometry16); var DrawingGroup = new DrawingGroup(); DrawingGroup.Children.Add(GD16); this.Fill = new DrawingBrush() { Drawing = DrawingGroup, //Viewport = new Rect(0, 0, 1, 1), TileMode = TileMode.None, Stretch = Stretch.UniformToFill }; Bounds = DrawingGroup.Bounds; var w = Bounds.Width; var h = Bounds.Height; }
public GeoBoundingBox(Latitude Latitude, Longitude Longitude, Latitude Latitude2, Longitude Longitude2) : this(Latitude, Longitude, new Altitude(0), Latitude2, Longitude2, new Altitude(0)) { }
public void HemisphereAngleConstructorTest1() { Angle angle = new Angle(0); Latitude latitude = new Latitude(angle,CardinalDirection.South); Assert.AreEqual(angle, latitude.Value); Assert.AreEqual(angle, latitude.RawValue); }
/// <summary> /// Create a new abstract shape. /// </summary> /// <param name="Id">The Id of the shape.</param> /// <param name="Latitude">The latitude of the shape center.</param> /// <param name="Longitude">The longitude of the shape center.</param> /// <param name="Altitude">The altitude of the shape center.</param> /// <param name="GeoWidth">The geographical width of the shape center.</param> /// <param name="GeoHeight">The geographical height of the shape center.</param> public AShape(String Id, Latitude Latitude, Longitude Longitude, Altitude Altitude, Latitude Latitude2, Longitude Longitude2) { this.Id = Id; this.Latitude = Latitude; this.Longitude = Longitude; this.Altitude = Altitude; this.Latitude2 = Latitude2; this.Longitude2 = Longitude2; }
public void GeoCoordinateInitializerTest() { var Random = new Random(); var RandomLatitude = new Latitude ((Random.NextDouble() - 0.5) * 180); var RandomLongitude = new Longitude((Random.NextDouble() - 0.5) * 180); var GeoCoordinate1 = new GeoCoordinate(RandomLatitude, RandomLongitude); Assert.AreEqual(RandomLatitude.Value, GeoCoordinate1.Latitude.Value, 0.0000001); Assert.AreEqual(RandomLongitude.Value, GeoCoordinate1.Longitude.Value, 0.0000001); }
/// <summary> /// Add a map feature of the given dimensions at the given geo coordinate. /// </summary> /// <param name="Id">The unique identification of the feature.</param> /// <param name="Latitude">The latitude of the feature.</param> /// <param name="Longitude">The longitude of the feature.</param> /// <param name="Width">The longitude of the feature.</param> /// <param name="Height">The longitude of the feature.</param> /// <param name="Fill">The fill brush of the feature.</param> /// <param name="Stroke">The stroke brush of the feature.</param> /// <param name="StrokeThickness">The thickness of the stroke.</param> public Feature AddFeature(String Id, Latitude Latitude, Longitude Longitude, Double Width, Double Height, Color Color) { return AddFeature(Id, new GeoCoordinate(Latitude, Longitude), Width, Height, Color); }
/// <summary> /// Creates a new instance from a specified <see cref="Latitude"/> and <see cref="Longitude"/> /// </summary> /// <param name="longitude"></param> /// <param name="latitude"></param> public Position(Longitude longitude,Latitude latitude) { if (longitude == null) { throw new ArgumentNullException("longitude"); } if (latitude == null) { throw new ArgumentNullException("latitude"); } Longitude = longitude; Latitude = latitude; }
/// <summary> /// Add a map feature of the given dimensions at the given geo coordinate. /// </summary> /// <param name="Id">The unique identification of the feature.</param> /// <param name="Latitude">The latitude of the feature.</param> /// <param name="Longitude">The longitude of the feature.</param> /// <param name="Width">The longitude of the feature.</param> /// <param name="Height">The longitude of the feature.</param> /// <param name="Fill">The fill brush of the feature.</param> /// <param name="Stroke">The stroke brush of the feature.</param> /// <param name="StrokeThickness">The thickness of the stroke.</param> public Feature AddFeature(String Id, Latitude Latitude, Longitude Longitude, Double Width, Double Height, Brush Fill, Brush Stroke, Double StrokeThickness) { return AddFeature(Id, new GeoCoordinate(Latitude, Longitude), Width, Height, Fill, Stroke, StrokeThickness); }
public Feature AddPath(String Id, Latitude Latitude, Longitude Longitude, Double Width, Double Height, Color Color) { var XY = GeoCalculations.GeoCoordinate2ScreenXY(Latitude, Longitude, MapControl.ZoomLevel); var PathGeometry1 = PathGeometry.Parse("M51,42c-5-4-11-7-19-7c-6,0-12,1-20,5l10-35c20-8,30-4,39,2l-10,35z"); var PathGeometry2 = PathGeometry.Parse("M106,13c-21,9-31,4-40-2l-10,35c9,6,20,11,40,2l10-35z"); var PathGeometry3 = PathGeometry.Parse("M39,83c-9-6-18-10-39-2l10-35c21-9,31-4,39,2l-10,35z"); var PathGeometry4 = PathGeometry.Parse("M55,52c9,6,18,10,39,2l-10,35c-21,8-30,3-39-3l10-34z"); var pathText = PathGeometry1.ToString(); var GD1 = new GeometryDrawing(new SolidColorBrush(Color.FromRgb(0xE0, 0x60, 0x30)), null, PathGeometry1); var GD2 = new GeometryDrawing(new SolidColorBrush(Color.FromRgb(0x70, 0xB0, 0x40)), null, PathGeometry2); var GD3 = new GeometryDrawing(new SolidColorBrush(Color.FromRgb(0x40, 0x90, 0xc0)), null, PathGeometry3); var GD4 = new GeometryDrawing(new SolidColorBrush(Color.FromRgb(0xF0, 0xD0, 0x50)), null, PathGeometry4); var DrawingGroup = new DrawingGroup(); DrawingGroup.Children.Add(GD1); DrawingGroup.Children.Add(GD2); DrawingGroup.Children.Add(GD3); DrawingGroup.Children.Add(GD4); var DrawingBrush = new DrawingBrush() { Drawing = DrawingGroup, TileMode = TileMode.None }; var Feature = new Feature(Id, new RectangleGeometry() { Rect = DrawingGroup.Bounds }) { Latitude = Latitude, Longitude = Longitude, Width = DrawingGroup.Bounds.Width, Height = DrawingGroup.Bounds.Height, Fill = DrawingBrush, ToolTip = Id }; // The position on the map will be set within the PaintMap() method! this.Children.Add(Feature); return Feature; }
public GeoBoundingBox(Latitude Latitude, Longitude Longitude, Altitude Altitude, Latitude Latitude2, Longitude Longitude2, Altitude Altitude2) { this.GeoCoordinate1 = new GeoCoordinate(Latitude, Longitude, Altitude); this.Latitude = Latitude; this.Longitude = Longitude; this.Altitude = Altitude; this.GeoCoordinate2 = new GeoCoordinate(Latitude2, Longitude2, Altitude2); this.Latitude2 = Latitude2; this.Longitude2 = Longitude2; this.Altitude2 = Altitude2; this.GeoWidth = GeoCoordinate1.DistanceKM(new GeoCoordinate(GeoCoordinate1.Latitude, GeoCoordinate2.Longitude)); // Longitude West <-> East this.GeoHeight = GeoCoordinate1.DistanceKM(new GeoCoordinate(GeoCoordinate2.Latitude, GeoCoordinate1.Longitude)); // Latitude North <-> South this.GeoAlitude = Altitude2. Value - Altitude. Value; }
/// <summary> /// Converts the given world coordinates and zoom level to the X and Y number of map tiles. /// </summary> /// <param name="Latitude">The latitude.</param> /// <param name="Longitude">The longitude.</param> /// <param name="ZoomLevel">The ZoomLevel.</param> /// <returns>The TileX and TileY number as a tuple.</returns> public static Tuple<UInt64, UInt64> WorldCoordinates_2_Tile(Latitude Latitude, Longitude Longitude, UInt32 ZoomLevel) { return new Tuple<UInt64, UInt64>( (UInt64) Math.Floor(((Longitude.Value + 180.0) / 360.0) * (1 << (Int32) ZoomLevel)), (UInt64) Math.Floor((1.0 - Math.Log ( Math.Tan(Latitude.Value * Math.PI / 180.0) + 1.0 / Math.Cos(Latitude.Value * Math.PI / 180.0) ) / Math.PI) / 2.0 * (1 << (Int32) ZoomLevel)) ); }
public void RawAngleConstructorTest5() { Angle angle = new Angle(-90); Latitude latitude = new Latitude(angle); Assert.AreEqual(CardinalDirection.South, latitude.Hemisphere); Assert.AreEqual(-angle, latitude.Value); Assert.AreEqual(angle, latitude.RawValue); }
public override XElement ToKml() { var element = new XElement("Point"); var coordinatesElement = new XElement("coordinates"); var coordinate = string.Format("{0},{1}", Longitude.ToString(CultureInfo.InvariantCulture), Latitude.ToString(CultureInfo.InvariantCulture)); coordinatesElement.Value = coordinate; element.Add(coordinatesElement); return(element); }
public override int GetHashCode() { int hash = 1; if (Id.Length != 0) { hash ^= Id.GetHashCode(); } if (LastModifiedTimestampMs != 0L) { hash ^= LastModifiedTimestampMs.GetHashCode(); } if (Latitude != 0D) { hash ^= Latitude.GetHashCode(); } if (Longitude != 0D) { hash ^= Longitude.GetHashCode(); } if (Enabled != false) { hash ^= Enabled.GetHashCode(); } if (Type != 0) { hash ^= Type.GetHashCode(); } if (OwnedByTeam != 0) { hash ^= OwnedByTeam.GetHashCode(); } if (GuardPokemonId != 0) { hash ^= GuardPokemonId.GetHashCode(); } if (GuardPokemonCp != 0) { hash ^= GuardPokemonCp.GetHashCode(); } if (GymPoints != 0L) { hash ^= GymPoints.GetHashCode(); } if (IsInBattle != false) { hash ^= IsInBattle.GetHashCode(); } if (CooldownCompleteTimestampMs != 0L) { hash ^= CooldownCompleteTimestampMs.GetHashCode(); } if (Sponsor != 0) { hash ^= Sponsor.GetHashCode(); } if (RenderingType != 0) { hash ^= RenderingType.GetHashCode(); } if (ActiveFortModifier.Length != 0) { hash ^= ActiveFortModifier.GetHashCode(); } if (lureInfo_ != null) { hash ^= LureInfo.GetHashCode(); } return(hash); }
public override string ToString() => Latitude.ToString("0.000000") + ";" + Longitude.ToString("0.000000");
/// <summary> /// Compares the current instance to the specified position using the specified numeric precision. /// </summary> /// <param name="value">A <strong>Position</strong> object to compare with.</param> /// <param name="decimals">An <strong>Integer</strong> specifying the number of fractional digits to compare.</param> /// <returns>A <strong>Boolean</strong>, <strong>True</strong> if the values are identical.</returns> /// <remarks>This method is typically used when positions do not mark the same location unless they are /// extremely close to one another. Conversely, a low or even negative value for <strong>Precision</strong> /// allows positions to be considered equal even when they do not precisely match.</remarks> public bool Equals(Position3D other, int decimals) { return(Latitude.Equals(other.Latitude, decimals) && Longitude.Equals(other.Longitude, decimals) && _Altitude.Equals(other.Altitude, decimals)); }
public void ReadXml(XmlReader reader) { /* The position class uses the GML 3.0 specification for XML. * * <gml:pos>X Y</gml:pos> * * ... but it is also helpful to be able to READ older versions * of GML, such as this one for GML 2.0: * * <gml:coord> * <gml:X>double</gml:X> * <gml:Y>double</gml:Y> // optional * <gml:Z>double</gml:Z> // optional * </gml:coord> * */ // .NET Complains if we don't assign values _Position = Position.Empty; _Altitude = Distance.Empty; Longitude longitude = Longitude.Empty; Latitude latitude = Latitude.Empty; // Move to the <gml:pos> or <gml:coord> element if (!reader.IsStartElement("pos", Xml.GmlXmlNamespace) && !reader.IsStartElement("coord", Xml.GmlXmlNamespace)) { reader.ReadStartElement(); } switch (reader.LocalName.ToLower(CultureInfo.InvariantCulture)) { case "pos": // Read the "X Y" string, then split by the space between them string[] Values = reader.ReadElementContentAsString().Split(' '); // Deserialize the longitude longitude = new Longitude(Values[0], CultureInfo.InvariantCulture); // Deserialize the latitude if (Values.Length >= 2) { latitude = new Latitude(Values[1], CultureInfo.InvariantCulture); } // Deserialize the altitude if (Values.Length == 3) { _Altitude = Distance.FromMeters(double.Parse(Values[2], CultureInfo.InvariantCulture)); } // Make the position _Position = new Position(latitude, longitude); break; case "coord": // Read the <gml:coord> start tag reader.ReadStartElement(); // Now read up to 3 elements: X, and optionally Y or Z for (int index = 0; index < 3; index++) { switch (reader.LocalName.ToLower(CultureInfo.InvariantCulture)) { case "x": longitude = new Longitude(reader.ReadElementContentAsDouble()); break; case "y": latitude = new Latitude(reader.ReadElementContentAsDouble()); break; case "z": // Read Z as meters (there's no unit type in the spec :P morons) _Altitude = Distance.FromMeters(reader.ReadElementContentAsDouble()); break; } // If we're at an end element, stop if (reader.NodeType == XmlNodeType.EndElement) { break; } } // Make the position _Position = new Position(latitude, longitude); // Read the </gml:coord> end tag reader.ReadEndElement(); break; } }
public static RFDevice WithLatitude(this RFDevice instance, Latitude value) { instance.Latitude = value; return(instance); }
public Coordinate(Longitude longitude, Latitude latitude) { _Longitude = longitude; _Latitude = latitude; }
public static GeoPosition New(Latitude latitude, Longitude longitude, Length altitude) { return new GeoPosition(latitude, longitude, altitude); }
public GeoPosition(Latitude latitude, Longitude longitude, Length altitude = null) { _latitude = latitude; _longitude = longitude; _altitude = altitude; }
/// <summary> /// Add a map feature of the given dimensions at the given geo coordinate. /// </summary> /// <param name="Id">The unique identification of the feature.</param> /// <param name="Latitude">The latitude of the feature.</param> /// <param name="Longitude">The longitude of the feature.</param> /// <param name="Altitude">The altitude of the feature.</param> /// <param name="Fill">The fill brush of the feature.</param> /// <param name="Stroke">The stroke brush of the feature.</param> /// <param name="StrokeThickness">The thickness of the stroke.</param> public VoronoiFeature AddFeature(String Id, Latitude Latitude, Longitude Longitude, Altitude Altitude, Brush Fill, Brush Stroke, Double StrokeThickness) { return AddFeature(Id, new GeoCoordinate(Latitude, Longitude, Altitude), Fill, Stroke, StrokeThickness); }
public void GeoCoordinateToStringAndBackParsingTest() { var Random = new Random(); var RandomLatitude = new Latitude ((Random.NextDouble() - 0.5) * 180); var RandomLongitude = new Longitude((Random.NextDouble() - 0.5) * 180); var GeoCoordinate1 = new GeoCoordinate(RandomLatitude, RandomLongitude); Assert.AreEqual(RandomLatitude.Value, GeoCoordinate1.Latitude.Value, 0.0000001); Assert.AreEqual(RandomLongitude.Value, GeoCoordinate1.Longitude.Value, 0.0000001); var GeoCoordinate2 = GeoCoordinate.ParseString(GeoCoordinate1.ToGeoString()); Assert.AreEqual(RandomLatitude.Value, GeoCoordinate2.Latitude.Value, 0.0000001); Assert.AreEqual(RandomLongitude.Value, GeoCoordinate2.Longitude.Value, 0.0000001); var GeoCoordinate3 = GeoCoordinate.ParseString(GeoCoordinate1.ToGeoString(GeoFormat.Decimal)); Assert.AreEqual(RandomLatitude.Value, GeoCoordinate3.Latitude.Value, 0.0000001); Assert.AreEqual(RandomLongitude.Value, GeoCoordinate3.Longitude.Value, 0.0000001); var GeoCoordinate4 = GeoCoordinate.ParseString(GeoCoordinate1.ToGeoString(GeoFormat.Sexagesimal)); Assert.AreEqual(RandomLatitude.Value, GeoCoordinate4.Latitude.Value, 0.0000001); Assert.AreEqual(RandomLongitude.Value, GeoCoordinate4.Longitude.Value, 0.0000001); var GeoCoordinate5 = GeoCoordinate.ParseString(RandomLatitude.ToString() + ", " + RandomLongitude.ToString()); Assert.AreEqual(RandomLatitude.Value, GeoCoordinate5.Latitude.Value, 0.0000001); Assert.AreEqual(RandomLongitude.Value, GeoCoordinate5.Longitude.Value, 0.0000001); }
public void RawAngleConstructorTest2() { Angle angle = new Angle(0); Latitude latitude = new Latitude(angle); Assert.AreEqual(angle, latitude.Value); Assert.AreEqual(angle, latitude.RawValue); }
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 templatePath = Path.Combine(whConfig.StaticMaps.TemplatesFolder, whConfig.StaticMaps.Quests.TemplateFile); var staticMapLink = Utils.GetStaticMapsUrl(templatePath, whConfig.Urls.StaticMap, whConfig.StaticMaps.Quests.ZoomLevel, Latitude, Longitude, questRewardImageUrl, null); 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 = Utils.GetAddress(city, Latitude, Longitude, 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); }
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); }
/// <summary> /// Gets the associated geometry style. /// </summary> /// <param name="mapJsRef">The map refference.</param> /// <returns></returns> protected override string GetStyle(string mapJsRef) { return(Radius > 0 ? string.Format("{0}.GCS({1}, {2}, {3}, {4})", mapJsRef, Longitude.ToString(CultureInfo.InvariantCulture), Latitude.ToString(CultureInfo.InvariantCulture), Radius, Style) : Style); }
/// <summary> /// Compares the current instance to the specified position. /// </summary> /// <param name="value">A <strong>Position</strong> object to compare with.</param> /// <returns>A <strong>Boolean</strong>, <strong>True</strong> if the values are identical.</returns> /// <remarks>The two objects are compared at up to four digits of precision.</remarks> public bool Equals(Position3D other) { return(Latitude.Equals(other.Latitude) && Longitude.Equals(other.Longitude) && _Altitude.Equals(other.Altitude)); }
public override string ToString() { return($"[{Latitude.ToString(CultureInfo.InvariantCulture)};{Longitude.ToString(CultureInfo.InvariantCulture)}]"); }
public Position3D(Latitude latitude, Longitude longitude, Distance altitude) { _Position = new Position(latitude, longitude); _Altitude = altitude; }
public override int GetHashCode() { int hash = 1; if (Id.Length != 0) { hash ^= Id.GetHashCode(); } if (LastModifiedTimestampMs != 0L) { hash ^= LastModifiedTimestampMs.GetHashCode(); } if (Latitude != 0D) { hash ^= Latitude.GetHashCode(); } if (Longitude != 0D) { hash ^= Longitude.GetHashCode(); } if (OwnedByTeam != 0) { hash ^= OwnedByTeam.GetHashCode(); } if (GuardPokemonId != 0) { hash ^= GuardPokemonId.GetHashCode(); } if (GuardPokemonCp != 0) { hash ^= GuardPokemonCp.GetHashCode(); } if (Enabled != false) { hash ^= Enabled.GetHashCode(); } if (Type != 0) { hash ^= Type.GetHashCode(); } if (GymPoints != 0L) { hash ^= GymPoints.GetHashCode(); } if (IsInBattle != false) { hash ^= IsInBattle.GetHashCode(); } hash ^= activeFortModifier_.GetHashCode(); if (lureInfo_ != null) { hash ^= LureInfo.GetHashCode(); } if (CooldownCompleteTimestampMs != 0L) { hash ^= CooldownCompleteTimestampMs.GetHashCode(); } if (Sponsor != 0) { hash ^= Sponsor.GetHashCode(); } if (RenderingType != 0) { hash ^= RenderingType.GetHashCode(); } if (DeployLockoutEndMs != 0L) { hash ^= DeployLockoutEndMs.GetHashCode(); } if (guardPokemonDisplay_ != null) { hash ^= GuardPokemonDisplay.GetHashCode(); } if (Closed != false) { hash ^= Closed.GetHashCode(); } if (raidInfo_ != null) { hash ^= RaidInfo.GetHashCode(); } if (gymDisplay_ != null) { hash ^= GymDisplay.GetHashCode(); } if (Visited != false) { hash ^= Visited.GetHashCode(); } if (SameTeamDeployLockoutEndMs != 0L) { hash ^= SameTeamDeployLockoutEndMs.GetHashCode(); } if (AllowCheckin != false) { hash ^= AllowCheckin.GetHashCode(); } if (ImageUrl.Length != 0) { hash ^= ImageUrl.GetHashCode(); } if (InEvent != false) { hash ^= InEvent.GetHashCode(); } if (BannerUrl.Length != 0) { hash ^= BannerUrl.GetHashCode(); } return(hash); }
protected bool Equals(GeographicLocation other) => Latitude.Equals(other.Latitude) && Longitude.Equals(other.Longitude);
public Latitude(Latitude Latitude) : this(Latitude.Degrees, Latitude.Minutes) { }
public override string ToString() { return($"MsgType1: MMSI {UserId}, {NavigationalStatus}, Lon {Longitude.ToString("N4")}, Lat {Latitude.ToString("N4")}, Heading {TrueHeadingString}, SOG {SOG.ToString("N2")}"); }
public static string AsDegreesMinutesSeconds(Latitude latitude) { return AsDegreesMinutesSeconds(latitude.Value, latitude.Hemisphere); }
/// <summary> /// Gets the specific Open Layers geometry code. /// </summary> /// <returns></returns> protected override string GetChildCode() { return(string.Format("new OL.P({0}, {1})", Longitude.ToString(CultureInfo.InvariantCulture), Latitude.ToString(CultureInfo.InvariantCulture))); }
/// <summary> /// Initialize the values. /// </summary> public SPOS() { SPOS_Latitude = new Latitude(); SPOS_Longitude = new Longitude(); SPOS_WaterDepth = AdcpCommands.DEFAULT_WATER_DEPTH; SPOS_PsensHeight = AdcpCommands.DEFAULT_PSEN_HEIGHT; }
/// <summary> /// Convert a MGRS string to gegraphic coordinate /// </summary> /// <param name="mgrs">MGRS string</param> /// <param name="lat">latitude</param> /// <param name="lng">longitude</param> public void FromMgrs(string mgrs, out Latitude lat, out Longitude lng) { FromMgrs(mgrs, out double easting, out double northing); Reverse(northing, easting, out lat, out lng); }
public override string ToString() { return($"{Longitude.ToString()} {Latitude.ToString()}"); }
public bool Equals(GpsCoordinates other) { return(Latitude.Equals(other.Latitude) && Longitude.Equals(other.Longitude)); }
public Coordinate(Longitude longitude, Latitude latitude) { Longitude = longitude; Latitude = latitude; }
protected bool Equals(LatLongCoordinate other) { return(Latitude.Equals(other.Latitude) && Longitude.Equals(other.Longitude)); }
public string ToFormattedString() { return("Lat : " + Latitude.ToString("##.######") + " Lon : " + Longitude.ToString("###.######")); }
public override string ToString() { return(Latitude.ToString("#0.0#######", CultureInfo.InvariantCulture) + "," + Longitude.ToString("#0.0#######", CultureInfo.InvariantCulture)); }
public string GetLatitudeString() { return(Latitude.ToString(CultureInfo.InvariantCulture)); }
private async Task <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 != WeatherType.None; var isWeatherBoosted = pkmnInfo?.IsWeatherBoosted(Weather ?? WeatherType.None); var weatherKey = $"weather_{Convert.ToInt32(Weather ?? WeatherType.None)}"; var weatherEmoji = string.IsNullOrEmpty(MasterFile.Instance.CustomEmojis[weatherKey]) ? MasterFile.Instance.CustomEmojis.ContainsKey(weatherKey) && Weather != WeatherType.None ? (Weather ?? WeatherType.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 templatePath = Path.Combine(properties.Config.StaticMaps.TemplatesFolder, properties.Config.StaticMaps.Pokemon.TemplateFile); var staticMapLink = Utils.GetStaticMapsUrl(templatePath, properties.Config.Urls.StaticMap, properties.Config.StaticMaps.Pokemon.ZoomLevel, Latitude, Longitude, properties.ImageUrl, null); 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 = Utils.GetAddress(properties.City, Latitude, Longitude, 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 = await 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(await Task.FromResult(dict)); }
/// <summary> /// Builds a string representation of the object. /// </summary> /// <returns>the string representation</returns> public override string ToString() => $"lat: {Latitude.ToString(CultureInfo.InvariantCulture)}, lon: {Longitude.ToString(CultureInfo.InvariantCulture)}";
public string LocationAsString() { return(Latitude.ToString(CultureInfo.InvariantCulture.NumberFormat) + "," + Longitude.ToString(CultureInfo.InvariantCulture.NumberFormat)); }
/// <summary> /// Uploads a file /// </summary> /// <param name="filename">The filename we want to upload</param> /// <param name="MD5Checksum">The MD5 checksum of a file</param> /// <returns>An Image object that describes the image we uploaded</returns> public async Task <Image> UploadImageAsync(string filename, string MD5Checksum, CancellationToken token) { string uploadURL = string.Format("http://upload.smugmug.com/{0}", filename); var myFileInfo = new FileInfo(filename); var myWebRequest = (HttpWebRequest)WebRequest.Create(uploadURL); myWebRequest.UserAgent = "YASMAPI v1.0"; myWebRequest.ContentType = "binary/octet-stream"; myWebRequest.ContentLength = myFileInfo.Length; myWebRequest.Method = WebRequestMethods.Http.Put; myWebRequest.Headers.Add("X-Smug-Version", Version); myWebRequest.Headers.Add("X-Smug-ResponseType", ResponseType); myWebRequest.Headers.Add("X-Smug-AlbumID", Album.id.ToString()); myWebRequest.Headers.Add("Content-MD5", MD5Checksum); myWebRequest.Headers.Add("X-Smug-FileName", myFileInfo.Name); if (Altitude != null) { myWebRequest.Headers.Add("X-Smug-Altitude", Altitude.ToString()); } if (Caption != null) { myWebRequest.Headers.Add("X-Smug-Caption", Caption); } if (Hidden == true) { myWebRequest.Headers.Add("X-Smug-Hidden", "true"); } if (ImageID != null) { myWebRequest.Headers.Add("X-Smug-ImageID", ImageID.ToString()); } if (Keywords != null) { myWebRequest.Headers.Add("X-Smug-Keywords", Keywords); } if (Latitude != null) { myWebRequest.Headers.Add("X-Smug-Latitude", Latitude.ToString()); } if (Longitude != null) { myWebRequest.Headers.Add("X-Smug-Longitude", Longitude.ToString()); } if (Pretty == true) { myWebRequest.Headers.Add("X-Smug-Pretty", "true"); } // Add the authorization header myWebRequest.Headers.Add("Authorization", oAuthUtility.GetAuthorizationHeader(authentication.AccessToken, uploadURL)); //we start reading from the file... //we have some elements to set //- request time out (compute this for 10 kb/sec speed) //- the chunk size to use when uploading (how much data to report after) if (UploadStarted != null) { UploadStarted(this, new UploadEventArgs() { FileName = myFileInfo.FullName, PercentComplete = 0 }); } int timeOut = ((int)myFileInfo.Length / 1024) * 1000; myWebRequest.Timeout = timeOut; myWebRequest.ReadWriteTimeout = timeOut; myWebRequest.AllowWriteStreamBuffering = AllowWriteStreamBuffering; long howMuchRead = 0; byte[] buffer = new byte[chunkSize]; int readSoFar = 0; try { using (FileStream sr = new FileStream(myFileInfo.FullName, FileMode.Open, FileAccess.Read)) { using (var stream = await myWebRequest.GetRequestStreamAsync()) { while (howMuchRead < myFileInfo.Length) { //we try to read a chunk from the file readSoFar = sr.Read(buffer, 0, chunkSize); howMuchRead += readSoFar; //we now write those files to the web. await stream.WriteAsync(buffer, 0, readSoFar, token); if (UploadProgress != null) { UploadProgress(this, new UploadEventArgs() { FileName = myFileInfo.FullName, PercentComplete = (float)howMuchRead / (float)myFileInfo.Length }); } } } } } catch (Exception) { //an error has occured... throw; } var resp = await myWebRequest.GetResponseAsync(); string rez = string.Empty; using (StreamReader ns = new StreamReader(resp.GetResponseStream())) { rez = await ns.ReadToEndAsync(); } if (UploadCompleted != null) { UploadCompleted(this, new UploadEventArgs() { FileName = myFileInfo.FullName, PercentComplete = (float)howMuchRead / (float)myFileInfo.Length }); } //we deserialize the image var response = JsonConvert.DeserializeObject <ImageResponse>(System.Uri.UnescapeDataString(rez)); if (response.stat == "ok") { Image img = response.Image; img.basic = authentication; img.Album = Album; return(img); } else { throw new SmugMugException(response.code, response.message, response.method); } }
/// <summary> /// Creates a new instance containing the specified Latitude object. /// </summary> public LatitudeEventArgs(Latitude angle) { _Latitude = angle; }
public override string ToString() { return(Latitude.ToString("F4") + ", " + Longitude.ToString("F4")); }
/// <summary> /// Converts the given world coordinates and zoom level to the X and Y number of map tiles. /// </summary> /// <param name="Latitude">The latitude.</param> /// <param name="Longitude">The longitude.</param> /// <param name="ZoomLevel">The ZoomLevel.</param> /// <returns>The TileX and TileY number as a tuple.</returns> public static Tuple<UInt64, UInt64> WorldCoordinates_2_Screen(Latitude Latitude, Longitude Longitude, UInt32 ZoomLevel) { var MapSize = Math.Pow(2.0, ZoomLevel) * 256; return new Tuple<UInt64, UInt64>( (UInt64) (((Longitude.Value + 180.0) / 360.0) * MapSize), (UInt64) (((1.0 - Math.Log( Math.Tan(Latitude.Value * Math.PI / 180.0) + 1.0 / Math.Cos(Latitude.Value * Math.PI / 180.0) ) / Math.PI) / 2.0) * MapSize) ); }
/// <summary> /// Serves as a hash function for the GeoCoordinate. /// </summary> /// <returns> /// A hash code for the current GeoCoordinate. /// </returns> public override int GetHashCode() { return(Latitude.GetHashCode() ^ Longitude.GetHashCode()); }