Skip to content
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

Is it helpful in D3 to simplify the precision of svg coordinates? #59

Open
jordansread opened this issue Mar 2, 2018 · 5 comments
Open
Labels
question Further information is requested

Comments

@jordansread
Copy link

When we were generating things like paths in a processing/visualize step (not in the browser), I would often simplify the coordinates to go to xx.12 or xx.123. Our current DOM has a lot of precision in the path elements that isn't really useful for rendering. Does this matter? Does it slow things down at all? This is a practical question (optimization) but also something I am just curious about. No urgency to it.

image

@jordansread jordansread added the question Further information is requested label Mar 2, 2018
@aappling-usgs
Copy link
Contributor

It's helpful on the data preparation side, for sure, and we're already doing it there. These values are post-projection, so the utility is in rendering rather than file size, but cleaner rendering also makes for sharper edges sometimes. I'm not sure whether there's a performance effect in this case, and sharper edges may not be relevant for geospatial polygons, but I'd like to know more.

If we decide it's worth doing, I know that some d3 scales do offer rangeRound, which uses interpolateRound...one of those functions might be useful to us here. And/or we can achieve rounding during the topojson creation if we project before creating the topojson (vizlab side) rather than doing it on the browser side as we currently are.

@jordansread
Copy link
Author

jordansread commented Mar 2, 2018

Ok - good to know. I understand the point about rendering sharpness, but
M640 means this svg is at least 640 svg pixels wide, and we are specifying many many digits. I think the rendering sharpness difference is notable between maybe 640.3 and 640.2913, but unlikely between 640.2913 and 640.291262-6...
So, I am curious if specifying way more digits has any real adverse impact. Does the DOM being bigger matter? Does the increased precision have any impact on rendering, or is the browser too smart for that?

@aappling-usgs
Copy link
Contributor

Oh, I meant it can be sharper with fewer digits, not more

@aappling-usgs
Copy link
Contributor

I am also curious about the impact of precision on performance.

@jordansread
Copy link
Author

Mike doubts it is a performance improvement but it doesn't look like there is a reason as to why it doesn't matter and also unclear if anyone has tested to see if it impacts performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants