gisconverter.php: a kml <-> geojson <-> wkt converter
For my next personal project, I need to convert in php, geographic data between different formats. I need that, among other things to insert those data in postgis. Actually, postgis support a lot of data format as output formats, but quite few as input formats.
Instead of of integrating that to my main project, I decided to create a related autonomous project. So, I had to implement more features than strictly needed. But I think it's more profitable in the middle and long run.
- This library is separated from my application. So it's more easy to test, debug and extend.
- That allow other people to reuse it in their application more easily.
- That allow me to reuse it in my future application with zero reintegration work.
So, here is gisconverter.php
gisconverter.php only work with php 5.3 (and probably higher). php 5.3 has a few nice new features. So, I decided to not care about backward compatibility. I use namespaces so I can include it in my project without having to care about name conflict. I also use late static binding. It allow to use class constants. Prior to php 5.3, it was not possible to use class constants in derived classes. I also use closure quite a lot (along with array_map). It saved me a couple of lines of code, but I could easily have done without.
I also used phpunit to test the library. It allowed me have a really efficient workflow. I first write the tests, then I implement a method, and when all tests pass, I known my method is bug free. The tricky part is to write the tests correctly, to test the code thoroughly without being redundant. Now, I'd like to use phpunit in my main application. It's is a full website with a database, so I've not yet understood how to use it.