コード例 #1
0
    private static DecimalDegree ApplyCoordinatePreparationRules(DecimalDegree coordinate)
    {
        coordinate = SubtractLowestCoordinates(coordinate);
        coordinate = RoundCoordinatesOnto7DigitsAndConvertToUnityUnits(coordinate);

        return(coordinate);
    }
コード例 #2
0
        private void Parse(string input)
        {
            this.points.Clear();
            for (int i = 0; i < input.Length;)
            {
                SkipWhitespace(input, ref i);
                if (!DecimalDegree.Parse(input, ref i, out double longitude))
                {
                    break;
                }

                if (!SkipSeparator(input, ref i) ||
                    !DecimalDegree.Parse(input, ref i, out double latitude))
                {
                    break;
                }

                if (SkipSeparator(input, ref i) &&
                    DecimalDegree.Parse(input, ref i, out double altitude))
                {
                    this.points.Add(new Vector(latitude, longitude, altitude));
                }
                else
                {
                    this.points.Add(new Vector(latitude, longitude));
                }
            }
        }
コード例 #3
0
            public void ShouldTruncateInsignificantDigits(string value)
            {
                int  index  = 0;
                bool result = DecimalDegree.Parse(value, ref index, out double parsed);

                Assert.That(result, Is.True);
                Assert.That(parsed, Is.EqualTo(double.Parse(value, NumberFormatInfo.InvariantInfo)));
            }
コード例 #4
0
            public void ShouldReadAsMuchAsPossible()
            {
                int  index  = 1;
                bool result = DecimalDegree.Parse(",123,", ref index, out double parsed);

                Assert.That(result, Is.True);
                Assert.That(index, Is.EqualTo(4));
                Assert.That(parsed, Is.EqualTo(123));
            }
コード例 #5
0
            public void ShouldParseValidFormats(string value, double expected)
            {
                int  index  = 0;
                bool result = DecimalDegree.Parse(value, ref index, out double parsed);

                Assert.That(result, Is.True);
                Assert.That(index, Is.EqualTo(value.Length));
                Assert.That(parsed, Is.EqualTo(expected));
            }
コード例 #6
0
    private static DecimalDegree SubtractLowestCoordinates(DecimalDegree coordinate)
    {
        if (!(coordinate.Latitude == 0) || !(coordinate.Longitude == 0))
        {
            coordinate.Longitude -= (decimal)lowestLongitude;
            coordinate.Latitude  -= (decimal)lowestLatitude;
        }

        return(coordinate);
    }
コード例 #7
0
    private static DecimalDegree RoundCoordinatesOnto7DigitsAndConvertToUnityUnits(DecimalDegree coordinate)
    {
        coordinate.Latitude  *= 10000000;
        coordinate.Longitude *= 10000000;

        coordinate.Latitude  = (decimal)Mathf.Round((float)coordinate.Latitude);
        coordinate.Longitude = (decimal)Mathf.Round((float)coordinate.Longitude);

        coordinate.Latitude  /= 100;
        coordinate.Longitude /= 100;

        return(coordinate);
    }
コード例 #8
0
    private static DecimalDegree ParseIntoDecimalDegreeFrom(string lineElementWithCoordinate)
    {
        //regex returns individual decimal digits in a format of 000.00000000000..
        Regex           regex   = new Regex(@"(?:\d{1,3}\.\d{1,20})");
        MatchCollection matches = regex.Matches(lineElementWithCoordinate);

        DecimalDegree coordinate = new DecimalDegree();

        foreach (var match in matches)
        {
            coordinate.ParseDecimalToLatitudeOrLongitude(Decimal.Parse(match.ToString()));
        }
        return(coordinate);
    }
コード例 #9
0
 public PointShape(DecimalDegree coordinate) : base(coordinate)
 {
 }
コード例 #10
0
ファイル: GeoAngle.cs プロジェクト: lihongyang5930/MapMaker
 public override int GetHashCode()
 {
     return(DecimalDegree.GetHashCode());
 }
コード例 #11
0
 public ShapeFormat(DecimalDegree coordinate)
 {
     coordinates.Add(coordinate);
 }