Changeset 1229

Show
Ignore:
Timestamp:
09/19/10 19:45:42 (3 years ago)
Author:
d0nut
Message:

map update: only fetch data within boundaries

Location:
g-map
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • g-map/files/lib/page/MapAjaxPage.class.php

    r1226 r1229  
    1515class MapAjaxPage extends AbstractPage { 
    1616        protected $zoom = 0; 
    17         protected $distance = 10; 
     17        protected $distance = 35; 
    1818        protected $bounds= array(); 
    1919        protected $initialized = false; 
     
    3131                // ((50.08930948264218, 10.298652648925781), (50.14434619645057, 10.506362915039062)) 
    3232                if(isset($_GET['bounds'])) { 
    33                         if(preg_match('\((\d+\.?\d*), (\d+\.?\d*)\), \((\d+\.?\d*), (\d+\.?\d*)\)', $_GET['bounds'], $match)) { 
    34                                 $this->bounds = $match; 
     33                        if(preg_match('/^\(\((-?\d+\.?\d*), (-?\d+\.?\d*)\), \((-?\d+\.?\d*), (-?\d+\.?\d*)\)\)$/', $_GET['bounds'], $match)) { 
     34                                $this->bounds = array( 
     35                                        array( 
     36                                                'lat' => $match[1], 
     37                                                'lon' => $match[2] 
     38                                        ), 
     39                                        array( 
     40                                                'lat' => $match[3], 
     41                                                'lon' => $match[4] 
     42                                        ), 
     43                                ); 
     44 
     45                                // extra 30% 
     46                                $this->bounds[0]['lat'] -= abs($this->bounds[0]['lat'] - $this->bounds[1]['lat']) * 0.3; 
     47                                $this->bounds[1]['lat'] += abs($this->bounds[0]['lat'] - $this->bounds[1]['lat']) * 0.3; 
     48                                $this->bounds[0]['lon'] -= abs($this->bounds[0]['lon'] - $this->bounds[1]['lon']) * 0.3; 
     49                                $this->bounds[1]['lon'] += abs($this->bounds[0]['lon'] - $this->bounds[1]['lon']) * 0.3; 
    3550                        } 
    3651                } 
     
    5065                $sql = 'SELECT          X(pt) AS lon, 
    5166                                        Y(pt) AS lat 
    52                         FROM            wcf'.WCF_N.'_gmap_user'; 
     67                        FROM            wcf'.WCF_N.'_gmap_user 
     68                        WHERE           1'; 
     69                         
     70                if($this->bounds) { 
     71                        $sql .= ' AND X(pt) BETWEEN '.floatval($this->bounds[0]['lon']).' AND '.floatval($this->bounds[1]['lon']).' '; 
     72                        $sql .= ' AND Y(pt) BETWEEN '.floatval($this->bounds[0]['lat']).' AND '.floatval($this->bounds[1]['lat']).' '; 
     73                } 
    5374                         
    5475                if(!$this->initialized) { 
  • g-map/files/lib/system/event/listener/GMapUserPageListener.class.php

    r1226 r1229  
    5454                        )); 
    5555                        // if user position exists 
    56                         WCF::getTPL()->append('additionalBoxes2', WCF::getTPL()->fetch('userProfileMapSide')); 
     56                        WCF::getTPL()->append('additionalBoxes1', WCF::getTPL()->fetch('userProfileMapSide')); 
    5757                } 
    5858 
    5959                // if user is owner or user has personal maps 
    60                 if(WCF::getUser()->userID == $this->userID || $this->personal_maps) { 
     60                if(false && WCF::getUser()->userID == $this->userID || $this->personal_maps) { 
    6161                        WCF::getTPL()->append('additionalContents3', WCF::getTPL()->fetch('userProfileMapCenter')); 
    6262                } 
  • g-map/files/lib/system/event/listener/GMapUserProfileEditFormListener.class.php

    r1223 r1229  
    2020                $this->className = $className; 
    2121                 
    22                  
     22                $this->$eventName(); 
    2323        } 
    2424         
    2525        protected function saved() { 
    26                 if($this->eventObj->activeCategory == 'profile' && $eventName == 'saved') { 
     26                if($this->eventObj->activeCategory == 'profile') { 
    2727                        if(isset($this->eventObj->values['location']) && !empty($this->eventObj->values['location'])) { 
    2828                                 
    2929                                // update user location 
    30                                 // MapDiscover::update(); 
    31                                  
    32                                 // show info message if no location was found 
     30                                require_once(WCF_DIR.'lib/data/gmap/GmapApi.class.php'); 
     31                                $api = new GmapApi(); 
     32                                $point = $api->search($this->eventObj->values['location']); 
     33                         
     34                                if($point) { 
     35                                        $sql = "REPLACE INTO    wcf".WCF_N."_gmap_user 
     36                                                                (userID, pt) 
     37                                                VALUES          (".$this->eventObj->user->userID.", PointFromText('POINT(".$point['lon']." ".$point['lat'].")'))"; 
     38                                        WCF::getDB()->sendQuery($sql); 
     39                                } 
    3340                        } 
    3441                } 
  • g-map/optionals/de.gmap.wbb/files/lib/acp/action/UpdateMapAction.class.php

    r1225 r1229  
    4242                                        ".$col." AS loc 
    4343                        FROM            wcf".WCF_N."_user_option_value 
    44                         ORDER BY        userID"; 
     44                        WHERE           ".$col." != '' 
     45                        ORDER BY        userID ASC"; 
    4546                $result = WCF::getDB()->sendQuery($sql, $this->limit, ($this->limit * $this->loop)); 
    4647                while ($row = WCF::getDB()->fetchArray($result)) {