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

d3.geo.projection #820

Closed
wants to merge 105 commits into from
Closed

d3.geo.projection #820

wants to merge 105 commits into from

Conversation

mbostock
Copy link
Member

No description provided.

mbostock and others added 30 commits September 22, 2012 16:03
We can use the implicit array.toString() rather than join(",").
This is still a work in progress, but it's a start.
Add projection.{line,polygon} support to d3.geo.path.
One more thing left to do: interpolate along the cut line when joining
endpoints. Ideally, the distance between interpolated points should be
less than 180°. This should probably also apply to points interpolated
at ±90° latitudes.
mbostock and others added 17 commits October 1, 2012 22:39
Also restore path.area and add a few tests.
Passes spiral test.
Conflicts:
	d3.v2.js
	d3.v2.min.js
	src/geo/circle.js
	src/geo/projection.js
Hurrah for tests!
Interpolation of longitudes becomes inaccurate near the poles, since
they become mathematically insignificant in relation to a sphere.
However, for map projections, we want to interpolate longitudes even at
the poles themselves, since many projections distort the poles along an
edge.
It was breaking obviously in the resampling demo.

Retains a minor optimisation.
Polygon LinearRings weren't being closed correctly.
This was breaking antemeridian clipping in some rare cases where a point
was coincident with the antemeridian.
@mbostock
Copy link
Member Author

mbostock commented Oct 3, 2012

@jasondavies I found some anomalies in the antemeridian cutting demo. The coordinates are:

projection.rotate([210.5, 62.5, 0]);
projection.rotate([349, -62.5, 0]);
projection.rotate([30.5, 52, 0]);

The antemeridian interpolator was mistakenly assuming longitudes of
interpolation points are exactly on the antemeridian. An alternative fix
would be to use exact equality tests for the coincident points test, but
it feels safer to use a margin of error.
@jasondavies
Copy link
Contributor

Thanks. All fixed in 7686856.

@mbostock
Copy link
Member Author

mbostock commented Oct 3, 2012

Nicely done!

jasondavies and others added 4 commits October 3, 2012 21:52
This can be optimised using the 3D coordinates directly from the
rotation step, rather than performing additional trig. calculations.
Add extra ring if polygon "surrounds" clip circle.
I've reinstated the original conditional for linear longitudinal
interpolation, since the x * x < ε conditional was not tight enough and
hence caused glitches in projections that include the poles e.g.
stereographic.

Back to solving the issue that was primarily noticeable in the Albers
demo: graticules near the poles would not resample correctly. We made an
assumption that a point mid-way along the connecting great arc is going
to be approximately mid-way in pixel-space. This is a reasonable
assumption in most cases, but there is an area of high instability near
the poles, since a small change in distance could result in a large
change in longitude, e.g. imagine a great arc going right over a pole,
so the longitude will change greatly depending on which side of the pole
you're on.

So the new fix is to see if the distance in pixel-space hardly changed
at all, and in this case we attempt to interpolate again, mid-way to the
new spherical coordinates. I think we can probably improve this even
further by borrowing methods from standard root-finding techniques e.g.
Newton-Raphson.
Better resampling for non-linear distortions.
@mbostock
Copy link
Member Author

mbostock commented Oct 5, 2012

Merged into #846.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants