There's a bug here. This does not work in cases where the altitude is not given, only the longitude and latitude are required. My old messy readCoordinate function used to check for these cases, could you look into it or tell me a fast way to refactor this code?
 
Example:
https://developers.google.com/kml/documentation/us_states.kml