Download node_modules/d3-geo/src/path/measure.js from NKessler/Horizon: direct link, hf CLI and curl.
- Browser
- Download file 854 Bytes
-
https://huggingface.co/NKessler/Horizon/resolve/main/node_modules/d3-geo/src/path/measure.js
- Command line
-
hf download hf://NKessler/Horizon/node_modules/d3-geo/src/path/measure.js
-
curl -L -o measure.js https://huggingface.co/NKessler/Horizon/resolve/main/node_modules/d3-geo/src/path/measure.js
854 Bytes
| import {Adder} from "d3-array"; | |
| import {sqrt} from "../math.js"; | |
| import noop from "../noop.js"; | |
| var lengthSum = new Adder(), | |
| lengthRing, | |
| x00, | |
| y00, | |
| x0, | |
| y0; | |
| var lengthStream = { | |
| point: noop, | |
| lineStart: function() { | |
| lengthStream.point = lengthPointFirst; | |
| }, | |
| lineEnd: function() { | |
| if (lengthRing) lengthPoint(x00, y00); | |
| lengthStream.point = noop; | |
| }, | |
| polygonStart: function() { | |
| lengthRing = true; | |
| }, | |
| polygonEnd: function() { | |
| lengthRing = null; | |
| }, | |
| result: function() { | |
| var length = +lengthSum; | |
| lengthSum = new Adder(); | |
| return length; | |
| } | |
| }; | |
| function lengthPointFirst(x, y) { | |
| lengthStream.point = lengthPoint; | |
| x00 = x0 = x, y00 = y0 = y; | |
| } | |
| function lengthPoint(x, y) { | |
| x0 -= x, y0 -= y; | |
| lengthSum.add(sqrt(x0 * x0 + y0 * y0)); | |
| x0 = x, y0 = y; | |
| } | |
| export default lengthStream; | |