-
Notifications
You must be signed in to change notification settings - Fork 4
PHPLIB-1337 Add tests on Geospatial Query Operators #25
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,4 @@ arguments: | |
name: crs | ||
type: | ||
- object | ||
optional: true |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
use MongoDB\Exception\UnsupportedValueException; | ||
use stdClass; | ||
|
||
use function array_key_exists; | ||
use function array_key_first; | ||
use function assert; | ||
use function get_debug_type; | ||
|
@@ -182,7 +183,19 @@ private function encodeAsDollarObject(OperatorInterface $value): stdClass | |
continue; | ||
} | ||
|
||
$result->{'$' . $key} = $this->recursiveEncode($val); | ||
$val = $this->recursiveEncode($val); | ||
|
||
if ($key === 'geometry') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We may want to consider introducing a special encoder for geo operators to extract this special logic. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For everything related to geometry, we need to be compatible with a GeoJSON library instead of creating a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree. Apart from a couple of libraries that saw their last updates 9 years ago, the only PHP libraries are found are jmikola/geojson which is supported in Doctrine ODM, and brick/geo which is still in a pre-release (0.x) state but saw its last update a little more than a year ago. I'll defer to @jmikola's expertise on this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tracking in PHPLIB-1364 |
||
if (is_object($val) && property_exists($val, '$geometry')) { | ||
$result->{'$geometry'} = $val->{'$geometry'}; | ||
} elseif (is_array($val) && array_key_exists('$geometry', $val)) { | ||
$result->{'$geometry'} = $val->{'$geometry'}; | ||
} else { | ||
$result->{'$geometry'} = $val; | ||
} | ||
} else { | ||
$result->{'$' . $key} = $val; | ||
} | ||
} | ||
|
||
return $this->wrap($value, $result); | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.