将CLLocation移动x米 [英] Moving a CLLocation by x meters
问题描述
我有一个CLLocation定义,我想移动这一点x米到东,y米到南。如何实现这一点?
I have a CLLocation defined, and I'd like to move that point x meters to the east and y meters to the south. How may I achieve that?
推荐答案
有一个C函数接近你要求,距离。它在我的UtilitiesGeo类中的 github 。你将把纬度和经度从你的CLLocation传递给它,然后从它返回的结果lat2和lon2创建一个新的CLLocation:
There is a C function that is close to what you are asking but it takes a bearing and distance. It's in my UtilitiesGeo class on github. You would pass the latitude and longitude from your CLLocation to it and then create a new CLLocation from the resulting lat2 and lon2 that it returns:
/*-------------------------------------------------------------------------
* Given a starting lat/lon point on earth, distance (in meters)
* and bearing, calculates destination coordinates lat2/lon2.
*
* all params in degrees
*-------------------------------------------------------------------------*/
void destCoordsInDegrees(double lat1, double lon1,
double distanceMeters, double bearing,
double* lat2, double* lon2);
如果你不能使用,请看看它从此处和这里,也许您可以修改它,或者这些网站可能有更接近您的需要。
If you can't use that, take a look at the algorithms that it was derived from here and here and perhaps you can modify it or those sites might have something closer to your needs.
这篇关于将CLLocation移动x米的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!