File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -138,6 +138,22 @@ public function testSpatialTypeDocuments(): void
138138 'notIntersects ' => Query::notIntersects ('pointAttr ' , [[1.0 , 1.0 ]])
139139 ];
140140
141+ $ result = $ database ->find ($ collectionName );
142+
143+ function decodePoint (string $ wkb ): array {
144+ // WKB format: 1-byte byte order + 4-byte type + 8-byte X + 8-byte Y
145+ // Skip first 5 bytes (1 byte byte order + 4 bytes type)
146+ $ coords = unpack ('dX/dY ' , substr ($ wkb , 5 , 16 ));
147+ return ['lon ' => $ coords ['X ' ], 'lat ' => $ coords ['Y ' ]];
148+ }
149+
150+ // Example usage:
151+ $ pointBinary = "\000\000\000\000\000\000\000\000\000\000\000\000\000@ \000\000\000\000\000\000@ " ;
152+ $ coords = decodePoint ($ pointBinary );
153+ print_r ($ coords );
154+
155+ var_dump ($ result );
156+ $ this ->assertEquals (999 ,888 );
141157 foreach ($ pointQueries as $ queryType => $ query ) {
142158 $ result = $ database ->find ($ collectionName , [$ query ], Database::PERMISSION_READ );
143159 $ this ->assertNotEmpty ($ result , sprintf ('Failed spatial query: %s on pointAttr ' , $ queryType ));
You can’t perform that action at this time.
0 commit comments