/[drupal]/contributions/modules/geo/includes/geo.formatters.inc
ViewVC logotype

Contents of /contributions/modules/geo/includes/geo.formatters.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.6 - (show annotations) (download) (as text)
Tue Jun 9 04:22:43 2009 UTC (5 months, 2 weeks ago) by vauxia
Branch: MAIN
CVS Tags: DRUPAL-6--1-0-ALPHA1
Changes since 1.5: +7 -11 lines
File MIME type: text/x-php
Allow CCK Formatter modules to define expected gis inputs ( point, linestring, etc) via hook_field_formatter_info()

1. A module declares CCK formatters using the usual syntax, but includes the
   "gis input" key:

   function geo_field_formatter_info(
     return array(
       'default' => array(
         'label' => t('Well Known Text'),
         'field types' => $field_types,
         'gis types' => array('point', 'linestring', 'polygon'),
         'gis input' => 'wkt',
       ),
       'lat' => array(
         'label' => t('Latitude'),
         'field types' => $field_types,
         'gis types' => array('point'),
         'gis input' => 'array',
       ),
     );
   }
2. Geo's CCK modules retrieve data in WKB format
3. On nodeapi:view, geo performs an on-the-fly conversion from WKB to the
   expected input format ( e.g. wkt, array, and so-on)

- Implemented this for all included formatters.
1 <?php // $Id: geo.formatters.inc,v 1.5 2009/06/04 02:02:19 vauxia Exp $
2 /**
3 * @file
4 * Field formatters for geo_field fields.
5 */
6 function theme_geo_formatter_default($element) {
7 return $element['#item']['wkt'];
8 }
9
10 function theme_geo_formatter_lat($element) {
11 return $element['#item']['array']['lat'];
12 }
13
14 function theme_geo_formatter_lon($element) {
15 return $element['#item']['array']['lon'];
16 }
17
18 function theme_geo_formatter_georss($element) {
19 $item = $element['#item'];
20
21 if (in_array($item['gis type'], array('point', 'line', 'polygon'))) {
22 $tag = 'georss:'. $item['gis type'];
23 $value = $item['text'];
24 }
25 elseif($item['bbox']) {
26 $tag = 'georss:bbox';
27 $value = $item['bbox'];
28 }
29 if (isset($tag)) {
30 return '<'. $tag .'>' . $value .'</'. $tag .'>';
31 }
32 }

  ViewVC Help
Powered by ViewVC 1.1.2