node-mapnik icon indicating copy to clipboard operation
node-mapnik copied to clipboard

Add transform option to toWKB and toWKT.

Open flippmoke opened this issue 10 years ago • 4 comments
trafficstars

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.

flippmoke avatar Mar 20 '15 20:03 flippmoke

Yes, and good call on +async too.

springmeyer avatar Mar 20 '15 20:03 springmeyer

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 avatar Mar 24 '15 15:03 flippmoke

@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

artemp avatar Mar 24 '15 15:03 artemp

:-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:

  1. Destructive/copy API
var geom = feat.geometry();
geom.transform(from,to);
geom.toWKB();
  1. 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.

springmeyer avatar Mar 24 '15 18:03 springmeyer