-
-
Notifications
You must be signed in to change notification settings - Fork 342
Add ParsePolygon Type and polygonContains query #327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good! Always cool to see new functionality coming to parse 👍 .
I'll wait for the requested changes and we'll go from there. Once the PR is merged in on the server I'll trigger Travis to rerun the test cases to see how that looks.
src/Parse/ParsePolygon.php
Outdated
*/ | ||
public function setCoordinates($coords) | ||
{ | ||
if (count($coords) < 3 || !is_array($coords)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move the array exception here into a separate check just above? It's close but the user should be informed that an array of coordinates is required when one is missing, just to be more specific about which is which.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I'll get on it
src/Parse/ParsePolygon.php
Outdated
$points = []; | ||
foreach ($coords as $coord) { | ||
$geoPoint = $coord; | ||
if (is_array($coord)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're only adding this coordinate set if it's an array we should probably add another check here instead of silently skipping entries. Something that expects $coord
to not only be an array, but to also contain a lat and long.
src/Parse/ParsePolygon.php
Outdated
if (is_array($coord)) { | ||
$geoPoint = new ParseGeoPoint($coord[0], $coord[1]); | ||
} | ||
$points[] = [$geoPoint->getLatitude(), $geoPoint->getLongitude()]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A note that currently this would fail if you pass something that's not an array by accident, like a string, as it would try to run $geoPoint->get...
on an object that's not necessarily a GeoPoint. If you add the check mentioned just above this shouldn't be a problem anymore though, as you would be able to safely create a new ParseGeoPoint and add it after the check.
It looks like you're expecting users to either supply an array of coords or a ParseGeoPoint
instance. To that end you could add an additional check as an else if
to ensure that if the object is not an array it is at least an instance of ParseGeoPoint
. If $coords
is neither of those it would be safe to throw an exception stating that one or the other is required to proceed.
$obj->set('polygon', $polygon); | ||
$obj->save(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming you add the aforementioned exceptions to further scrutinize the input to ParsePolygon
, you would have to add a couple cases here for firing the other conditions.
There's an added benefit of mixing and matching points and geopoints |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me! Thanks for putting all this up.
I'll leave this on ice for the moment until the pending functionality is in place server-side ☃️. Once that's done we can rerun the CI and see how it goes. Assuming everything comes out good I'll approve the changes and we'll move onto getting this added in!
src/Parse/ParsePolygon.php
Outdated
} | ||
$points = []; | ||
foreach ($coords as $coord) { | ||
$geoPoint = $coord; | ||
if (is_array($coord)) { | ||
$geoPoint; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't really need this here, lexical scoping doesn't apply in this case for php.
However...with that said I imagine some IDEs would like to highlight later uses as 'potentially undefined', even though the final case is throwing an exception. With that in mind this is okay to leave here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow I didn't know that. Thanks for the knowledge.
now it's merged! |
* Add lint * update travis * coding style * add coverage to gitignore * removed ignore lines * nit
* Corrects and updates phpdoc references/errors * Lint fixes
Adds a **Getting Started** section to README.md to direct newcomers to the [official guide](http://docs.parseplatform.org/php/guide/) and [API reference](http://parseplatform.org/parse-php-sdk/namespaces/Parse.html).
* Removed default api and added appropriate checking * lint
* Added 'document-check' to add phpdoc checking during tests and added deploy for api ref on gh-pages * Wrapping filename in quotes * Moved bash out of package.json * Unescaping strings * Testing missing block comment * Fixing lint exception to expose phpdoc style issue * Restored class summary * removed comment
Whoops looks like the |
@dplewis tests look good! What's causing this to fail out is the In this case it seems you need a summary for ParsePolygon.php. You can check this against the other src files, like the top of ParseACL.php for example. <?php
/**
* Class ParseACL | Parse/ParseACL.php
*/ |
@montymxb I figured something like that would happen. I fixed the summary documentation. |
@montymxb no problem |
Looks like updating composer dependencies allowed me to replicate this locally. It would appear a package has been updated between yesterday and today that is tripping this :/ . I'll keep digging and see how we can patch this up. |
@dplewis the culprit is jms/serializer, referenced internally by It was updated to 1.8.0 earlier this morning. Locally specifying the prior 1.7.1 corrects this issue like so in composer.json under "jms/serializer": "1.7.1" I'll put up a separate PR to fix this and merge it in real quick, then we can go from there. |
* Pinned jms/serializer to 1.7.1 * Checking to update jms/serializer to 1.8.0 ONLY on php 5.4 for travis-ci * Added comment, and added graphviz for class diagrams in generated api docs
Codecov Report
@@ Coverage Diff @@
## master #327 +/- ##
==========================================
+ Coverage 98.04% 98.78% +0.74%
==========================================
Files 35 35
Lines 2708 2727 +19
==========================================
+ Hits 2655 2694 +39
+ Misses 53 33 -20
Continue to review full report at Codecov.
|
Finally, alright I'll give this just another quick check and we should be good to go! |
@dplewis nearly 3 weeks later but it's finally in 👍 . Looks like you can attend to those other sdks as needed now. Thanks again for adding in this functionality! |
Since each update to the master is now automatically deployed to |
That diagram looks pretty cool |
parse-community/parse-server#3944
Added ParsePolygon Type created from Array of Coordinates or ParseGeoPoints
Added polygonContains to query.
I'm using PHP as a base for updating the other sdks.
Let me know if any more tests are needed or additional functionality.