Internal Geodata Formats

Geo provides the function geo_wkb_get_data($wkb, $format) to translate Well Known Binary (WKB, the format used to store geographic features in the database) into various formats that you can use. Geo itself provides the following formats:

  • text - a plain text list of points
  • wkt - "Well Known Text"
  • array - an array of points
  • kml - text formatted for KML features

These data formatters are functions named like geo_wkb_get_FORMAT($data, $items = NULL). The geo core data formatters live in includes/geo.wkb.inc. Individual modules which require data in a different format are encouraged to write data formatter functions; in your own module you may provide a geodata formatter and then access it via Geo:

// Your custom geodata format<br />
function geo_wkb_get_gmap_feature($data, $items = NULL) {<br />
&nbsp;&nbsp;...<br />
&nbsp;&nbsp;return $gmap_feature;<br />
}<br />
&nbsp;<br />
// Now use it in some other function<br />
function xyz() {<br />
&nbsp;&nbsp;$map['shapes'][] = geo_wkb_get_data($wkb, 'gmap_feature');<br />
}<br />
&nbsp;<br />
// Or in a hook_field_formatter_info()<br />
function gmap_geo_field_formatter_info() {<br />
&nbsp;&nbsp;return array(<br />
&nbsp;&nbsp;&nbsp;&nbsp;'gmap_geo' => array(<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'label' => t('GMap'),<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'field types' => array('geo', 'geo_data'),<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'multiple values' => CONTENT_HANDLE_MODULE,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'gis types' => array('point', 'linestring', 'polygon'),<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'gis input' => 'gmap_feature',<br />
&nbsp;&nbsp;&nbsp;&nbsp;),<br />
&nbsp;&nbsp;);<br />
}

Also see the page on CCK Field Formatters for Geo fields.

Related modules: 
Geo