artemp/trac2github — Issue #814: Add Geometry.to_wkb() and to_wkt()
Author: artemp
Created: 2011-10-09 20:52:03+00:00
State: open
Labels: Core_Library

Mapnik stores geometries in svg-like paths (x,y,command). This is optimal for rendering as they are easily adapted to AGG and Cairo. The approach also works gracefully with coordinates that might be invalid by OGC standards but are perfectly "renderable".

But, we should be able to expose geometry paths in the C++ API and in binding languages so that applications using mapnik can access feature geometry data through the generic datasource plugin interface (e.g. use mapnik instead of ogr api). To enable this we need add, for example, to_wkt() and/or to_wkb() in the python bindings: http://trac.mapnik.org/browser/trunk/bindings/python/mapnik_geometry.cpp#L62 as currently mapnik.Geometry2d is write-only.

In addition, ideally the C++ API could offer something like to_coords(). The latter could be used by mapnik metawriters to avoid code like this having to be duplicated in more places in the future: http://trac.mapnik.org/browser/trunk/src/metawriter.cpp#L291

Note: Creating "proper" OGC geometries will be difficult because of the conversion issues in datasources from OGC -> mapnik paths -> OGC. Invalid geometries may be produced, or multi* may be flattened depending on the parsing of each ds plugin.