Skip to content

Commit

Permalink
set clipCircle precision to 2 degrees (#282)
Browse files Browse the repository at this point in the history
* default geoCircle precision to 2 degrees

Results in 180 control points instead of 60 (⨉3). The error is quadratic with the precision, with the worst case (for a parallel) being at latitude 45°. Under this new setting, the maximum error is now ~484m, vs. 4.365km with precision 6°.
https://observablehq.com/@d3/geocircle-error

* document

* refine clipCircle precision, from 6 degrees to 2 degrees
following #281

(note that for clipCircle the precision is not modifiable by the user)

Manually rechecked each of the tests that are (slightly) modified as a consequence

---------

Co-authored-by: Mike Bostock <mbostock@gmail.com>
  • Loading branch information
Fil and mbostock authored Mar 12, 2024
1 parent dcca6b2 commit dbb42ba
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/clip/circle.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import clip from "./index.js";

export default function(radius) {
var cr = cos(radius),
delta = 6 * radians,
delta = 2 * radians,
smallRadius = cr > 0,
notHemisphere = abs(cr) > epsilon; // TODO optimise for this common case

Expand Down
2 changes: 1 addition & 1 deletion test/projection/clipcircle-test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions test/projection/fit-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ it("projection.fitExtent(…) world azimuthalEquidistant", () => {
it("projection.fitExtent(…) world conicConformal", () => {
const projection = geoConicConformal().clipAngle(30).parallels([30, 60]).rotate([0, -45]);
projection.fitExtent([[50, 50], [950, 950]], world);
assertInDelta(projection.scale(), 626.111027, 1e-6);
assertInDelta(projection.translate(), [444.395951, 410.223799], 1e-6);
assertInDelta(projection.scale(), 625.567161, 1e-6);
assertInDelta(projection.translate(), [444.206209, 409.910893], 1e-6);
});

it("projection.fitExtent(…) world conicEqualArea", () => {
Expand Down Expand Up @@ -69,7 +69,7 @@ it("projection.fitExtent(…) world gnomonic", () => {
const projection = geoGnomonic().clipAngle(45);
projection.fitExtent([[50, 50], [950, 950]], world);
assertInDelta(projection.scale(), 450.348233, 1e-6);
assertInDelta(projection.translate(), [500.115138, 556.522620], 1e-6);
assertInDelta(projection.translate(), [500.115138, 556.551304], 1e-6);
});

it("projection.fitExtent(…) world mercator", () => {
Expand Down
Binary file modified test/snapshots/angleorient30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/snapshots/azimuthalEqualArea.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/snapshots/gnomonic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/snapshots/orthographic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit dbb42ba

Please sign in to comment.