Skip to content

Commit d03449f

Browse files
committed
Some GeoJSON fixes
1 parent b255669 commit d03449f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/Tqdev/PhpCrudApi/GeoJson/GeoJsonService.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public function _list(string $tableName, array $params): FeatureCollection
5555
{
5656
$geometryParam = isset($params['geometry']) ? $params['geometry'][0] : '';
5757
$geometryColumnName = $this->getGeometryColumnName($tableName, $geometryParam);
58+
$params['mandatory'][] = $tableName . "." . $geometryColumnName;
5859
$records = $this->records->_list($tableName, $params);
5960

6061
$features = array();
@@ -68,6 +69,7 @@ public function read(string $tableName, string $id, array $params): Feature
6869
{
6970
$geometryParam = isset($params['geometry']) ? $params['geometry'][0] : '';
7071
$geometryColumnName = $this->getGeometryColumnName($tableName, $geometryParam);
72+
$params['mandatory'][] = $tableName . "." . $geometryColumnName;
7173
$record = $this->records->read($tableName, $id, $params);
7274
return $this->convertRecordToFeature($record, $geometryColumnName);
7375
}

tests/functional/001_records/083_list_users_as_geojson.log

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ Content-Length: 269
66

77
{"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}]}
88
===
9-
GET /geojson/users?geometry=location
9+
GET /geojson/users?geometry=location&include=username
1010
===
1111
200
1212
Content-Type: application/json
13-
Content-Length: 269
13+
Content-Length: 213
1414

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}]}
1616
===
1717
GET /geojson/users?geometry=notlocation
1818
===

0 commit comments

Comments
 (0)