symm/gisconverter — pull request #3 by amenadiel (2014-07-21 18:24:49+00:00)
Title: Parses possible element attributes

Since KML files can contain not only Placemark geometries but also custom attributes for each placemark, I added a parser to store those properties in an $attributes public class property

Case of use:

alabama.kml file

```xml

abernant
ALLGOOD

alabama
Alabama

Geocode Score
0.889

Geocode Precision
zip

-86.508321,33.92621

```

```php
$decoder = new Symm\Gisconverter\Decoders\KML();
$kmltext=file_get_contents('alabama.kml');
$placemark= $decoder->geomFromText( $kmltext );

var_dump($placemark->attributes);
# array (size=4)
# 'abernant' => string 'ALLGOOD' (length=7)
# 'alabama' => string 'Alabama' (length=7)
# 'Geocode Score' => string '0.889' (length=5)
# 'Geocode Precision' => string 'zip' (length=3)

var_dump($placemark->toWKT() );
# string 'POINT(-86.508321 33.92621)' (length=26)

```

The parser tries to cover every possible case, since placemark attributes can come in the form of children nodes, or children nodes of the ExtendedData node. The attribute name can come from several sources as well. In my case, I was parsing the kml already and it was sub optimal to do that twice for each placemark.