Piotr Labudda 9 лет назад
Родитель
Сommit
4cea45ec82
2 измененных файлов с 21 добавлено и 9 удалено
  1. 5 3
      SE/se-lib/Api/WfsLogger.php
  2. 16 6
      SE/se-lib/Api/WfsServerBase.php

+ 5 - 3
SE/se-lib/Api/WfsLogger.php

@@ -1,5 +1,7 @@
 <?php
 
+Lib::loadClass('Request');
+
 class Api_WfsLogger {
 
 	protected $_reqId;
@@ -17,9 +19,9 @@ class Api_WfsLogger {
 	}
 
 	public function reqDBG($request) {
-		$reqLog = "{$_SERVER['REQUEST_METHOD']} {$_SERVER['REQUEST_URI']}";
-		if ($_SERVER['REQUEST_METHOD'] == 'POST') $reqLog .= "\n------------ POST:\n" . Request::getRequestBody();
-		if (!empty($request)) $reqLog .= "\n------------ request: " . json_encode($request);
+		$reqLog = "{$_SERVER['REQUEST_METHOD']} " . Request::getHostUri() . "{$_SERVER['REQUEST_URI']}";
+		if ($_SERVER['REQUEST_METHOD'] == 'POST') $reqLog .= "\n------------ POST:\n" . substr(Request::getRequestBody(), 0, 1000);
+		// if (!empty($request)) $reqLog .= "\n------------ request: " . substr(json_encode($request), 0, 1000);
 		$this->DBG($reqLog);
 	}
 

+ 16 - 6
SE/se-lib/Api/WfsServerBase.php

@@ -112,12 +112,22 @@ class Api_WfsServerBase {
 		$args['bbox'] = V::get('bbox', '', $lowerArgs);
 		if (!empty($args['bbox'])) {
 			// BBOX may have EPSG at then end - example: ",EPSG:4326"
-			if (!preg_match("/^\d+(.\d+)?,\d+(.\d+)?,\d+(.\d+)?,\d+(.\d+)?(\,EPSG:\d+)?$/", $args['bbox'], $matches)) throw new Exception("Wrong param BBOX");
-			if (preg_match("/\,EPSG:\d+$/", $args['bbox'], $matches)) {
-				$args['bbox'] = substr($args['bbox'], 0, strlen($args['bbox']) - strlen($matches[0]));
-			}
-			if (!preg_match("/^\d+(.\d+)?,\d+(.\d+)?,\d+(.\d+)?,\d+(.\d+)?$/", $args['bbox'], $matches)) throw new Exception("Illegal BBOX format");
-			$searchParams['f_the_geom'] = "BBOX:{$args['bbox']}";
+			$num = "\d+.?\d*?";// "\d+(.\d+)?"
+			if (!preg_match("/^({$num}),({$num}),({$num}),({$num})(\,EPSG:\d+)?$/", $args['bbox'], $matches)) throw new Exception("Illegal BBOX format");
+			// QGIS may send BBOX in wrong order: 54.23580872176457,18.46844302390853,54.25220902538883,18.492990600812696
+			// first number should be smaller then second
+			// example $matches:
+			//     [0] => 18.492990600812696,54.23580872176457,18.46844302390853,54.25220902538883
+			//     [1] => 18.492990600812696
+			//     [2] => 54.23580872176457
+			//     [3] => 18.46844302390853
+			//     [4] => 54.25220902538883
+			// (optional) EPGS
+			$bboxPoints = ($matches[1] > $matches[2])
+				? [ $matches[2], $matches[3], $matches[4], $matches[1] ]
+				: [ $matches[1], $matches[2], $matches[3], $matches[4] ];
+
+			$searchParams['f_the_geom'] = "BBOX:" . implode(",", $bboxPoints);
 		}
 
 		$args['wfs:featureID'] = V::get('featureid', null, $lowerArgs);// TODO: allow multiply feature id (csv)