GithubHelp home page GithubHelp logo

avdwerff / kmlparser Goto Github PK

View Code? Open in Web Editor NEW
7.0 7.0 4.0 616 KB

Swift KML parser based on the (NS)XMLParser found in Foundation

License: MIT License

Swift 94.15% Objective-C 1.36% Ruby 4.21% C 0.28%

kmlparser's People

Contributors

avdwerff avatar orestpatlyka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

kmlparser's Issues

icon support?

Hi! Thank you for this library. Could you plan to add icon support for placemarks?

Parser uses only fractions of strings/names and throws away the rest (annotation.title)

How to test:
take a kml file with a place mark with a name that contains an unusual character:

Heiglhofstraße 1-3

What happens:
the final annotation has a title == "ße 1-3"

What is expected:
the final annotation has a title == "Heiglhofstraße 1-3"

Cause:
Any XML SAX parser is allowed to divide strings into chunks and present the chunks as separate callbacks to method parser(_ parser: XMLParser, foundCharacters string: String).
SAX Parsers are not only allowed to do this, most parsers actually do this and so is Apples implementation.

In our case, parser(_ parser: XMLParser, foundCharacters string: String) is called twice:
once with string "Heiglhofstra" and once with "ße 1-3"
The current implementation throws away the first string when assigning the annotation title.

partial fix for my test case (this is a dirty hack, see comment below):
case .some(.name):
if let oldKmlStr = kmlObjectLookup[.name] as? KMLStringValue {
let value = oldKmlStr.value + string
kmlObjectLookup[.name] = KMLStringValue(value: value)
} else {
kmlObjectLookup[.name] = KMLStringValue(value: string)
}
(be aware that I removed the where condition which is also a bug - probably your first attempt to fix the problem)

The same bug appears probably here
case .some(.description):
kmlObjectLookup[.description] = KMLStringValue(value: string)
But this is not relevant for my data.

Usually what I do when implementing a SAX parser, is collecting all the string fragments.
At endElement I look if there is some collected string data and call a method that looks like your parser(_ parser: XMLParser, foundCharacters string: String) implementation. This would be the good solution, not my quick hack above

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.