From 3c99fde45db83b531c41c350ed4d0ac2a3c40c62 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:45:13 +0200 Subject: Adding debian version 1.1.0-3. Signed-off-by: Daniel Baumann --- .../leaflet.js/geometry/PolyUtil.js | 55 ++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 debian/missing-sources/leaflet.js/geometry/PolyUtil.js (limited to 'debian/missing-sources/leaflet.js/geometry/PolyUtil.js') diff --git a/debian/missing-sources/leaflet.js/geometry/PolyUtil.js b/debian/missing-sources/leaflet.js/geometry/PolyUtil.js new file mode 100644 index 0000000..87aa4b1 --- /dev/null +++ b/debian/missing-sources/leaflet.js/geometry/PolyUtil.js @@ -0,0 +1,55 @@ +import * as LineUtil from './LineUtil'; + +/* + * @namespace PolyUtil + * Various utility functions for polygon geometries. + */ + +/* @function clipPolygon(points: Point[], bounds: Bounds, round?: Boolean): Point[] + * Clips the polygon geometry defined by the given `points` by the given bounds (using the [Sutherland-Hodgman algorithm](https://en.wikipedia.org/wiki/Sutherland%E2%80%93Hodgman_algorithm)). + * Used by Leaflet to only show polygon points that are on the screen or near, increasing + * performance. Note that polygon points needs different algorithm for clipping + * than polyline, so there's a separate method for it. + */ +export function clipPolygon(points, bounds, round) { + var clippedPoints, + edges = [1, 4, 2, 8], + i, j, k, + a, b, + len, edge, p; + + for (i = 0, len = points.length; i < len; i++) { + points[i]._code = LineUtil._getBitCode(points[i], bounds); + } + + // for each edge (left, bottom, right, top) + for (k = 0; k < 4; k++) { + edge = edges[k]; + clippedPoints = []; + + for (i = 0, len = points.length, j = len - 1; i < len; j = i++) { + a = points[i]; + b = points[j]; + + // if a is inside the clip window + if (!(a._code & edge)) { + // if b is outside the clip window (a->b goes out of screen) + if (b._code & edge) { + p = LineUtil._getEdgeIntersection(b, a, edge, bounds, round); + p._code = LineUtil._getBitCode(p, bounds); + clippedPoints.push(p); + } + clippedPoints.push(a); + + // else if b is inside the clip window (a->b enters the screen) + } else if (!(b._code & edge)) { + p = LineUtil._getEdgeIntersection(b, a, edge, bounds, round); + p._code = LineUtil._getBitCode(p, bounds); + clippedPoints.push(p); + } + } + points = clippedPoints; + } + + return points; +} -- cgit v1.2.3