Index: twitter.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/twitter/twitter.install,v
retrieving revision 1.3.2.4
diff -u -p -B -r1.3.2.4 twitter.install
--- twitter.install	13 Feb 2010 20:32:26 -0000	1.3.2.4
+++ twitter.install	22 May 2010 12:55:52 -0000
@@ -70,6 +70,20 @@ function twitter_schema() {
         'length' => 255,
         'not null' => FALSE,
       ),
+      'longitude' => array(
+        'description' => 'Tweet coordinates longitude (decimal degrees).',
+        'type' => 'numeric',
+        'precision' => 10,
+        'scale' => 6, // means accuracy of 0.08m
+        'not null' => FALSE,
+      ),
+      'latitude' => array(
+        'description' => 'Tweet cordinates latitude (decimal degrees).',
+        'type' => 'numeric',
+        'precision' => 10,
+        'scale' => 6,
+        'not null' => FALSE,
+      ),
       'truncated' => array(
         'description' => t("Boolean flag indicating whether the {twitter} status was cut off to fit in the 140 character limit."),
         'type' => 'int',
@@ -153,19 +167,19 @@ function twitter_schema() {
         'type' => 'int',
         'not null' => TRUE,
         'default' => 0
-      ),      
+      ),
       'statuses_count' => array(
         'description' => t("The total number of status updates performed by a user, excluding direct messages sent."),
         'type' => 'int',
         'not null' => TRUE,
         'default' => 0
-      ),      
+      ),
       'favourites_count' => array(
         'description' => t("The  number of statuses a user has marked as favorite."),
         'type' => 'int',
         'not null' => TRUE,
         'default' => 0
-      ),      
+      ),
       'url' => array(
         'description' => t("The url of the {twitter_account}'s home page."),
         'type' => 'varchar',
@@ -349,7 +363,7 @@ function twitter_update_6002() {
 function twitter_update_6003() {
   $ret = array();
   db_drop_primary_key($ret, 'twitter');
-  
+
   db_change_field($ret, 'twitter', 'twitter_id', 'twitter_id',
     array('description' => t("Unique identifier for each {twitter} post."),
           'type' => 'int', 'size' => 'big', 'unsigned' => 'true', 'not null' => TRUE),
@@ -359,7 +373,7 @@ function twitter_update_6003() {
 }
 
 /**
- * Add NOT NULL constraint and DEFAULT value to the screen_name field of the 
+ * Add NOT NULL constraint and DEFAULT value to the screen_name field of the
  * twitter and twitter_user tables per updated schema definition.
  *
  * See http://drupal.org/node/336048 and http://drupal.org/node/430442
@@ -399,12 +413,12 @@ function twitter_update_6005() {
   $ret[] = update_sql("DELETE FROM {twitter} WHERE twitter_id = 2147483647");
 
   db_drop_primary_key($ret, 'twitter');
-  
+
   db_change_field($ret, 'twitter', 'twitter_id', 'twitter_id',
     array('description' => t("Unique identifier for each {twitter} post."),
           'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
     array('primary key' => array('twitter_id')));
-  
+
   return $ret;
 }
 
@@ -422,7 +436,7 @@ function twitter_update_6006() {
   $ret = array();
 
   db_drop_primary_key($ret, 'twitter');
-  
+
   db_change_field($ret, 'twitter', 'twitter_id', 'twitter_id',
     array(
       'description' => t("Unique identifier for each {twitter} post."),
@@ -435,7 +449,7 @@ function twitter_update_6006() {
     ),
     array('primary key' => array('twitter_id'))
   );
-  
+
   db_add_field($ret, 'twitter', 'in_reply_to_status_id',
     array(
       'description' => t("Unique identifier of a status this {twitter} post was replying to."),
@@ -476,7 +490,7 @@ function twitter_update_6006() {
       'default' => 0,
     )
   );
-  
+
   db_drop_primary_key($ret, 'twitter_account');
 
   db_change_field($ret, 'twitter_account', 'twitter_uid', 'twitter_uid',
@@ -492,7 +506,7 @@ function twitter_update_6006() {
     array('primary key' => array('twitter_uid'))
   );
 
-       
+
   return $ret;
 }
 
@@ -513,7 +527,7 @@ function twitter_update_6007() {
 }
 
 /**
- * Update from 2.x to 3.x 
+ * Update from 2.x to 3.x
  */
 function twitter_update_6300() {
   $ret = array();
@@ -671,8 +685,8 @@ function twitter_update_6300() {
                  'not null' => TRUE,
                  'default' => 0
                ));
-               
-               
+
+
   if (db_table_exists('twitter_user')) {
     $result = db_query("SELECT * FROM {twitter_user} ORDER BY uid DESC");
     while ($row = db_fetch_array($result)) {
@@ -688,6 +702,30 @@ function twitter_update_6300() {
   return $ret;
 }
 
+/**
+ * Add coordinates columns to {twitter}.
+ */
+function twitter_update_6301() {
+  $ret = array();
+  // add coordinate fields to {twitter}
+  db_add_field($ret, 'twitter', 'longitude',
+               array(
+                'description' => 'Tweet coordinates longitude (decimal degrees).',
+                'type' => 'numeric',
+                'precision' => 10,
+                'scale' => 6, // means accuracy of 0.08m
+                'not null' => FALSE,
+              ));
+  db_add_field($ret, 'twitter', 'latitude',
+               array(
+                'description' => 'Tweet cordinates latitude (decimal degrees).',
+                'type' => 'numeric',
+                'precision' => 10,
+                'scale' => 6,
+                'not null' => FALSE,
+              ));
+  return $ret;
+}
 
 function twitter_uninstall() {
   // Remove tables.
Index: twitter.lib.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/twitter/twitter.lib.php,v
retrieving revision 1.1.2.5
diff -u -p -B -r1.1.2.5 twitter.lib.php
--- twitter.lib.php	14 Feb 2010 04:11:45 -0000	1.1.2.5
+++ twitter.lib.php	22 May 2010 12:55:52 -0000
@@ -83,7 +83,7 @@ class Twitter {
     }
     return $statuses;
   }
-  
+
   /**
    * Fetch the public timeline
    *
@@ -135,12 +135,12 @@ class Twitter {
     if ($this->source) {
       $params['source'] = $this->source;
     }
-    $values = $this->call('statuses/update', $params, 'POST', TRUE); 
+    $values = $this->call('statuses/update', $params, 'POST', TRUE);
 
     return new TwitterStatus($values);
   }
 
-  
+
   /**
    *
    * @see http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-users%C2%A0show
@@ -169,14 +169,14 @@ class Twitter {
     }
     return new TwitterUser($values);
   }
-  
+
 
   /**
    * Method for calling any twitter api resource
    */
   public function call($path, $params = array(), $method = 'GET', $use_auth = FALSE) {
     $url = $this->create_url($path);
-    
+
     try {
       if ($use_auth) {
         $response = $this->auth_request($url, $params, $method);
@@ -192,10 +192,10 @@ class Twitter {
     if (!$response) {
       return FALSE;
     }
-    
+
     return $this->parse_response($response);
   }
-  
+
   /**
    * Perform an authentication required request.
    */
@@ -227,7 +227,7 @@ class Twitter {
       $headers['Authorization'] = 'Basic '. base64_encode($this->username .':'. $this->password);
       $headers['Content-type'] = 'application/x-www-form-urlencoded';
     }
-    
+
     $response = drupal_http_request($url, $headers, $method, $data);
     if (!$response->error) {
       return $response->data;
@@ -252,12 +252,12 @@ class Twitter {
         return json_decode($response, TRUE);
     }
   }
-  
+
   protected function create_url($path, $format = NULL) {
     if (is_null($format)) {
       $format = $this->format;
     }
-    
+
     $url =  'http://'. $this->host .'/'. $path;
     if (!empty($format)) {
       $url .= '.'. $this->format;
@@ -272,11 +272,11 @@ class Twitter {
 class TwitterOAuth extends Twitter {
 
   protected $signature_method;
-  
+
   protected $consumer;
 
   protected $token;
-  
+
   public function __construct($consumer_key, $consumer_secret, $oauth_token = NULL, $oauth_token_secret = NULL) {
     $this->signature_method = new OAuthSignatureMethod_HMAC_SHA1();
     $this->consumer = new OAuthConsumer($consumer_key, $consumer_secret);
@@ -300,14 +300,14 @@ class TwitterOAuth extends Twitter {
   public function get_authorize_url($token) {
     $url = $this->create_url('oauth/authorize', '');
     $url.= '?oauth_token=' . $token['oauth_token'];
-  
+
     return $url;
   }
 
   public function get_authenticate_url($token) {
     $url = $this->create_url('oauth/authenticate', '');
     $url.= '?oauth_token=' . $token['oauth_token'];
-    
+
     return $url;
   }
 
@@ -322,7 +322,7 @@ class TwitterOAuth extends Twitter {
     $this->token = new OAuthConsumer($token['oauth_token'], $token['oauth_token_secret']);
     return $token;
   }
-  
+
   public function auth_request($url, $params = array(), $method = 'GET') {
     $request = OAuthRequest::from_consumer_and_token($this->consumer, $this->token, $method, $url, $params);
     $request->sign_request($this->signature_method, $this->consumer, $this->token);
@@ -341,7 +341,7 @@ class TwitterSearch extends Twitter {
   protected $host = 'search.twitter.com';
 
   public function search($params = array()) {
-    
+
   }
 }
 
@@ -369,7 +369,10 @@ class TwitterStatus {
   public $in_reply_to_user_id;
 
   public $in_reply_to_screen_name;
-  
+
+  public $longitude;
+  public $latitude;
+
   public $user;
 
   /**
@@ -388,8 +391,14 @@ class TwitterStatus {
     if (isset($values['user'])) {
       $this->user = new TwitterUser($values['user']);
     }
+    // Use coordinates (geo will be deprecated: @see http://bit.ly/DyxlM)
+    if (isset($values['coordinates']['coordinates']) && is_array($values['coordinates']['coordinates'])
+        && $values['coordinates']['type'] == 'Point') {
+      $this->longitude = $values['coordinates']['coordinates'][0];
+      $this->latitude = $values['coordinates']['coordinates'][1];
+    }
   }
-  
+
 }
 
 class TwitterUser {
@@ -425,11 +434,11 @@ class TwitterUser {
   public $profile_link_color;
 
   public $profile_sidebar_fill_color;
-  
+
   public $profile_sidebar_border_color;
 
   public $profile_background_image_url;
-  
+
   public $profile_background_tile;
 
   public $verified;
@@ -439,15 +448,15 @@ class TwitterUser {
   public $created_time;
 
   public $utc_offset;
-  
+
   public $status;
-  
+
   protected $password;
-  
+
   protected $oauth_token;
 
   protected $oauth_token_secret;
-  
+
   public function __construct($values = array()) {
     $this->id = $values['id'];
     $this->screen_name = $values['screen_name'];
@@ -474,7 +483,7 @@ class TwitterUser {
       $this->created_time = $created_time;
     }
     $this->utc_offset = $values['utc_offset'];
-    
+
     if ($values['status']) {
       $this->status = new TwitterStatus($values['status']);
     }
Index: twitter.views.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/twitter/twitter.views.inc,v
retrieving revision 1.6.2.1
diff -u -p -B -r1.6.2.1 twitter.views.inc
--- twitter.views.inc	28 May 2009 06:45:21 -0000	1.6.2.1
+++ twitter.views.inc	22 May 2010 12:55:52 -0000
@@ -111,7 +111,34 @@ function twitter_views_data() {
     ),
   );
 
-
+  $data['twitter']['longitude'] = array(
+    'title' => t('Longitude'),
+    'help' => t('The numeric longitude of a tweet location.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+  );
+  $data['twitter']['latitude'] = array(
+    'title' => t('Latitude'),
+    'help' => t('The numeric latitude of a tweet location.'),
+    'field' => array(
+      'handler' => 'views_handler_field_numeric',
+      'click sortable' => TRUE,
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+  );
 
 
   $data['twitter_account']['table']['group']  = t('Twitter');
