avdwerff / kmlparser Goto Github PK
View Code? Open in Web Editor NEWSwift KML parser based on the (NS)XMLParser found in Foundation
License: MIT License
Swift KML parser based on the (NS)XMLParser found in Foundation
License: MIT License
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
Hi! Thank you for this library. Could you plan to add icon support for placemarks?
I need to add interior polygon support. Any guidance on where to start?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.