Submitted by bec on Thu, 06/11/2009 - 17:04
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 />
...<br />
return $gmap_feature;<br />
}<br />
<br />
// Now use it in some other function<br />
function xyz() {<br />
$map['shapes'][] = geo_wkb_get_data($wkb, 'gmap_feature');<br />
}<br />
<br />
// Or in a hook_field_formatter_info()<br />
function gmap_geo_field_formatter_info() {<br />
return array(<br />
'gmap_geo' => array(<br />
'label' => t('GMap'),<br />
'field types' => array('geo', 'geo_data'),<br />
'multiple values' => CONTENT_HANDLE_MODULE,<br />
'gis types' => array('point', 'linestring', 'polygon'),<br />
'gis input' => 'gmap_feature',<br />
),<br />
);<br />
}Also see the page on CCK Field Formatters for Geo fields.
Related modules:
