Location
using System;
namespace DynamoUnits
{
public class Location
{
public string Name { get; set; }
public double Latitude { get; set; }
public double Longitude { get; set; }
private Location(double latitude, double longitude, string name)
{
Latitude = latitude;
Longitude = longitude;
Name = name;
}
public static Location ByLatitudeAndLongitude(double latitude, double longitude, string name = null)
{
if (latitude < -90 || latitude > 90)
throw new Exception("You must enter a latitude between -90.0 and 90.");
if (longitude < -180 || longitude > 180)
throw new Exception("You must enter a longitude between -180.0 and 180.0");
return new Location(latitude, longitude, name);
}
public override string ToString()
{
string name = Name;
double num = Latitude;
string arg = num.ToString(Display.PrecisionFormat);
num = Longitude;
return $"""{name}""{arg}""{num.ToString(Display.PrecisionFormat)}";
}
}
}