geoPHP
geoPHP copied to clipboard
Support Read and Write TopoJSON format
Please support TopoJSON as input/output format.
:+1:
Keep in mind that KML, Geojson, WKT, etc, are meant to describe geometries (or features with a geometry property) whereas TopoJSON is meant to describe collections of geometries. I mean, you could transform a single feature to topojson, but it would be pretty useless.
In my opinion, for GeoPHP to ingest and output TopoJSON, the first step would be to create an abstract entity capable of ingesting N geometries in the form:
$geom_wkt = geoPHP::load($wkt,'wkt');
$geom_json = geoPHP::load($json,'json');
$geom_kml = geoPHP::load($kml,'kml');
$collection = geoPHP::createCollection();
$collection->addGeometry($geom_wkt);
$collection->addGeometry($geom_json);
$collection->addGeometry($geom_kml);
The next step would be to add topojoson as a possible output for this collection
$topojson = $collection->out('topojson');
But the collection could, I guess, still output other formats:
$geojsoncollection = $collection->out('json'); // GeoJSON FeatureCollection comprising N features
$wktarray = $collection->out('wkt'); // Array of N WKT strings
$kmldocument = $collection->out('kml'); // KML document comprising N placemarks
Again, this is just my humble opinion
Sounds good. :+1: