Ejemplo n.º 1
0
        public static NZazuCoordinate Parse(string latLonDecimalWithSpace)
        {
            var split = latLonDecimalWithSpace
                        .Replace(',', '.') // german comma is allowed
                        .Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries);

            if (split.Length < 2)
            {
                return(null);
            }

            var canLat = double.TryParse(split[0], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign,
                                         NumberFormatInfo.InvariantInfo, out var lat);
            var canLon = double.TryParse(split[1], NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign,
                                         NumberFormatInfo.InvariantInfo, out var lon);

            if (!canLat || !canLon)
            {
                return(null);
            }

            var result = new NZazuCoordinate {
                Lat = lat, Lon = lon
            };

            if (!result.GetIsValid())
            {
                return(null);
            }

            return(result);
        }
Ejemplo n.º 2
0
 public NZazuCoordinate Parse(string source)
 {
     if (string.IsNullOrEmpty(source))
     {
         return(null);
     }
     return(NZazuCoordinate.Parse(source));
 }
Ejemplo n.º 3
0
        public void Parse_German(string toParse, double lat, double lon)
        {
            var sut = NZazuCoordinate.Parse(toParse);

            sut.Should().NotBeNull();
            sut.Lat.Should().Be(lat);
            sut.Lon.Should().Be(lon);
        }
Ejemplo n.º 4
0
        public void Be_Creatable()
        {
            var sut = new NZazuCoordinate {
                Lat = 23, Lon = -10
            };

            sut.Should().NotBeNull();
            sut.Lat.Should().Be(23);
            sut.Lon.Should().Be(-10);
        }
Ejemplo n.º 5
0
        public void Be_Creatble()
        {
            var sut = new SupportGeoLocationBox();

            sut.Should().NotBeNull();

            var data = new NZazuCoordinate {
                Lat = 23.4, Lon = 56.7
            };

            data.Should().BeEquivalentTo(sut.Parse(sut.ToString(data)));
        }
Ejemplo n.º 6
0
        public void Parse_LatLonDecimal(string toParse, double lat, double lon)
        {
            var sut = NZazuCoordinate.Parse(toParse);

            sut.Should().NotBeNull();
            sut.Lat.Should().Be(lat);
            sut.Lon.Should().Be(lon);

            // at least it should be symetric
            var str = sut.ToString();

            str.Should().Be(toParse);

            // and parse its own dog-food
            sut = NZazuCoordinate.Parse(str);
            sut.Should().NotBeNull();
            sut.Lat.Should().Be(lat);
            sut.Lon.Should().Be(lon);
        }
Ejemplo n.º 7
0
 public string ToString(NZazuCoordinate c)
 {
     return(c?.ToString() ?? string.Empty);
 }
Ejemplo n.º 8
0
 public Task OpenGeoApp(NZazuCoordinate c)
 {
     return(Task.Run(() => Process.Start($"https://www.google.com/maps/place/@{c.Lat},{c.Lon},14z")));
 }