|
|
@@ -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)
|