creof / doctrine2-spatial

Doctrine2 multi-platform support for spatial types and functions.
MIT License
272 stars 176 forks source link

Json Serializable #140

Open cermakondrej opened 8 years ago

cermakondrej commented 8 years ago

Is there some way to implement JSON Serializable interface to Point, Linestring etc. ? So it can be viewed by json_encode? I dont want to modify the vendor files directly, and i can't redeclare/override CrEOF\Spatial\PHP\Types\Geometry/Point(Linestring, etc) ...

ddproxy commented 8 years ago

We've updated recently to allow geometries to be converted to json (geojson) via a ->toJson() method. We haven't impemented the JSON Serializable interface yet but it's in the roadmap for the next major update to the library.

cermakondrej commented 8 years ago

But that's a method in the specific class, but if i have entity , that includes point, linestring etc, I would have to query to actualy get the point instance and then call toJson() instead of serializing whole entity or array of entities. The reason i want to implement json Serializable is the speed. I tried to use some JSON Serializing bundles, but serializing 3000 objects with those bundles to json takes aprox 8 seconds. With JSON Serializable it takes like 2-3 seconds ...

bucefal91 commented 6 years ago

I have filed a pull request - https://github.com/creof/doctrine2-spatial/pull/194