Browse Source

Improve batch read for GeoJSON

Maurits van der Schee 5 years ago
parent
commit
edbb4dcadb
2 changed files with 4 additions and 4 deletions
  1. 2
    2
      api.php
  2. 2
    2
      src/Tqdev/PhpCrudApi/Controller/GeoJsonController.php

+ 2
- 2
api.php View File

@@ -2818,9 +2818,9 @@ class GeoJsonController
2818 2818
         $params = RequestUtils::getParams($request);
2819 2819
         if (strpos($id, ',') !== false) {
2820 2820
             $ids = explode(',', $id);
2821
-            $result = [];
2821
+            $result = (object) array('type' => 'FeatureCollection', 'features' => array());
2822 2822
             for ($i = 0; $i < count($ids); $i++) {
2823
-                array_push($result, $this->service->read($table, $ids[$i], $params));
2823
+                array_push($result->features, $this->service->read($table, $ids[$i], $params));
2824 2824
             }
2825 2825
             return $this->responder->success($result);
2826 2826
         } else {

+ 2
- 2
src/Tqdev/PhpCrudApi/Controller/GeoJsonController.php View File

@@ -45,9 +45,9 @@ class GeoJsonController
45 45
         $params = RequestUtils::getParams($request);
46 46
         if (strpos($id, ',') !== false) {
47 47
             $ids = explode(',', $id);
48
-            $result = [];
48
+            $result = (object) array('type' => 'FeatureCollection', 'features' => array());
49 49
             for ($i = 0; $i < count($ids); $i++) {
50
-                array_push($result, $this->service->read($table, $ids[$i], $params));
50
+                array_push($result->features, $this->service->read($table, $ids[$i], $params));
51 51
             }
52 52
             return $this->responder->success($result);
53 53
         } else {

Loading…
Cancel
Save