-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
IO GeoJSON Support #13
Comments
Hi Michael, sure, I welcome pull requests! This would fit very well as standalone reader/writer classes in the |
I have not dug in too much yet, but I am hoping to get some time this weekend. P.S: Great Lib and thanks for writing it! |
@BenMorel : I 100% see what you mean by the Question: NOTE: I could see an argument for accepting GeoJSON |
@BenMorel Apologies for the long question... I think I just answered my own question. It looks like the other Parsers throw a Unless you specify otherwise, I will stick to this standard, and new "types" can be added to the parser as development continues. 👍 |
Hi Michael,
I've never used GeoJSON myself, but after a quick look, it looks to me that a GeoJSON object contains either a If this is correct, I would convert to GeoJSON object to:
IIRC, this is when reading a WKT that would contain an unsupported type; this should not be necessary here, as all Geometry types in the GeoJSON spec are supported by this library! |
@BenMorel In reply to The first version of the GeoJSON read, I don't plan to implement |
I don't think this should be hard to add straight away, maybe it's worth thinking about it from the beginning? Something like: public function readGeometry(array $geoJsonObject) : Geometry
{
switch (strtolower($geoJsonObject['type'])) {
case 'feature':
return $this->readGeometryFromFeature($geoJsonObject);
case 'featurecollection':
$geometries = [];
foreach ($geoJsonObject['features'] as $feature) {
$geometries[] = $this->readGeometryFromFeature($feature);
}
return GeometryCollection::of(...$geometries);
}
private function readGeometryFromFeature(array $feature) : Geometry
{
$geometry = $feature['geometry'];
switch (strtolower($geometry['type'])) {
// ...
}
} |
Good idea @BenMorel! I apparently overlooked the ability to return a Note: I have to run for a while but hope to continue working on the Pull Request later tonight/this weekend. |
@BenMorel: GeoJSON "read" functionality is complete. I am about to start on "write" functionality 👍 |
First Pull Request Review Complete: (For Tracking) |
Pull Request update: All review items have been resolved. We should be going into final Tweaks 👍 |
Released as 0.2.2. Thank you! |
Note: I added docs about import/export formats to the README, including GeoJSON! |
This is great @BenMorel |
I actually went ahead and added the case-insensitive read and pretty-print write functionality! Please go ahead if you want to add KML support now 👍 |
@BenMorel you beat me to it! Thanks for taking the time to do this. I am actually looking into |
Good point, I see that in the RFC. I created issue #15 to track this. |
@BenMorel : It looks like Geojson, KML, etc... is not currently supported. If a Pull Request came in that expanded the ability to Init and ToString multiple Geo String Types, would you be up for reviewing / merging?
The text was updated successfully, but these errors were encountered: