Skip to content
Permalink
Browse files

memory and performance optimization: fix getMapObject SQL query (lng/…

…lat rectangle)

fixes #205
  • Loading branch information...
vpithart authored and LarsMichelsen committed Jul 11, 2019
1 parent 8455e02 commit 8e958fe101002ae4772cdf29532554bfcb1c402c
Showing with 12 additions and 11 deletions.
  1. +1 −0 ChangeLog
  2. +11 −11 share/server/core/sources/worldmap.php
@@ -6,6 +6,7 @@ Core:
Worldmap:
* Consistent page reloads: center + zoom of the map kept in URL
* Memory and performance optimization: line rendering - clip long lines protruding out of viewport
* Memory and performance optimization: fix getMapObject SQL query (lng/lat rectangle)

Frontend
* FIX: Fix creating users when mbstring extension is not available
@@ -159,18 +159,12 @@ function worldmap_get_objects_by_bounds($sw_lng, $sw_lat, $ne_lng, $ne_lat) {
global $DB;
worldmap_init_db();
if ($sw_lat > $ne_lat) swap($sw_lat, $ne_lat);
if ($sw_lng > $ne_lng) swap($sw_lng, $ne_lng);
$q = 'SELECT lat, lng, lat2, lng2, object FROM objects WHERE'
.'((:sw_lat < :ne_lat AND lat BETWEEN :sw_lat AND :ne_lat)'
.' OR (:ne_lat < :sw_lat AND lat BETWEEN :ne_lat AND :sw_lat)'
.'AND '
.'(:sw_lng < :ne_lng AND lng BETWEEN :sw_lng AND :ne_lng)'
.' OR (:ne_lng < :sw_lng AND lng BETWEEN :ne_lng AND :sw_lng))'
.'OR '
.'((:sw_lat < :ne_lat AND lat2 BETWEEN :sw_lat AND :ne_lat)'
.' OR (:ne_lat < :sw_lat AND lat2 BETWEEN :ne_lat AND :sw_lat)'
.'AND '
.'(:sw_lng < :ne_lng AND lng2 BETWEEN :sw_lng AND :ne_lng)'
.' OR (:ne_lng < :sw_lng AND lng2 BETWEEN :ne_lng AND :sw_lng))';
.'(lat BETWEEN :sw_lat AND :ne_lat AND lng BETWEEN :sw_lng AND :ne_lng)'
.'OR (lat2 BETWEEN :sw_lat AND :ne_lat AND lng2 BETWEEN :sw_lng AND :ne_lng)';
$RES = $DB->query($q, array('sw_lng' => $sw_lng, 'sw_lat' => $sw_lat, 'ne_lng' => $ne_lng, 'ne_lat' => $ne_lat));
$objects = array();
@@ -377,4 +371,10 @@ function changed_worldmap($MAPCFG, $compare_time) {
return !file_exists($db_path) || filemtime($db_path) > $compare_time;
}
function swap(&$x, &$y) {
$tmp=$x;
$x=$y;
$y=$tmp;
}
?>

0 comments on commit 8e958fe

Please sign in to comment.
You can’t perform that action at this time.