Changeset 12304

Show
Ignore:
Timestamp:
09/16/07 01:04:41 (1 year ago)
Author:
w_i
Message:

Added possibility to search for alternatives

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/org.routamc.positioning/config/manifest.inc

    r11719 r12304  
    99    0 => 'midcom_dba_classes.inc', 
    1010  ), 
    11   'version' => '1.1.2beta1', 
     11  'version' => '1.1.2beta3', 
    1212  'state' => 'beta', 
    1313  'package.xml' =>  
     
    2121        'email' => 'henri.bergius@iki.fi', 
    2222        'role' => 'lead', 
     23      ), 
     24      'w_i' =>  
     25      array ( 
     26        'name' => 'Jerry Jalava', 
     27        'email' => 'jerry.jalava@gmail.com', 
     28        'role' => 'developer', 
    2329      ), 
    2430    ), 
  • trunk/midcom/org.routamc.positioning/exec/geocode.php

    r12268 r12304  
    11<?php 
    2 if (!isset($_GET['service'])) 
     2if (! isset($_GET['service'])) 
    33{ 
    44    $service = 'city'; 
     
    99} 
    1010 
    11 if (!isset($_GET['dir'])) 
     11if (! isset($_GET['dir'])) 
    1212{ 
    1313    $direction = ''; 
     
    1616{ 
    1717    $direction = 'reverse_'; 
     18} 
     19 
     20$options = array(); 
     21if (   isset($_GET['options']) 
     22    && is_array($_GET['options'])) 
     23{ 
     24    foreach ($_GET['options'] as $key => $value) 
     25    { 
     26        $options[$key] = $value;         
     27    } 
    1828} 
    1929 
     
    5161$method_name = "{$direction}geocode"; 
    5262 
    53 $position = $geocoder->$method_name($location); 
    54 if (is_null($position)) 
     63$positions = $geocoder->$method_name($location, $options); 
     64if (is_null($positions)) 
    5565{ 
    5666    $error_str = 'unknown'; 
     
    5969        $error_str = $geocoder->error;         
    6070    } 
    61     //$_MIDCOM->generate_error(MIDCOM_ERRCRIT, "Geocoding failed: {$error_str}"); 
    6271 
    6372    $_MIDCOM->header('HTTP/1.0 500 Server Error'); 
     
    7180$_MIDCOM->header("Content-type: text/xml; charset=UTF-8"); 
    7281 
    73 echo "<position>\n"; 
    74 foreach ($position as $key => $value
     82echo "<results>\n"; 
     83foreach ($positions as $position
    7584{ 
    76     echo "    <{$key}>{$value}</{$key}>\n"; 
     85    echo "    <position>\n"; 
     86    foreach ($position as $key => $value) 
     87    { 
     88        if (is_array($value)) 
     89        { 
     90            echo "        <{$key}>\n"; 
     91            foreach ($value as $sub_key => $sub_value) 
     92            { 
     93                echo "            <{$sub_key}>{$sub_value}</{$sub_key}>\n"; 
     94            } 
     95            echo "        </{$key}>\n"; 
     96        } 
     97        else 
     98        { 
     99            echo "        <{$key}>{$value}</{$key}>\n";             
     100        } 
     101    }     
     102    echo "    </position>\n"; 
    77103} 
    78 echo "</position>\n"; 
     104echo "</results>\n"; 
    79105?> 
  • trunk/midcom/org.routamc.positioning/geocoder/city.php

    r12268 r12304  
    3030     * @return Array containing geocoded information 
    3131     */ 
    32     function geocode($location
     32    function geocode($location, $options=array()
    3333    { 
    34         $position = array 
     34        $results = array(); 
     35         
     36        $parameters = array 
    3537        ( 
    36             'latitude' => null, 
    37             'longitude' => null, 
    38             'accuracy' => null, 
     38            'maxRows' => 1, 
    3939        ); 
     40         
     41        if (! empty($options)) 
     42        { 
     43            foreach ($options as $key => $value) 
     44            { 
     45                if (isset($parameters[$key])) 
     46                { 
     47                    $parameters[$key] = $value; 
     48                } 
     49            } 
     50        } 
     51         
     52        if ($parameters['maxRows'] < 1) 
     53        { 
     54            $parameters['maxRows'] = 1; 
     55        } 
    4056             
    4157        if (!isset($location['city'])) 
     
    5369            $qb->add_constraint('country', '=', $location['country']); 
    5470        } 
     71         
     72        $qb->set_limit($parameters['maxRows']); 
    5573        $matches = $qb->execute(); 
    56         if (count($matches) > 0) 
    57         { 
    58             $city_entry = $matches[0]; 
    59         } 
    60  
    61         if (is_null($city_entry)) 
     74         
     75        if (count($matches) < 1) 
    6276        { 
    6377            // Seek the city entry by alternate names via a LIKE query 
     
    7084            } 
    7185             
     86            $qb->set_limit($parameters['maxRows']); 
    7287            $matches = $qb->execute(); 
    73             if (count($matches) > 0) 
     88             
     89            if (count($matches) < 1) 
    7490            { 
    75                 $city_entry = $matches[0]; 
     91                $this->error = 'POSITIONING_CITY_NOT_FOUND'; 
     92                return null; 
     93            }             
     94        } 
     95         
     96        foreach ($matches as $city_entry) 
     97        { 
     98            $city_coordinates = array 
     99            ( 
     100                'latitude'  => $city->latitude, 
     101                'longitude' => $city->longitude, 
     102            ); 
     103 
     104            $position = array(); 
     105            $position['latitude' ] = $city_entry->latitude; 
     106            $position['longitude' ] = $city_entry->longitude; 
     107            $position['distance'] = array 
     108            ( 
     109                'meters' => 0, 
     110                'bearing' => null, 
     111            ); 
     112            $position['city' ] = $city_entry->city; 
     113            $position['region' ] = $city_entry->region; 
     114            $position['country' ] = $city_entry->country; 
     115            $position['postalcode' ] = null; 
     116            $position['alternate_names'] = $city->alternatenames; 
     117            $position['accuracy'] = ORG_ROUTAMC_POSITIONING_ACCURACY_CITY; 
     118             
     119            $results[] = $position; 
     120        } 
     121         
     122        return $results; 
     123    } 
     124     
     125    /** 
     126     * @param Array $coordinates Contains latitude and longitude values 
     127     * @param Array $options 
     128     * @return Array containing geocoded information 
     129     */ 
     130    function reverse_geocode($coordinates, $options=array()) 
     131    { 
     132        $results = array(); 
     133         
     134        $parameters = array 
     135        ( 
     136            'maxRows' => 1, 
     137        ); 
     138         
     139        if (! empty($options)) 
     140        { 
     141            foreach ($options as $key => $value) 
     142            { 
     143                if (isset($parameters[$key])) 
     144                { 
     145                    $parameters[$key] = $value; 
     146                } 
    76147            } 
    77148        } 
    78          
    79         if (is_null($city_entry)) 
     149 
     150        if (   !isset($coordinates['latitude']) 
     151            && !isset($coordinates['longitude'])) 
    80152        { 
    81             $this->error = 'POSITIONING_CITY_NOT_FOUND'; 
     153            $this->error = 'POSITIONING_MISSING_ATTRIBUTES'; 
    82154            return null; 
    83155        } 
    84156         
    85         $position['latitude' ] = $city_entry->latitude; 
    86         $position['longitude' ] = $city_entry->longitude; 
    87         $position['city' ] = $city_entry->city; 
    88         $position['region' ] = $city_entry->region; 
    89         $position['country' ] = $city_entry->country; 
    90         $position['accuracy'] = ORG_ROUTAMC_POSITIONING_ACCURACY_CITY; 
     157        $closest = org_routamc_positioning_utils::get_closest('org_routamc_positioning_city_dba', $coordinates, $parameters['maxRows']); 
    91158         
    92         return $position; 
    93     } 
    94      
    95     /** 
    96      * Empty default implementation, this won't do anything yet 
    97      * 
    98      * @param Array $coordinates Contains latitude and longitude values 
    99      * @return Array containing geocoded information 
    100      */ 
    101     function reverse_geocode($coordinates,$options=array()) 
    102     { 
    103         $this->error = 'METHOD_NOT_IMPLEMENTED';         
    104         return null; 
     159        if (empty($closest)) 
     160        { 
     161            $this->error = 'POSITIONING_DETAILS_NOT_FOUND'; 
     162            return null; 
     163        } 
     164         
     165        foreach ($closest as $city) 
     166        { 
     167            $city_coordinates = array 
     168            ( 
     169                'latitude'  => $city->latitude, 
     170                'longitude' => $city->longitude, 
     171            ); 
     172 
     173            $position = array(); 
     174            $position['latitude' ] = $city->latitude; 
     175            $position['longitude' ] = $city->longitude; 
     176            $position['distance'] = array 
     177            ( 
     178                'meters' => round( org_routamc_positioning_utils::get_distance($coordinates, $city_coordinates) * 1000 ), 
     179                'bearing' => org_routamc_positioning_utils::get_bearing($coordinates, $city_coordinates), 
     180            ); 
     181            $position['city'] = $city->city; 
     182            $position['region'] = $city->region; 
     183            $position['country'] = $city->country; 
     184            $position['alternate_names'] = $city->alternatenames; 
     185            $position['accuracy'] = ORG_ROUTAMC_POSITIONING_ACCURACY_GPS; 
     186 
     187            $results[] = $position; 
     188        } 
     189         
     190        return $results; 
    105191    } 
    106192} 
  • trunk/midcom/org.routamc.positioning/geocoder/geonames.php

    r12268 r12304  
    3030     * @return Array containing geocoded information 
    3131     */ 
    32     function geocode($location
     32    function geocode($location, $options=array()
    3333    { 
    34         $position = array 
     34        $results = array(); 
     35         
     36        $parameters = array 
    3537        ( 
    36             'latitude' => null, 
    37             'longitude' => null
    38             'accuracy' => null
     38            'radius' => null, 
     39            'maxRows' => 1
     40            'style' => 'FULL'
    3941        ); 
     42         
     43        if (! empty($options)) 
     44        { 
     45            foreach ($options as $key => $value) 
     46            { 
     47                if (isset($parameters[$key])) 
     48                { 
     49                    $parameters[$key] = $value; 
     50                } 
     51            } 
     52        } 
    4053             
    4154        if (   !isset($location['postalcode']) 
     
    5871        { 
    5972            $params[] = 'country=' . urlencode($location['country']); 
     73        } 
     74 
     75        foreach ($parameters as $key => $value) 
     76        { 
     77            if (! is_null($value)) 
     78            { 
     79                $params[] = "{$key}=" . urlencode($value); 
     80            } 
    6081        } 
    6182         
     
    7091            return null; 
    7192        } 
    72          
    73         $city_entry = $simplexml->code[0]; 
    74         $position['latitude' ] = (float) $city_entry->lat; 
    75         $position['longitude' ] = (float) $city_entry->lng; 
    76         $position['city' ] = (string) $city_entry->name; 
    77         $position['region' ] = (string) $city_entry->adminName2; 
    78         $position['country' ] = (string) $city_entry->countryCode; 
    79         $position['postalcode' ] = (string) $city_entry->postalcode; 
    80         $position['accuracy'] = ORG_ROUTAMC_POSITIONING_ACCURACY_CITY; 
    81  
    82         return $position; 
     93                 
     94        for ($i=0; $i<$parameters['maxRows']; $i++) 
     95        { 
     96            if (! isset($simplexml->code[$i])) 
     97            { 
     98                break; 
     99            } 
     100            $entry = $simplexml->code[$i]; 
     101             
     102            $position = array(); 
     103            $position['latitude' ] = (float) $entry->lat; 
     104            $position['longitude' ] = (float) $entry->lng; 
     105            $position['distance'] = array 
     106            ( 
     107                'meters' => round( (float) $entry->distance * 1000 ), 
     108                'bearing' => null, 
     109            ); 
     110            $position['city' ] = (string) $entry->name; 
     111            $position['region' ] = (string) $entry->adminName2; 
     112            $position['country' ] = (string) $entry->countryCode; 
     113            $position['postalcode' ] = (string) $entry->postalcode; 
     114            $position['alternate_names'] = (string) $entry->alternateNames; 
     115            $position['accuracy'] = ORG_ROUTAMC_POSITIONING_ACCURACY_CITY; 
     116             
     117            $results[] = $position; 
     118        } 
     119 
     120        return $results; 
    83121    } 
    84122     
     
    88126     * @return Array containing geocoded information 
    89127     */ 
    90     function reverse_geocode($coordinates,$options=array()) 
     128    function reverse_geocode($coordinates, $options=array()) 
    91129    { 
     130        $results = array(); 
     131         
    92132        $parameters = array 
    93133        ( 
    94             'radius' => null
    95             'maxRows' => null
    96             'style' => 'FULL' 
     134            'radius' => 10
     135            'maxRows' => 1
     136            'style' => 'FULL', 
    97137        ); 
    98138         
     
    128168         
    129169        $http_request = new org_openpsa_httplib(); 
    130         $response = $http_request->get('http://ws.geonames.org/findNearbyPlaceName?' . implode('&', $params)); 
     170        $url = 'http://ws.geonames.org/findNearbyPlaceName?' . implode('&', $params); 
     171        $response = $http_request->get($url); 
    131172        $simplexml = simplexml_load_string($response); 
    132  
     173         
    133174        if (   !isset($simplexml->geoname) 
    134175            || count($simplexml->geoname) == 0) 
     
    144185        } 
    145186         
    146         $entry = $simplexml->geoname[0]; 
    147         $position['latitude' ] = (float) $entry->lat; 
    148         $position['longitude' ] = (float) $entry->lng; 
    149         $position['city' ] = (string) $entry->name; 
    150         $position['region' ] = (string) $entry->adminName2; 
    151         $position['country' ] = (string) $entry->countryCode; 
    152         $position['accuracy'] = ORG_ROUTAMC_POSITIONING_ACCURACY_GPS; 
    153  
    154         return $position; 
     187        for ($i=0; $i<$parameters['maxRows']; $i++) 
     188        { 
     189            if (! isset($simplexml->geoname[$i])) 
     190            { 
     191                break; 
     192            } 
     193             
     194            $entry = $simplexml->geoname[$i]; 
     195 
     196            $entry_coordinates = array 
     197            ( 
     198                'latitude'  => (float) $entry->lat, 
     199                'longitude' => (float) $entry->lng, 
     200            ); 
     201 
     202            $meters = round( org_routamc_positioning_utils::get_distance($coordinates, $entry_coordinates) * 1000 ); 
     203            $entry_meters = round( (float) $entry->distance * 1000 ); 
     204             
     205            if ($entry_meters < $meters) 
     206            { 
     207                $meters = $entry_meters; 
     208            } 
     209             
     210            $position = array(); 
     211            $position['latitude' ] = (float) $entry->lat; 
     212            $position['longitude' ] = (float) $entry->lng; 
     213            $position['distance'] = array 
     214            ( 
     215                'meters' => $meters, 
     216                'bearing' => org_routamc_positioning_utils::get_bearing($coordinates, $entry_coordinates), 
     217            ); 
     218            $position['city'] = (string) $entry->name; 
     219            $position['region'] = (string) $entry->adminName2; 
     220            $position['country'] = (string) $entry->countryCode; 
     221            $position['postalcode' ] = (string) $entry->postalcode; 
     222            $position['alternate_names'] = (string) $entry->alternateNames; 
     223            $position['accuracy'] = ORG_ROUTAMC_POSITIONING_ACCURACY_GPS; 
     224 
     225            $results[] = $position;             
     226        } 
     227         
     228        return $results; 
    155229    } 
    156230} 
  • trunk/midcom/org.routamc.positioning/geocoder/yahoo.php

    r12268 r12304  
    3131     * @return Array containing geocoded information 
    3232     */ 
    33     function geocode($location
     33    function geocode($location, $options=array()
    3434    { 
    35         $position = array 
     35        $results = array(); 
     36         
     37        $parameters = array 
    3638        ( 
    37             'latitude' => null, 
    38             'longitude' => null, 
    39             'accuracy' => null, 
     39            'output' => 'xml', 
     40            'appid' => $this->_config->get('yahoo_application_key'), 
    4041        ); 
    41    
     42         
     43        if (! empty($options)) 
     44        { 
     45            foreach ($options as $key => $value) 
     46            { 
     47                if (isset($parameters[$key])) 
     48                { 
     49                    $parameters[$key] = $value; 
     50                } 
     51            } 
     52        } 
     53 
    4254        if (   !isset($location['postalcode']) 
    4355            && !isset($location['city'])) 
     
    4759        } 
    4860        $params = array(); 
    49         $params[] = 'appid=' . $this->_config->get('yahoo_application_key'); 
    50         $params[] = 'output=xml'; 
    5161 
    5262        if (isset($location['street'])) 
     
    6575        { 
    6676            $params[] = 'zip=' . urlencode($location['postalcode']); 
     77        } 
     78 
     79        foreach ($parameters as $key => $value) 
     80        { 
     81            if (! is_null($value)) 
     82            { 
     83                $params[] = "{$key}=" . urlencode($value); 
     84            } 
    6785        } 
    6886                
    6987        $http_request = new org_openpsa_httplib(); 
    70         $response = $http_request->get('http://local.yahooapis.com/MapsService/V1/geocode?' . implode('&', $params)); 
     88        $url = 'http://local.yahooapis.com/MapsService/V1/geocode?' . implode('&', $params); 
     89        $response = $http_request->get($url); 
    7190        $simplexml = simplexml_load_string($response); 
    7291 
    73         if (!isset($simplexml->Result->Latitude)) 
    74         { 
    75             $this->error = 'POSITIONING_CITY_NOT_FOUND'; 
    76             return null; 
    77         } 
    78          
    79         $position['latitude' ] = (float) $simplexml->Result->Latitude; 
    80         $position['longitude' ] = (float) $simplexml->Result->Longitude; 
    81         $position['street' ] = (string) $simplexml->Result->Address; 
    82         $position['city' ] = (string) $simplexml->Result->City; 
    83         $position['region' ] = (string) $simplexml->Result->State; 
    84         $position['country' ] = (string) $simplexml->Result->Country; 
    85         $position['postalcode' ] = (string) $simplexml->Result->Zip; 
    86         $position['accuracy'] = ORG_ROUTAMC_POSITIONING_ACCURACY_CITY; 
    87  
    88         // Cleaner cases, Yahoo! returns uppercase 
    89         $position['street'] = ucwords(strtolower($position['street'])); 
    90         $position['city'] = ucwords(strtolower($position['city'])); 
    91          
    92         foreach ($simplexml->Result->attributes() as $key => $val) 
    93         { 
    94             if ($key == 'warning') 
    95             { 
    96                 $this->error = $val; 
    97             } 
    98             if ($key == 'precision') 
    99             { 
    100                 switch ($val) 
    101                 { 
    102                     case 'address': 
    103                         $position['accuracy'] = ORG_ROUTAMC_POSITIONING_ACCURACY_ADDRESS; 
    104                         break; 
    105                     case 'street': 
    106                         $position['accuracy'] = ORG_ROUTAMC_POSITIONING_ACCURACY_STREET; 
    107                         break;                     
    108                     default: 
    109                         $position['accuracy'] = ORG_ROUTAMC_POSITIONING_ACCURACY_CITY; 
    110                         break; 
    111                 } 
    112             } 
    113         } 
    114  
    115         return $position; 
     92        if (   !isset($simplexml->Result) 
     93            || empty($simplexml->Result)) 
     94        { 
     95            $this->error = 'POSITIONING_DETAILS_NOT_FOUND'; 
     96            return null; 
     97        } 
     98         
     99        if (   !isset($options['maxRows']) 
     100            || $options['maxRows'] < 0) 
     101        { 
     102            $options['maxRows'] = 1; 
     103        } 
     104         
     105        for ($i=0; $i<$options['maxRows']; $i++) 
     106        { 
     107            if (! isset($simplexml->Result[$i])) 
     108            { 
     109                break; 
     110            } 
     111             
     112            $entry = $simplexml->Result[$i];             
     113             
     114            $position = array(); 
     115            $position['latitude'] = (float) $entry->Latitude; 
     116            $position['longitude'] = (float) $entry->Longitude; 
     117            $position['street'] = (string) $entry->Address; 
     118            $position['city'] = (string) $entry->City; 
     119            $position['region'] = (string) $entry->State; 
     120            $position['country'] = (string) $entry->Country; 
     121            $position['postalcode'] = (string) $entry->Zip; 
     122            $position['accuracy'] = ORG_ROUTAMC_POSITIONING_ACCURACY_CITY; 
     123 
     124            // Cleaner cases, Yahoo! returns uppercase 
     125            $position['street'] = ucwords(strtolower($position['street'])); 
     126            $position['city'] = ucwords(strtolower($position['city'])); 
     127 
     128            foreach ($entry->attributes() as $key => $val) 
     129            { 
     130                if ($key == 'warning') 
     131                { 
     132                    $this->error = $val; 
     133                } 
     134                if ($key == 'precision') 
     135                { 
     136                    switch ($val) 
     137                    { 
     138                        case 'address': 
     139                            $position['accuracy'] = ORG_ROUTAMC_POSITIONING_ACCURACY_ADDRESS; 
     140                            break; 
     141                        case 'street': 
     142                            $position['accuracy'] = ORG_ROUTAMC_POSITIONING_ACCURACY_STREET; 
     143                            break;                     
     144                        default: 
     145                            $position['accuracy'] = ORG_ROUTAMC_POSITIONING_ACCURACY_CITY; 
     146                            break; 
     147                    } 
     148                } 
     149            } 
     150 
     151            $results[] = $position; 
     152        } 
     153 
     154        return $results; 
    116155    } 
    117156     
    118157    /** 
    119158     * Empty default implementation, this won't do anything yet 
     159     * Temporarily added geonames reverse geocoding here so we get atleast some results... 
    120160     * 
    121161     * @param Array $coordinates Contains latitude and longitude values 
    122162     * @return Array containing geocoded information 
    123163     */ 
    124     function reverse_geocode($coordinates,$options=array()) 
     164    function reverse_geocode($coordinates, $options=array()) 
    125165    { 
    126         $this->error = 'METHOD_NOT_IMPLEMENTED';         
    127         return null; 
     166        // $this->error = 'METHOD_NOT_IMPLEMENTED';         
     167        // return null; 
     168        $results = array(); 
     169         
     170        $parameters = array 
     171        ( 
     172            'radius' => 10, 
     173            'maxRows' => 1, 
     174            'style' => 'FULL', 
     175        ); 
     176         
     177        if (! empty($options)) 
     178        { 
     179            foreach ($options as $key => $value) 
     180            { 
     181                if (isset($parameters[$key])) 
     182                { 
     183                    $parameters[$key] = $value; 
     184                } 
     185            } 
     186        } 
     187             
     188        if (   !isset($coordinates['latitude']) 
     189            && !isset($coordinates['longitude'])) 
     190        { 
     191            $this->error = 'POSITIONING_MISSING_ATTRIBUTES'; 
     192            return null; 
     193        } 
     194        $params = array(); 
     195         
     196        $params[] = 'lat=' . urlencode($coordinates['latitude']); 
     197        $params[] = 'lng=' . urlencode($coordinates['longitude']); 
     198         
     199        foreach ($parameters as $key => $value) 
     200        { 
     201            if (! is_null($value)) 
     202            { 
     203                $params[] = "{$key}=" . urlencode($value); 
     204            } 
     205        } 
     206         
     207        $http_request = new org_openpsa_httplib(); 
     208        $url = 'http://ws.geonames.org/findNearbyPlaceName?' . implode('&', $params); 
     209        $response = $http_request->get($url); 
     210        $simplexml = simplexml_load_string($response); 
     211         
     212        if (   !isset($simplexml->geoname) 
     213            || count($simplexml->geoname) == 0) 
     214        { 
     215            $this->error = 'POSITIONING_DETAILS_NOT_FOUND'; 
     216             
     217            if (isset($simplexml->status)) 
     218            { 
     219                $constant_name = strtoupper(str_replace(" ", "_",$simplexml->status)); 
     220                $this->error = $constant_name; 
     221            } 
     222            return null; 
     223        } 
     224         
     225        for ($i=0; $i<$parameters['maxRows']; $i++) 
     226        { 
     227            if (! isset($simplexml->geoname[$i])) 
     228            { 
     229                break; 
     230            } 
     231             
     232            $entry = $simplexml->geoname[$i]; 
     233 
     234            $entry_coordinates = array 
     235            ( 
     236                'latitude'  => (float) $entry->lat, 
     237                'longitude' => (float) $entry->lng, 
     238            ); 
     239 
     240            $meters = round( org_routamc_positioning_utils::get_distance($coordinates, $entry_coordinates) * 1000 ); 
     241            $entry_meters = round( (float) $entry->distance * 1000 ); 
     242             
     243            if ($entry_meters < $meters) 
     244            { 
     245                $meters = $entry_meters; 
     246            } 
     247             
     248            $position = array(); 
     249            $position['latitude' ] = (float) $entry->lat; 
     250            $position['longitude' ] = (float) $entry->lng; 
     251            $position['distance'] = array 
     252            ( 
     253                'meters' => $meters, 
     254                'bearing' => org_routamc_positioning_utils::get_bearing($coordinates, $entry_coordinates), 
     255            ); 
     256            $position['city'] = (string) $entry->name; 
     257            $position['region'] = (string) $entry->adminName2; 
     258            $position['country'] = (string) $entry->countryCode; 
     259            $position['postalcode' ] = (string) $entry->postalcode; 
     260            $position['alternate_names'] = (string) $entry->alternateNames; 
     261            $position['accuracy'] = ORG_ROUTAMC_POSITIONING_ACCURACY_GPS; 
     262 
     263            $results[] = $position;             
     264        } 
     265         
     266        return $results; 
    128267    } 
    129268}