Преглед изворни кода

Optymalizacja EpsgConversion::GetZByWgs84/GetZByEpsg2180

Mariusz Muszyński пре 8 година
родитељ
комит
a7d9428dc1
1 измењених фајлова са 16 додато и 2 уклоњено
  1. 16 2
      SE/se-lib/EpsgConversion.php

+ 16 - 2
SE/se-lib/EpsgConversion.php

@@ -2,7 +2,15 @@
 
 
 class Complex {
 class Complex {
 	private $real = 0; 
 	private $real = 0; 
-	private $imag = 0; 
+	private $imag = 0;
+
+	public function __debugInfo() {
+		return null;
+	}
+
+	public function __invoke() {
+		return null;
+	}
 
 
 	public function __construct($real = 0, $imag = 0) {
 	public function __construct($real = 0, $imag = 0) {
 		if ($real instanceof Complex) {
 		if ($real instanceof Complex) {
@@ -328,7 +336,13 @@ class EpsgConversion {
 	public static function GetZByEpsg2180($x, $y) {
 	public static function GetZByEpsg2180($x, $y) {
 		if (!(is_numeric($x) && is_numeric($y))) throw new Exception('Bad argument(s)');
 		if (!(is_numeric($x) && is_numeric($y))) throw new Exception('Bad argument(s)');
 		$table = 'CODGIK_NMT_100_EPSG2180';
 		$table = 'CODGIK_NMT_100_EPSG2180';
-		$query = "select x(`the_geom`) as `x`, y(`the_geom`) as `y`, `z` from `{$table}` where abs(x(`the_geom`) - {$x}) < 100 and abs(y(`the_geom`) - {$y}) < 100";
+		//$query = "select x(`the_geom`) as `x`, y(`the_geom`) as `y`, `z` from `{$table}` where abs(x(`the_geom`) - {$x}) < 100 and abs(y(`the_geom`) - {$y}) < 100";
+		$x1 = round(floor($x / 100) * 100);
+		$x2 = round(ceil($x / 100) * 100);
+		$y1 = round(floor($y / 100) * 100);
+		$y2 = round(ceil($y / 100) * 100);
+		$query = "select `x`, `y`, `z` from `{$table}` where (`x` = {$x1} and `y` = {$y1}) or (`x` = {$x1} and `y` = {$y2}) or (`x` = {$x2} and `y` = {$y1}) or (`x` = {$x2} and `y` = {$y2})";
+
 		try {
 		try {
 			$result = DB::getPDO()->fetchAll($query);
 			$result = DB::getPDO()->fetchAll($query);
 		} catch (Exception $e) {
 		} catch (Exception $e) {