Fixed: Now name of points gets added to the GeoJSON properties.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sat, 10 Aug 2013 19:27:11 +0000 (19:27 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Sat, 10 Aug 2013 19:27:11 +0000 (19:27 +0000)
git-svn-id: http://www.winterrodeln.org/svn/servermediawiki/mediawiki_extensions/wrmap/trunk@1507 7aebc617-e5e2-0310-91dc-80fb5f6d2477

wrmap.body.php

index 16faa49e268c0cd408ca41c56442d37c4a09be8e..b6bd40b29b5c585b45b16f93057b484bbbe0dc6c 100644 (file)
@@ -51,7 +51,6 @@ function sledruns_to_json_features() {
 // 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
@@ -62,8 +61,8 @@ function xml_to_json_features($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(
@@ -77,8 +76,8 @@ function xml_to_json_features($input) {
                // 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(