You are here

function farm_map_kml_parse_placemark in farmOS 7

Helper function for extracting information about a KML placemark.

Parameters

$placemark: A SimpleXML Placemark object.

Return value

array Returns information about the placemark, including name, description, and geometry in Well-Known Text (WKT).

1 call to farm_map_kml_parse_placemark()
farm_map_kml_parse_geometries in modules/farm/farm_map/farm_map_kml/farm_map_kml.module
Helper function for converting KML to a set of geometries.

File

modules/farm/farm_map/farm_map_kml/farm_map_kml.module, line 195
Farm map KML.

Code

function farm_map_kml_parse_placemark($placemark) {

  // Start a new array for the geometry info.
  $geometry = array();

  // Get the placemark name as a string.
  $geometry['name'] = (string) $placemark->name;

  // Get the placemark description as a string.
  $geometry['description'] = (string) $placemark->description;

  // Parse the placemark into a GeoPHP geometry object.
  $placemark_xml = $placemark
    ->asXML();
  $geophp_geometry = geoPHP::load($placemark_xml, 'kml');

  // Convert the geometry to WKT.
  $geometry['wkt'] = $geophp_geometry
    ->out('wkt');

  // Return the geometry.
  return $geometry;
}