public ICoordinate Transform(ICoordinate coordinate) { // Set up fields var xy = new[] { coordinate.X, coordinate.Y }; var z = double.IsNaN(coordinate.Z) ? null : new[] { coordinate.Z }; var m = double.IsNaN(coordinate.M) ? null : new[] { coordinate.M }; //Do the reprojection Reproject.ReprojectPoints(xy, z, _order[0], _order[1], 0, 1); // Put result in new object var res = (ICoordinate)Activator.CreateInstance(coordinate.GetType()); res.X = xy[0]; res.Y = xy[1]; if (z != null) { res.Z = z[0]; } if (m != null) { res.M = m[0]; } return(res); }
/// <summary> /// Calling this method will convert from the passed value to the OSGB36 /// </summary> /// <param name="pCoordinate">The latitude and longtitude to be converted </param> /// <returns>The location as a OSGB36 coordinate</returns> public ICoordinate Calculate(ICoordinate pCoordinate) { if (pCoordinate.GetType() != typeof(EastingNorthing)) { throw new CoordinateTypeException("the wrong coordinate type has been passed"); } else { EastingNorthing p = (EastingNorthing)pCoordinate; return(Calculate(p.Easting, p.Northing, p.Height)); } }
/// <summary> /// Calling this method will convert from the passed value to the OSGB36 /// </summary> /// <param name="pCoordinate">The latitude and longtitude to be converted </param> /// <returns>The location as a OSGB36 coordinate</returns> public ICoordinate Calculate(ICoordinate pCoordinate) { if (pCoordinate.GetType() != typeof(LatLon)) { throw new CoordinateTypeException("the wrong coordinate type has been passed"); } else { LatLon p = (LatLon)pCoordinate; return(Calculate(p.Latitude, p.Longtitude, p.Height)); } }