@@ -43,9 +43,12 @@ private function getGeometryColumnName(string $tableName, string $geometryParam)
43
43
44
44
private function convertRecordToFeature ( /*object*/ $ record , string $ geometryColumnName )
45
45
{
46
- $ geometry = Geometry::fromWkt ($ record [$ geometryColumnName ]);
47
- unset($ record [$ geometryColumnName ]);
48
- return new Feature ($ record , $ geometry );
46
+ $ geometry = null ;
47
+ if (isset ($ record [$ geometryColumnName ])) {
48
+ $ geometry = Geometry::fromWkt ($ record [$ geometryColumnName ]);
49
+ }
50
+ $ properties = array_diff_key ($ record , [$ geometryColumnName => true ]);
51
+ return new Feature ($ properties , $ geometry );
49
52
}
50
53
51
54
public function _list (string $ tableName , array $ params ): FeatureCollection
@@ -63,15 +66,11 @@ public function _list(string $tableName, array $params): FeatureCollection
63
66
return new FeatureCollection ($ features );
64
67
}
65
68
66
- public function read (string $ tableName , string $ id , array $ params ) /*: ? Feature*/
69
+ public function read (string $ tableName , string $ id , array $ params ): Feature
67
70
{
68
71
$ geometryParam = isset ($ params ['geometry ' ]) ? $ params ['geometry ' ] : '' ;
69
72
$ geometryColumnName = $ this ->getGeometryColumnName ($ tableName , $ geometryParam );
70
73
$ record = $ this ->records ->read ($ tableName , $ id , $ params );
71
- if (!isset ($ record [$ geometryColumnName ])) {
72
- print_r ($ record );
73
- return null ;
74
- }
75
74
return $ this ->convertRecordToFeature ($ record , $ geometryColumnName );
76
75
}
77
76
}
0 commit comments