Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Support for line breaks between KML coordinate tuples #80

merged 1 commit into from

2 participants


I was trying to parse some KML files with geoPHP today and it kept throwing exceptions because the coordinate tuples in a LineString were separated with line breaks, not spaces. Google's KML reference says to use spaces, but they also provide examples where line breaks are used (see

This might not be a legitimate issue, but I figured I'd send it in since almost every sample KML file out there seems to use line breaks.

@phayes phayes merged commit 0aae7c3 into phayes:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/adapters/KML.class.php
2  lib/adapters/KML.class.php
@@ -169,7 +169,7 @@ protected function _extractCoordinates($xml) {
$coord_elements = $this->childElements($xml, 'coordinates');
$coordinates = array();
if (count($coord_elements)) {
- $coord_sets = explode(' ', $coord_elements[0]->nodeValue);
+ $coord_sets = explode(' ', preg_replace('/[\r\n]+/', ' ', $coord_elements[0]->nodeValue));
foreach ($coord_sets as $set_string) {
$set_string = trim($set_string);
if ($set_string) {
Something went wrong with that request. Please try again.