public override SubwayShape GetFeatureLookup(double x, double y) { // Validate Point is in Range var result = GeoTransformationHelper.ConvertNad83ToWgs84(x, y); var point = new Point(result.Item1.Value, result.Item2.Value); var features = GetFeatures(); var subwayStops = new List <SubwayShape>(features.Count); foreach (var f in features) { var distance = f.Geometry.Distance(point); var model = new SubwayShape { Line = f.Attributes["line"].ToString(), Name = f.Attributes["name"].ToString(), ObjectId = int.Parse(f.Attributes["objectid"].ToString()), Distance = distance, }; subwayStops.Add(model); } var orderedStops = subwayStops.OrderBy(x => x.Distance); var nearest = orderedStops.FirstOrDefault(); return(nearest); }
public ActionResult <(double?, double?)> ConvertWgs84ToNad83(double latitude, double longitude) { if (latitude == 0 || longitude == 0) { return(NoContent()); } var result = GeoTransformationHelper.ConvertWgs84ToNad83(latitude, longitude); var point = new { X = result.Item1, Y = result.Item2 }; return(Ok(point)); }
public ActionResult <(double?, double?)> ConvertNad83ToWgs84(double x, double y) { if (x == 0 || y == 0) { return(NoContent()); } var result = GeoTransformationHelper.ConvertNad83ToWgs84(x, y); var point = new { X = result.Item1, Y = result.Item2 }; return(Ok(point)); }
public void Projection_Transform_ESRI102718_to_WGS84() { double x = 1016637; double y = 187747; var result = GeoTransformationHelper.ConvertNad83ToWgs84(x, y); var latitude = result.Item2; var longitude = result.Item1; var result2 = GeoTransformationHelper.ConvertWgs84ToNad83(latitude, longitude); var x1 = result2.Item1; var y1 = result2.Item2; Assert.NotNull(x1); Assert.NotNull(y1); Assert.Equal((decimal)x, Math.Round((decimal)x1)); Assert.Equal((decimal)y, Math.Round((decimal)y1)); }
public override DSNYDistrictsShape GetFeatureLookup(double x, double y) { // Convert Nad83 to Wgs var result = GeoTransformationHelper.ConvertNad83ToWgs84(x, y); var wgs84Point = new { X = result.Item1, Y = result.Item2 }; // Validate Point is in Range var point = new Point(wgs84Point.X.Value, wgs84Point.Y.Value); var model = new DSNYDistrictsShape(); var features = GetFeatures(); foreach (var f in features) { var exists = f.Geometry.Contains(point); if (exists) { var district = f.Attributes["district"].ToString(); var operationZone = district.RemoveIntegers(); var operationZoneName = EnumHelper.ParseEnum <DsnyOperationZone>(operationZone).GetEnumDescription(); model = new DSNYDistrictsShape { District = district, DistrictCode = f.Attributes["districtco"].ToString(), OperationZone = operationZone, OperationZoneName = operationZoneName }; } } if (!model.ArePropertiesNotNull()) { return(null); } return(model); }