// convert XML to geojson (http://www.geojson.org/geojson-spec.html)
// Returns an array of features
// TODO: Error reporting
-// TODO: name of points gets not added to properties
function xml_to_json_features($input) {
libxml_use_internal_errors(true); // without that, we get PHP Warnings if the $input is not well-formed
$xml = new SimpleXMLElement($input); // input
// point
if (in_array($feature->getName(), array_keys($point_type))) {
$properties = array('type' => $point_type[$feature->getName()]);
- if (array_key_exists('wiki', $feature)) $properties['wiki'] = $feature['wiki'];
- if (array_key_exists('name', $feature)) $properties['name'] = $feature['name'];
+ if (isset($feature['wiki'])) $properties['wiki'] = (string) $feature['wiki'];
+ if (isset($feature['name'])) $properties['name'] = (string) $feature['name'];
$json_feature = array(
'type' => 'feature',
'geometry' => array(
// line
if (in_array($feature->getName(), array_keys($line_type))) {
$properties = array('type' => $line_type[$feature->getName()]);
- if (array_key_exists('farbe', $feature)) $properties['strokeColor'] = $feature['farbe'];
- if (array_key_exists('dicke', $feature)) $properties['strokeWidth'] = $feature['dicke'];
+ if (isset($feature['farbe'])) $properties['strokeColor'] = (string) $feature['farbe'];
+ if (isset($feature['dicke'])) $properties['strokeWidth'] = (string) $feature['dicke'];
$json_feature = array(
'type' => 'feature',
'geometry' => array(