-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Projection.stream only supports points with x and y (no z) #96
Comments
Hmm. We’d need to change all the parts of the projection pipeline to pass along z (transformRadians, preclip, projectResample, postclip), which is a bit of a pain, especially since it presumably adds a small amount of overhead to the common case where z is not needed. Another option would be to call d3.geoProject on load instead of using projection.stream; then you save your projected GeoJSON and you don’t need to reproject on pan & zoom; you just apply your transform and dynamic simplification. And you don’t lose z. If you’re using topojson.presimplify to compute z, it takes a topology as input and after d3.geoProject you have individual GeoJSON features. So you’d also need to call topojson.topology to construct a new topology after projecting. I’m not sure if there’s a better way to do it at the moment. |
Thanks for the advice, I'll try out those suggestions. Really appreciate the fast response. |
I'm wondering where the best place is to highlight this in the docs? I spent a while scratching my head over this before browsing the issues and finding this. Perhaps under the docs for projection.stream(stream) <>Returns a projection stream for the specified output stream. Any input geometry is projected before being streamed to the output stream. A typical projection involves several geometry transformations: the input geometry is first converted to radians, rotated on three axes, clipped to the small circle or cut along the antimeridian, and lastly projected to the plane with adaptive resampling, scale and translation. a projection stream, unlike a transform stream, only accepts 2D [x, y] coordinates, not 3D [x, y, z] coordinates |
More precisely, the geometry stream implemented by projection.stream accepts an arbitrary number of dimensions as input, but only observes and outputs the first two dimensions (x and y). You could implement a geometry stream that transforms more than two dimensions, meaning that is supported by the stream interface, but it’s not currently supported by d3.geoProjection implementation. |
I was working to implement your Map Pan & Zoom IV example without baking in the projection to the json file.
As a result I've been playing around with
projection.stream
, and discovered that, unlikegeoTransform
, when I pass in a stream, thepoint
function only receivesx
andy
params, whereas thegeoTransform
receivesx
,y
, andz
params.So when I write the following:
my projection doesn't render because z is undefined in the
point
function. Alternatively reversing the order the streams are called has the same result. But either stream called individually works as expected (simplify.stream
calls thepoint
function with three params andprojection.stream(s)
renders my map, but without dynamic simplification.The text was updated successfully, but these errors were encountered: