Download node_modules/d3-geo/src/projection/fit.js from NKessler/Horizon: direct link, hf CLI and curl.
- Browser
- Download file 1.59 kB
-
https://huggingface.co/NKessler/Horizon/resolve/main/node_modules/d3-geo/src/projection/fit.js
- Command line
-
hf download hf://NKessler/Horizon/node_modules/d3-geo/src/projection/fit.js
-
curl -L -o fit.js https://huggingface.co/NKessler/Horizon/resolve/main/node_modules/d3-geo/src/projection/fit.js
1.59 kB
| import {default as geoStream} from "../stream.js"; | |
| import boundsStream from "../path/bounds.js"; | |
| function fit(projection, fitBounds, object) { | |
| var clip = projection.clipExtent && projection.clipExtent(); | |
| projection.scale(150).translate([0, 0]); | |
| if (clip != null) projection.clipExtent(null); | |
| geoStream(object, projection.stream(boundsStream)); | |
| fitBounds(boundsStream.result()); | |
| if (clip != null) projection.clipExtent(clip); | |
| return projection; | |
| } | |
| export function fitExtent(projection, extent, object) { | |
| return fit(projection, function(b) { | |
| var w = extent[1][0] - extent[0][0], | |
| h = extent[1][1] - extent[0][1], | |
| k = Math.min(w / (b[1][0] - b[0][0]), h / (b[1][1] - b[0][1])), | |
| x = +extent[0][0] + (w - k * (b[1][0] + b[0][0])) / 2, | |
| y = +extent[0][1] + (h - k * (b[1][1] + b[0][1])) / 2; | |
| projection.scale(150 * k).translate([x, y]); | |
| }, object); | |
| } | |
| export function fitSize(projection, size, object) { | |
| return fitExtent(projection, [[0, 0], size], object); | |
| } | |
| export function fitWidth(projection, width, object) { | |
| return fit(projection, function(b) { | |
| var w = +width, | |
| k = w / (b[1][0] - b[0][0]), | |
| x = (w - k * (b[1][0] + b[0][0])) / 2, | |
| y = -k * b[0][1]; | |
| projection.scale(150 * k).translate([x, y]); | |
| }, object); | |
| } | |
| export function fitHeight(projection, height, object) { | |
| return fit(projection, function(b) { | |
| var h = +height, | |
| k = h / (b[1][1] - b[0][1]), | |
| x = -k * b[0][0], | |
| y = (h - k * (b[1][1] + b[0][1])) / 2; | |
| projection.scale(150 * k).translate([x, y]); | |
| }, object); | |
| } | |