| 1 |
<?php // $Id: geo.module,v 1.30 2009/11/17 22:09:57 vauxia Exp $ |
<?php // $Id: geo.module,v 1.31 2009/11/23 20:35:54 vauxia Exp $ |
| 2 |
|
|
| 3 |
/** |
/** |
| 4 |
* Geo: Geospatial storage and retrieval. |
* Geo: Geospatial storage and retrieval. |
| 71 |
return array( |
return array( |
| 72 |
'default' => array( |
'default' => array( |
| 73 |
'label' => t('Well Known Text'), |
'label' => t('Well Known Text'), |
| 74 |
'field types' => geo_field_types(), |
'field types' => geo_field_type_names(), |
| 75 |
'gis types' => array('point', 'linestring', 'polygon'), |
'gis types' => array('point', 'linestring', 'polygon'), |
| 76 |
'gis input' => 'wkt', |
'gis input' => 'wkt', |
| 77 |
), |
), |
| 78 |
'lat' => array( |
'lat' => array( |
| 79 |
'label' => t('Latitude'), |
'label' => t('Latitude'), |
| 80 |
'field types' => geo_field_types(), |
'field types' => geo_field_type_names(), |
| 81 |
'gis types' => array('point'), |
'gis types' => array('point'), |
| 82 |
'gis input' => 'array', |
'gis input' => 'array', |
| 83 |
), |
), |
| 84 |
'lon' => array( |
'lon' => array( |
| 85 |
'label' => t('Longitude'), |
'label' => t('Longitude'), |
| 86 |
'field types' => geo_field_types(), |
'field types' => geo_field_type_names(), |
| 87 |
'gis types' => array('point'), |
'gis types' => array('point'), |
| 88 |
'gis input' => 'array', |
'gis input' => 'array', |
| 89 |
), |
), |
| 90 |
'georss' => array( |
'georss' => array( |
| 91 |
'label' => t('GeoRSS'), |
'label' => t('GeoRSS'), |
| 92 |
'field types' => geo_field_types(), |
'field types' => geo_field_type_names(), |
| 93 |
'gis types' => array('point', 'linestring', 'polygon'), |
'gis types' => array('point', 'linestring', 'polygon'), |
| 94 |
'gis input' => 'text', |
'gis input' => 'text', |
| 95 |
), |
), |
| 102 |
function geo_field_types() { |
function geo_field_types() { |
| 103 |
static $field_types; |
static $field_types; |
| 104 |
if (!isset($field_types)) { |
if (!isset($field_types)) { |
| 105 |
$field_types = array('geo', 'geo_data'); |
$field_types = array('geo' => array(), 'geo_data' => array()); |
| 106 |
drupal_alter('geo_field_types', $field_types); |
drupal_alter('geo_field_types', $field_types); |
| 107 |
} |
} |
| 108 |
return $field_types; |
return $field_types; |
| 109 |
} |
} |
| 110 |
|
|
| 111 |
/** |
/** |
| 112 |
|
* API Function: Return a flat array list of field types that may contain |
| 113 |
|
* geospatial data. |
| 114 |
|
*/ |
| 115 |
|
function geo_field_type_names() { |
| 116 |
|
return array_keys(geo_field_types()); |
| 117 |
|
} |
| 118 |
|
|
| 119 |
|
/** |
| 120 |
* API Function: Return a list of CCK fields that contain geospatial data. |
* API Function: Return a list of CCK fields that contain geospatial data. |
| 121 |
*/ |
*/ |
| 122 |
function geo_fields($reset = FALSE) { |
function geo_fields($reset = FALSE) { |
| 126 |
$fields = array(); |
$fields = array(); |
| 127 |
if (function_exists('content_fields')) { |
if (function_exists('content_fields')) { |
| 128 |
foreach (content_fields() as $field) { |
foreach (content_fields() as $field) { |
| 129 |
if (in_array($field['type'], $field_types)) { |
if (in_array($field['type'], array_keys($field_types))) { |
| 130 |
$fields[$field['field_name']] = array( |
$fields[$field['field_name']] = array( |
| 131 |
'label' => $field['widget']['label'], |
'label' => $field['widget']['label'], |
| 132 |
'gis type' => $field['geo_type'], |
'gis type' => $field['geo_type'], |
| 142 |
} |
} |
| 143 |
|
|
| 144 |
/** |
/** |
| 145 |
|
* API Function: Return a flat array list of CCK fields that contain |
| 146 |
|
* geospatial data. |
| 147 |
|
*/ |
| 148 |
|
function geo_field_names($reset = FALSE) { |
| 149 |
|
return array_keys(geo_fields($reset)); |
| 150 |
|
} |
| 151 |
|
|
| 152 |
|
/** |
| 153 |
* Implementation of hook_content_fieldapi(). |
* Implementation of hook_content_fieldapi(). |
| 154 |
*/ |
*/ |
| 155 |
function geo_content_fieldapi($op, $field) { |
function geo_content_fieldapi($op, $field) { |