扩展iOS KMLViewer示例以处理KML NetworkLink元素 [英] Extending iOS KMLViewer Sample to Handle KML NetworkLink Elements

查看:181
本文介绍了扩展iOS KMLViewer示例以处理KML NetworkLink元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个可通过MKMapView显示KML数据的iOS应用.

I am developing an iOS app that displays KML data over an MKMapView.

Apple的 KMLViewer 示例应用程序吸引了我开始.不幸的是,我使用的KML数据在很大程度上依赖于NetworkLinkLinkhref KML元素的链接文件,而KMLViewer的解析器无法处理这些文件.

Apple's KMLViewer sample app has gotten me started. Unfortunately, the KML data I am using relies heavily on linked files via the NetworkLink, Link and href KML elements, and KMLViewer's parser doesn't handle those.

我大概可以弄清楚如何添加这种支持,但是在走那条路之前,我想知道是否有人已经这样做,或者是否有比KMLViewer更好的起点.

I can probably figure out how to add such support, but before I go down that road I was wondering if anyone else has already done this, or if there is a better starting point than KMLViewer.

我看过简单KML ,但它似乎不支持要么.

I've looked at Simple KML, but it doesn't seem to support NetworkLink either.

推荐答案

这是我的调查过程:

  1. 我首先扩展了KMLViewer示例,以支持我需要的其他元素.该示例不太适合此示例:它没有以SAX样式的解析器应有的方式组织,并且如果要向其中添加更多内容,则简单化的状态机确实需要进行大修.
  2. 接下来,我尝试了简单KML 库.它很容易使用,但是解析我需要解析的KML文件花了3500毫秒,比我认为可接受的时间至少长了3000毫秒.另外,Simple KML不支持我需要的所有元素和属性,因此如果我想使用它,就需要对其进行扩展.
  3. 因此,我最终只使用了 TBXML ,它易于使用,并且可以用更少的时间来解析文件超过100毫秒.
  1. I first extended the KMLViewer sample to support the additional elements I needed. The sample is not well suited to this: it is not organized the way a SAX-style parser should be, and the simplistic state machine really needs an overhaul if you want to add more stuff to it.
  2. Next I tried the Simple KML library. It was easy to use, but it took 3500 milliseconds to parse the KML file I needed to parse, which was at least 3000 milliseconds longer than I would find acceptable. Also, Simple KML didn't support all the elements and attributes I needed, so I would have needed to extend it if I wanted to use it.
  3. So, I finally just used TBXML, which was easy to use and which parsed the file in less than 100 milliseconds.

这篇关于扩展iOS KMLViewer示例以处理KML NetworkLink元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆