-
-
Notifications
You must be signed in to change notification settings - Fork 265
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
Allow importing KML with empty geometries. #510 #511
Conversation
a7f47d7
to
16ed2e5
Compare
Force push to add fix to README.md |
@@ -119,6 +119,11 @@ public function denormalize($data, $type, $format = NULL, array $context = []) { | |||
// Load KML into a Geometry object. | |||
$geometry = $this->geoPHP->load($placemark['xml'], 'kml'); | |||
|
|||
// Create an empty collection if no geometry was loaded. | |||
if (empty($geometry)) { | |||
$geometry = new \GeometryCollection(); |
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.
I wonder if it makes sense to add use GeometryCollection;
to the top of the file and change this to:
$geometry = new GeometryCollection();
Same effect, but feels like it would be more consistent to add a use
statement in this case, even though phayes/GeometryCollection
doesn't use namespaces.
I wonder if there's any benefit to consistency in this regard, like IDE integration, code sniffing, etc...
Curious your thoughts on this (very minor) thought @paul121 - doesn't need to be a blocker for merging this, I don't think, but worth considering?
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.
Oh interesting, yeah I don't see any problem with that, as long as it works! Normally PHPStorm would add that automatically for me but it's possible I typed it in differently without using any type helpers.
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.
Cool! I can make that change and amend your commit.
Create an empty collection if no geometry was loaded.
16ed2e5
to
3c5b2c7
Compare
Pushed that change - do you want to give it one more test @paul121? I didn't test it, but PHPStorm recognizes |
Great, tested & works great! |
Hey @mstenta this change actually created a code sniffer violation:
|
Of course it did. 🙄 Should have left well enough alone... |
… with use statements #511 See #511 (comment)
Pushed a commit that changes this back to the way you had it originally @paul121 👍 |
A simple fix for the bug identified in #510
Attaching a screenshot that shows the result of parsing the following placemark: