Browse Source

Some GeoJSON fixes

Maurits van der Schee 6 years ago
parent
commit
d03449f087

+ 2
- 0
src/Tqdev/PhpCrudApi/GeoJson/GeoJsonService.php View File

55
     {
55
     {
56
         $geometryParam = isset($params['geometry']) ? $params['geometry'][0] : '';
56
         $geometryParam = isset($params['geometry']) ? $params['geometry'][0] : '';
57
         $geometryColumnName = $this->getGeometryColumnName($tableName, $geometryParam);
57
         $geometryColumnName = $this->getGeometryColumnName($tableName, $geometryParam);
58
+        $params['mandatory'][] = $tableName . "." . $geometryColumnName;
58
         $records = $this->records->_list($tableName, $params);
59
         $records = $this->records->_list($tableName, $params);
59
 
60
 
60
         $features = array();
61
         $features = array();
68
     {
69
     {
69
         $geometryParam = isset($params['geometry']) ? $params['geometry'][0] : '';
70
         $geometryParam = isset($params['geometry']) ? $params['geometry'][0] : '';
70
         $geometryColumnName = $this->getGeometryColumnName($tableName, $geometryParam);
71
         $geometryColumnName = $this->getGeometryColumnName($tableName, $geometryParam);
72
+        $params['mandatory'][] = $tableName . "." . $geometryColumnName;
71
         $record = $this->records->read($tableName, $id, $params);
73
         $record = $this->records->read($tableName, $id, $params);
72
         return $this->convertRecordToFeature($record, $geometryColumnName);
74
         return $this->convertRecordToFeature($record, $geometryColumnName);
73
     }
75
     }

+ 3
- 3
tests/functional/001_records/083_list_users_as_geojson.log View File

6
 
6
 
7
 {"type":"FeatureCollection","features":[{"type":"Feature","properties":{"id":1,"username":"user1","password":"testtest2"},"geometry":{"type":"Point","coordinates":[30,20]}},{"type":"Feature","properties":{"id":2,"username":"user2","password":"pass2"},"geometry":null}]}
7
 {"type":"FeatureCollection","features":[{"type":"Feature","properties":{"id":1,"username":"user1","password":"testtest2"},"geometry":{"type":"Point","coordinates":[30,20]}},{"type":"Feature","properties":{"id":2,"username":"user2","password":"pass2"},"geometry":null}]}
8
 ===
8
 ===
9
-GET /geojson/users?geometry=location
9
+GET /geojson/users?geometry=location&include=username
10
 ===
10
 ===
11
 200
11
 200
12
 Content-Type: application/json
12
 Content-Type: application/json
13
-Content-Length: 269
13
+Content-Length: 213
14
 
14
 
15
-{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"id":1,"username":"user1","password":"testtest2"},"geometry":{"type":"Point","coordinates":[30,20]}},{"type":"Feature","properties":{"id":2,"username":"user2","password":"pass2"},"geometry":null}]}
15
+{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"username":"user1"},"geometry":{"type":"Point","coordinates":[30,20]}},{"type":"Feature","properties":{"username":"user2"},"geometry":null}]}
16
 ===
16
 ===
17
 GET /geojson/users?geometry=notlocation
17
 GET /geojson/users?geometry=notlocation
18
 ===
18
 ===

Loading…
Cancel
Save