protected override void ProcessRecord() { if (Short) { var code = new OpenLocationCode.ShortCode(Code); var result = code.RecoverNearest(ReferenceLatitude, ReferenceLongitude); WriteVerbose($"Full code: {code.Code}"); WriteObject(result.Decode()); } else { var code = new OpenLocationCode(Code); WriteObject(code.Decode()); } }
public void ShouldShortenFullCodeToShortCodeFromReferencePoint() { foreach (var testData in ShorteningTestCases) { if (testData.TestType != 'B' && testData.TestType != 'S') { continue; } OpenLocationCode.ShortCode shortened = OpenLocationCode.Shorten(testData.Code, testData.Latitude, testData.Longitude); Assert.AreEqual(testData.ShortCode, shortened.Code, $"Wrong shortening of code {testData.Code} from reference latitude {testData.Latitude} and longitude {testData.Longitude}."); } }