node-mapnik
node-mapnik copied to clipboard
Add transform option to toWKB and toWKT.
Add the ability to provide a reprojection prior to using the toWKB and toWKT operations in src/mapnik_geometry.cpp similar to how you can provide the transform option for toJSON. Additionally add async functionality for both of these methods.
Yes, and good call on +async too.
Additionally it seems that toWKB does not provide any projection information, this is something that PostGIS expects apparently? Currently the workaround is to insert WKB objects as SRID=0 and then repoject after. Look into how we can provide either an SRID passed as an option, or have it known from the vector tile?
@flippmoke - I think not mixing re-projection and I/O would be better and more flexible solution - they are separate concepts. Having said that, I see some performance advantages re-projecting individual coords while iterating over them. How about providing `filter' adapter interface on our geometries where we can inject user defined functor to do re-projection or any other transformations ? Similar to STL approach
/cc @springmeyer
:-1: on adding SRID info the the WKB. We should not support EWKB - only supporting WKB output I think is fine. If programs want WKB (like PostGIS) then adding it via ST_SetSRID on the geometries provided by Mapnik should be fine.
:+1: to supporting fast reprojection. As far as how to do it I see two options:
- Destructive/copy API
var geom = feat.geometry();
geom.transform(from,to);
geom.toWKB();
- Filter API
Sketching out what I think @artemp has in mind:
var geom = feat.geometry();
var geom_filter = mapnik.GeomFilter({'type':'proj_transform','from':wgs84_proj,'to':merc_proj});
geom_filter(geom).toWKB();
geom_filter(geom).toGeoJSON();
Note: we'll need a solution here for both WKB and the existing feat.toJSON to keep existing functionality when we move on https://github.com/mapnik/node-mapnik/issues/421.