geoPHP icon indicating copy to clipboard operation
geoPHP copied to clipboard

Support Read and Write TopoJSON format

Open anber20 opened this issue 10 years ago • 3 comments

Please support TopoJSON as input/output format.

anber20 avatar May 07 '14 02:05 anber20

:+1:

swen100 avatar Jun 30 '15 06:06 swen100

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

ffflabs avatar Jun 30 '15 18:06 ffflabs

Sounds good. :+1:

swen100 avatar Jul 01 '15 06:07 swen100