protected override void Execute() { if (!GeocodedAddress.Zip5.HasValue) { Result = null; return; } List <GridLinkable> items; App.UspsDeliveryPoints.TryGetValue(GeocodedAddress.Zip5.Value.ToString(), out items); if (items == null || !items.Any()) { Result = null; return; } var deliveryPoint = items.FirstOrDefault() as UspsDeliveryPointLink; if (deliveryPoint == null) { Result = null; return; } var result = new Candidate { Address = deliveryPoint.MatchAddress, AddressGrid = deliveryPoint.Grid, Locator = "USPS Delivery Points", Score = 100, Location = new Location(deliveryPoint.X, deliveryPoint.Y) }; if (_options.WkId != 26912) { var reprojectPointCommand = new ReprojectPointsCommand(new ReprojectPointsCommand.PointProjectQueryArgs(26912, _options.WkId, new List <double> { deliveryPoint.X, deliveryPoint.Y })); var pointReprojectResponse = CommandExecutor.ExecuteCommand(reprojectPointCommand); if (!pointReprojectResponse.IsSuccessful || !pointReprojectResponse.Geometries.Any()) { return; } var points = pointReprojectResponse.Geometries.FirstOrDefault(); result.Location = new Location(points.X, points.Y); } Result = new[] { result }; }
public void HandlesBadInput() { var command = new ReprojectPointsCommand(new ReprojectPointsCommand.PointProjectQueryArgs(26912, 0, new List <double> { 447158, 4493466 })); command.Run(); Assert.That(command.Result, Is.Not.Null); Assert.That(command.Result.IsSuccessful, Is.False); Assert.That(command.ErrorMessage, Is.Not.Null); }
public void HandlesBadInput() { var command = new ReprojectPointsCommand(new ReprojectPointsCommand.PointProjectQueryArgs(26912, 0, new List<double> { 447158, 4493466 })); command.Run(); Assert.That(command.Result, Is.Not.Null); Assert.That(command.Result.IsSuccessful, Is.False); Assert.That(command.ErrorMessage, Is.Not.Null); }
public void CanReprojectSimplePoint() { var command = new ReprojectPointsCommand(new ReprojectPointsCommand.PointProjectQueryArgs(26912, 4326, new List <double> { 447158, 4493466 })); command.Run(); Assert.That(command.Result, Is.Not.Null); Assert.That(command.Result.IsSuccessful, Is.True); Assert.That(Math.Round(command.Result.Geometries.First().X, 2), Is.EqualTo(-111.62)); Assert.That(Math.Round(command.Result.Geometries.First().Y, 2), Is.EqualTo(40.59)); }
public void CanReprojectSimplePoint() { var command = new ReprojectPointsCommand(new ReprojectPointsCommand.PointProjectQueryArgs(26912, 4326, new List<double> { 447158, 4493466 })); command.Run(); Assert.That(command.Result, Is.Not.Null); Assert.That(command.Result.IsSuccessful, Is.True); Assert.That(Math.Round(command.Result.Geometries.First().X, 2), Is.EqualTo(-111.62)); Assert.That(Math.Round(command.Result.Geometries.First().Y, 2), Is.EqualTo(40.59)); }
protected override void Execute() { if (Wkid != 26912) { var reprojectPointCommand = new ReprojectPointsCommand(new ReprojectPointsCommand.PointProjectQueryArgs(Wkid, 26912, new List <double> { Location.X, Location.Y })); var pointReprojectResponse = CommandExecutor.ExecuteCommand(reprojectPointCommand); if (!pointReprojectResponse.IsSuccessful || !pointReprojectResponse.Geometries.Any()) { return; } var points = pointReprojectResponse.Geometries.FirstOrDefault(); if (points != null) { Location = new Location(points.X, points.Y); } } var locator = CommandExecutor.ExecuteCommand(new GetAltNameLocatorsForLocationCommand(Location)); var requestUri = string.Format(locator.Url, Location.X, Location.Y, Distance, Wkid); var response = App.HttpClient.GetAsync(requestUri).ContinueWith( httpResponse => ConvertResponseToObjectAsync(httpResponse.Result)).Unwrap().Result; var result = new ReverseGeocodeResult { InputLocation = response.Location, Address = response.Address }; Result = result; }
public void CanReprojectMultiplePoint() { var command = new ReprojectPointsCommand(new ReprojectPointsCommand.PointProjectQueryArgs(26912, 4326, new List <double> { 447158, 4493466, 418473.370852653, 4563753.59168596 })); command.Run(); Assert.That(command.Result, Is.Not.Null); Assert.That(command.Result.IsSuccessful, Is.True); Assert.That(command.Result.Geometries.First().X, Is.EqualTo(-111.62447107405954d)); Assert.That(command.Result.Geometries.First().Y, Is.EqualTo(40.590310911817163d)); Assert.That(command.Result.Geometries.Skip(1).First().X, Is.EqualTo(-111.97264595627512d)); Assert.That(command.Result.Geometries.Skip(1).First().Y, Is.EqualTo(41.221068629003206d)); }
public void CanReprojectMultiplePoint() { var command = new ReprojectPointsCommand(new ReprojectPointsCommand.PointProjectQueryArgs(26912, 4326, new List<double> { 447158, 4493466, 418473.370852653, 4563753.59168596 })); command.Run(); Assert.That(command.Result, Is.Not.Null); Assert.That(command.Result.IsSuccessful, Is.True); Assert.That(command.Result.Geometries.First().X, Is.EqualTo(-111.62447107405954d)); Assert.That(command.Result.Geometries.First().Y, Is.EqualTo(40.590310911817163d)); Assert.That(command.Result.Geometries.Skip(1).First().X, Is.EqualTo(-111.97264595627512d)); Assert.That(command.Result.Geometries.Skip(1).First().Y, Is.EqualTo(41.221068629003206d)); }
protected override void Execute() { if (!GeocodedAddress.Zip5.HasValue) { Result = null; return; } if (App.PoBoxLookup is null) { Result = null; return; } if (!App.PoBoxLookup.ContainsKey(GeocodedAddress.Zip5.Value)) { Result = null; return; } Candidate candidate; var key = GeocodedAddress.Zip5.Value * 10000 + GeocodedAddress.PoBox; if (App.PoBoxZipCodesWithExclusions.Any(x => x == GeocodedAddress.Zip5) && App.PoBoxExclusions.ContainsKey(key)) { var exclusion = App.PoBoxExclusions[key]; candidate = new Candidate { Address = GeocodedAddress.StandardizedAddress, Locator = "Post Office Point Exclusions", Score = 100, Location = new Location(exclusion.X, exclusion.Y), AddressGrid = GeocodedAddress.AddressGrids.FirstOrDefault().Grid }; } else if (App.PoBoxLookup.ContainsKey(GeocodedAddress.Zip5.Value)) { var result = App.PoBoxLookup[GeocodedAddress.Zip5.Value]; candidate = new Candidate { Address = GeocodedAddress.StandardizedAddress, Locator = "Post Office Point", Score = 100, Location = new Location(result.X, result.Y), AddressGrid = GeocodedAddress.AddressGrids.FirstOrDefault()?.Grid }; } else { return; } if (_options.WkId != 26912) { var reprojectPointCommand = new ReprojectPointsCommand(new ReprojectPointsCommand.PointProjectQueryArgs(26912, _options.WkId, new List <double> { candidate.Location.X, candidate.Location.Y })); var pointReprojectResponse = CommandExecutor.ExecuteCommand(reprojectPointCommand); if (!pointReprojectResponse.IsSuccessful || !pointReprojectResponse.Geometries.Any()) { return; } var points = pointReprojectResponse.Geometries.FirstOrDefault(); candidate.Location = new Location(points.X, points.Y); } Result = new[] { candidate }; }