public static function make($supplychain) { $data = json_decode(Sourcemap_Geojson::make($supplychain)); $k = '<?xml version="1.0" encoding="UTF-8"?>'; $k .= '<kml xmlns="http://www.opengis.net/kml/2.2"><Document>'; $k .= '<name>' . $data->properties->title . '</name>'; $k .= '<description>'; $k .= '<![CDATA['; $k .= isset($data->properties->description) ? $data->properties->description : ""; $k .= ']]>'; $k .= '</description>'; $k .= '<Style id="defaultline">'; $k .= '<LineStyle>'; $k .= '<color>aaffffff</color>'; $k .= '<width>6</width>'; $k .= '</LineStyle>'; $k .= '</Style>'; $k .= '<Style id="defaultpoint">'; $k .= '<IconStyle>'; $k .= '<scale>1.0</scale>'; $k .= '<Icon><href>http://maps.google.com/mapfiles/kml/pal2/icon18.png</href></Icon>'; $k .= '</IconStyle>'; $k .= '</Style>'; foreach ($data->features as $ftr) { if ($ftr->geometry->type == "Point") { $k .= '<Placemark>'; $k .= '<name>' . $ftr->properties->title . '</name>'; $k .= '<styleUrl>#defaultpoint</styleUrl>'; $k .= '<description>'; $k .= '<![CDATA['; $k .= isset($ftr->properties->description) ? $ftr->properties->description : ""; $k .= ']]>'; $k .= '</description>'; $k .= '<Point>'; $k .= '<coordinates>' . implode($ftr->geometry->coordinates, ",") . '</coordinates>'; $k .= '</Point>'; $k .= '</Placemark>'; } else { $k .= '<Placemark>'; $k .= '<name>' . $ftr->properties->title . '</name>'; $k .= '<visibility>1</visibility>'; $k .= '<styleUrl>#defaultline</styleUrl>'; $k .= '<description>'; $k .= '<![CDATA['; $k .= isset($ftr->properties->description) ? $ftr->properties->description : ""; $k .= ']]>'; $k .= '</description>'; $k .= '<LineString>'; $k .= '<extrude>1</extrude>'; $k .= '<tessellate>1</tessellate>'; $k .= '<altitudeMode>clampToGround</altitudeMode>'; $k .= '<coordinates>' . implode($ftr->geometry->coordinates[0], ",") . ' ' . implode($ftr->geometry->coordinates[1], ",") . '</coordinates>'; $k .= '</LineString>'; $k .= '</Placemark>'; } } $k .= '</Document></kml>'; return $k; }
protected function _serialize_geojson($data) { $supplychain = array_shift($data); return Sourcemap_Geojson::make($supplychain); }