CLLocation Coordinate 3D refactoring thoughts and examples.


From: http://www.mailinglistarchive.com/route-me-map@googlegroups.com/msg00296.html
 
 
 
 
This is the kind of thing that goes with the refactoring comments made 
already, an example method, and the marker manager object, and suggested 
approaches. Delete if you don't like pedantry.... it's just a suggestion.

At issue:

- (void) moveMarker:(RMMarker *)marker AtLatLon:(RMLatLong)point;

Listing the problems:

1. internally the kit is using "RMLatLong" which is arguably a big 
improvement over the cumbersome CLLocationCoordinate2D data type. 
RMLatLong typedefs over to the terribly named Apple equivalent. The 
problem is that the kit mixes and matches the two. Some interfaces you 
see CLLocationCoordinate2D, some RMLatLong and some of the others mixed 
in for the different coordinate systems cause some confusion. At the 
very least, RMLatLong or else CLLocationCoordinate2D need to be 
eradicated from the interface, one or the other should be the standard. 
I'd use RMLatLong myself and make it clear it is type compatible with 
CLLocationCoordinate2D. Flag day style replacement suggestion for 
RMLatLong+CLLocationCoordinate2D mix-n-match status quo is below.

2. AtLatLon: takes a data type of RMLatLon(g). Consistency. This happens 
all the time with google maps Javascript, the g shows up and vanishes 
all the time. The reason to leave it off is a clash with the keyword 
"long" so should probably standardize on RMLatLon and "AtLatLon:"

3. Bicaps: AtLatLon should be "atLatLon:" to fit 20+ year existing 
standard ObjC programming style.

4. Method taking "AtLatLon" *really* means "ToLatLon". It is not 
selecting the marker at the given position for movement, it is taking 
the marker given and assigning it the paramaterized coordinate.

Overall the refactored method would (in my suggestion) look like this:

// bicaps fixed, meaning fixed, type consistency fixed
- (void)moveMarker:(RMMarker *)marker toLatLon:(RMLatLon)point;

Simple changes, but makes a big difference in meaning and consistency. I 
think this kind of thing important and I think should be done regardless 
of the below part. When the interface gets cluttered up with 
inconsistency in type, meaning, bicaps, and so on, as the kit gets more 
features and functionality it gets exponentially harder to use.

STRUCTURAL SUGGESTIONS

This is a bit deeper than the cosmetic type changes.

[a] In order to manipulate a marker we need to know three things. 1. the 
map view it belongs to (so we can get the marker manager) and then 2. 
the marker manager and then 3. the marker we want to manipulate. The map 
view we only need to know so we can access the marker manager. For me, I 
suggest that it would be nice if all of this were encapsulated in the 
RMMarker object. That way to manipulate a marker, you deal with the 
marker. If you want the marker to move you tell it to move and it takes 
care of all of the things you don't need to or should know about.

For example, when we manipulate a view, we do not need to separately 
have an object on hand for its superview and for its window, and have to 
orchestrate the interaction between the three objects. We just 
manipulate the view. The creator of the view needs to plug it into the 
view heirarchy but beyond that, nobody has to know or care.

So operating it... you'd create a marker and assign it to a map view. 
Once assigned, it could internally pick up the marker manager of the map 
view, and when the user modifies its attributes, if these cause map 
operations, it should interact with the map through the marker manager 
if necessary. Otherwise, the user of the object should not know or care 
or have to go into the details of who is responsible for modifying whom.

In the current model, the marker is mostly a chunk of data, the 
modification of which is de-encapsulated and stored in the marker 
manager (it's being treated like a struct basically). This is part of 
the problem of the view-model-controller paradigm that Apple uses in 
that it bleeds over into things, none of which settle clearly into being 
views or models or controllers so is not always appropriate to try to 
shoehorn in. For example, a View does have data and you can directly 
manipulate this data without requiring a third party intemediary. *You* 
are the one doing the controlling so there is not a need to insert a 
controller there. That's your job.

With the excess controller removed from the picture, you get a cleaner 
interface, considering that your custom code is the marker "controller" 
and the marker is doing what a marker needs to do: knowing its position 
in the world, drawing, hiding, holding and displaying a label.

This is how UIView would work as a marker under the current structure:

UIView *subview = [self myCustomizedView];
UIViewManager *subviewManager;
UIView * superview = self.view; // we are a view controller
viewManager = [superview subviewManager];
CGRect frame = [subviewManager getFrameForView:myCustomView];
frame.origin.x += 10.0;
[subviewManager setFrame:frame forView:myCustomView];

If we had to do that every time we wanted to move a view... go nuts. 
Instead the code looks like:

UIView *subview = [self myCustomizedView]; // however way we have a 
reference to the view
CGRect frame = subview.frame;
frame.origin.x += 10.0;
subview.frame = frame.origin.x;

(1) we don't care about the host view (superview) or how it manages its 
subviews and (2) we don't even care if the view has a superview... we 
don't need to know, if it does, then it will do the right thing because 
the knowledge is encapsulated.

Suggestion [b]:

I would rip the RMLatLon concept out and replace with a 3d system with a 
2d interface for those who don't care about 3d. Then we drop being bound 
to "latlon" but end up having an opaque type for coordinates.

The above method would then be refactored to:

- (void)moveMarker:(RMMarker *)marker toCoordinate:(RMCoord)coord;

And if the smart marker suggestion made, this would actually boil down to:

RMMarker.h

@property (nonatomic,assign) RMCoord coordinate;

And in use:

// Move my marker on the map to a new coordinate
marker.coordinate = RMCoordMake(latitude,longitude,altitude);

...
// I got a CLLocation object, I want to move a marker based on the 
CLLocation object...
marker.coordinate = RMCoordMake2D(location.coordinate);

// -or- can add a support method to set from a CLLocation object, this 
would do the above
// internally from the object's data when being set
marker.location = location;

And everything would just work from there. To me this is clean, object 
oriented, encapsulated, and easy.

In depth:

Dump all mentions of CLLocationCoordinate2D and RMLatLong, and replace 
with a single data type, RMCoord.

typedef struct {
        CLLocationCoordinate2D coordinate;
        double altitude;
} RMCoord;

RMCoord RMCoordMake2D(CLLocationCoordinate2D coord)
{
        return RMCoordCopy3D(coord,0);
}

RMCoord RMCoordMake3D(CLLocationCoordinate3D coord, double altitude)
{
        RMCoord self;
        self.coordinate = coord;
        self.altitude = altitude;
        return self;
}

RMCoordMake(double latitude, double longitude, double altitude)
{
        CLLocationCoordinate2D coordinate;
        coordinate.latitude = latitude;
        coordinate.longitude = longitude;
        return RMCoordMake3D(coordinate,altitude);
}

The above can be put into the header file inlined following the examples 
in CGBase.h and CGGeometry.h.

Please consider the above as food for thought. Now I have to get back to 
my coding :-).

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"route-me" group.
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/route-me-map?hl=en
-~----------~----~----~----~------~----~------~--~---
【6层】一字型框架办公楼(含建筑结构图、计算书) 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
深度学习是机器学习的一个子领域,它基于人工神经网络的研究,特别是利用多层次的神经网络来进行学习和模式识别。深度学习模型能够学习数据的高层次特征,这些特征对于图像和语音识别、自然语言处理、医学图像分析等应用至关重要。以下是深度学习的一些关键概念和组成部分: 1. **神经网络(Neural Networks)**:深度学习的基础是人工神经网络,它是由多个层组成的网络结构,包括输入层、隐藏层和输出层。每个层由多个神经元组成,神经元之间通过权重连接。 2. **前馈神经网络(Feedforward Neural Networks)**:这是最常见的神经网络类型,信息从输入层流向隐藏层,最终到达输出层。 3. **卷积神经网络(Convolutional Neural Networks, CNNs)**:这种网络特别适合处理具有网格结构的数据,如图像。它们使用卷积层来提取图像的特征。 4. **循环神经网络(Recurrent Neural Networks, RNNs)**:这种网络能够处理序列数据,如时间序列或自然语言,因为它们具有记忆功能,能够捕捉数据中的时间依赖性。 5. **长短期记忆网络(Long Short-Term Memory, LSTM)**:LSTM 是一种特殊的 RNN,它能够学习长期依赖关系,非常适合复杂的序列预测任务。 6. **生成对抗网络(Generative Adversarial Networks, GANs)**:由两个网络组成,一个生成器和一个判别器,它们相互竞争,生成器生成数据,判别器评估数据的真实性。 7. **深度学习框架**:如 TensorFlow、Keras、PyTorch 等,这些框架提供了构建、训练和部署深度学习模型的工具和库。 8. **激活函数(Activation Functions)**:如 ReLU、Sigmoid、Tanh 等,它们在神经网络中用于添加非线性,使得网络能够学习复杂的函数。 9. **损失函数(Loss Functions)**:用于评估模型的预测与真实值之间的差异,常见的损失函数包括均方误差(MSE)、交叉熵(Cross-Entropy)等。 10. **优化算法(Optimization Algorithms)**:如梯度下降(Gradient Descent)、随机梯度下降(SGD)、Adam 等,用于更新网络权重,以最小化损失函数。 11. **正则化(Regularization)**:技术如 Dropout、L1/L2 正则化等,用于防止模型过拟合。 12. **迁移学习(Transfer Learning)**:利用在一个任务上训练好的模型来提高另一个相关任务的性能。 深度学习在许多领域都取得了显著的成就,但它也面临着一些挑战,如对大量数据的依赖、模型的解释性差、计算资源消耗大等。研究人员正在不断探索新的方法来解决这些问题。
1、资源项目源码均已通过严格测试验证,保证能够正常运行;、 2项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值