将值数组放入 CLLocationCooperative2D 的优雅方法
是否有一种优雅的方法从 NSDecimalNumber 值数组创建 CLLocationCooperative2D 对象?也许是一个递归函数?
我是目标 C 的新手,对此遇到困难。
下面是我正在使用的数据结构的示例。
NSDecimalNumber 值的数组:
NSLog(@"path: %@", [path description]);
返回
path: (
"-71.4826609644423",
"27.7231737704478",
"-71.4826608497223",
"27.7231120144099",
"-71.4826391681679",
"27.7228678610506",
...
"-71.482414263977",
"27.7225217655116",
)
我可以像这样手动创建 CLLocationCooperative2D 对象:
CLLocationCoordinate2D pathCoords[5]={
CLLocationCoordinate2DMake(27.7231737704478,-71.4826609644423),
CLLocationCoordinate2DMake(27.7231120144099,-71.4826608497223),
CLLocationCoordinate2DMake(27.7228678610506,-71.4826391681679),
...
CLLocationCoordinate2DMake(27.7225217655116,-71.482414263977),
};
欢迎任何编码建议。 谢谢!
Is there an elegant way to create a CLLocationCoordinate2D object from an array of NSDecimalNumber values? Perhaps a recursive function?
I'm new to objective C and am having difficulty with this.
Below is an example of the data structures I'm working with.
an array of NSDecimalNumber values:
NSLog(@"path: %@", [path description]);
returns
path: (
"-71.4826609644423",
"27.7231737704478",
"-71.4826608497223",
"27.7231120144099",
"-71.4826391681679",
"27.7228678610506",
...
"-71.482414263977",
"27.7225217655116",
)
I can manually create the CLLocationCoordinate2D object like this:
CLLocationCoordinate2D pathCoords[5]={
CLLocationCoordinate2DMake(27.7231737704478,-71.4826609644423),
CLLocationCoordinate2DMake(27.7231120144099,-71.4826608497223),
CLLocationCoordinate2DMake(27.7228678610506,-71.4826391681679),
...
CLLocationCoordinate2DMake(27.7225217655116,-71.482414263977),
};
Any coding suggestions are welcome.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我假设您已经创建了一个名为
pathCoords
的CLLocationCooperative2D
结构,大小为 5。您的问题的本质不是递归的,因此如果您采用递归,那就太过分了。
I'm assuming you have already created a
CLLocationCoordinate2D
structure calledpathCoords
of size 5.The nature of your problem is not recursive, so if you go recursive - it's an overkill.
最终的解决方案包括将 NSDecimalNumbers 类型转换为 doubleValues:
The final solution including typecasting the NSDecimalNumbers to doubleValues: