PageSourceSearch

https://varosgazda.hu/themes/custom/varosgazda/js/Leaflet.draw/ext/GeometryUtil.js?v=11.4.8

js varosgazda.hu collected 2026-10-07 17:40:58 UTC 5,123 bytes, 165 lines download raw bytes

vendor: 5,123 bytes, lines 1-165
1(function () {
2
3	var defaultPrecision = {
4		km: 2,
5		ha: 2,
6		m: 0,
7		mi: 2,
8		ac: 2,
9		yd: 0,
10		ft: 0,
11		nm: 2
12	};
13
14
15	/**
16	 * @class L.GeometryUtil
17	 * @aka GeometryUtil
18	 */
19	L.GeometryUtil = L.extend(L.GeometryUtil || {}, {
20		// Ported from the OpenLayers implementation. See https://github.com/openlayers/openlayers/blob/master/lib/OpenLayers/Geometry/LinearRing.js#L270
21
22		// @method geodesicArea(): number
23		geodesicArea: function (latLngs) {
24			var pointsCount = latLngs.length,
25				area = 0.0,
26				d2r = Math.PI / 180,
27				p1, p2;
28
29			if (pointsCount > 2) {
30				for (var i = 0; i < pointsCount; i++) {
31					p1 = latLngs[i];
32					p2 = latLngs[(i + 1) % pointsCount];
33					area += ((p2.lng - p1.lng) * d2r) *
34						(2 + Math.sin(p1.lat * d2r) + Math.sin(p2.lat * d2r));
35				}
36				area = area * 6378137.0 * 6378137.0 / 2.0;
37			}
38
39			return Math.abs(area);
40		},
41
42		// @method formattedNumber(n, precision): string
43		// Returns n in specified number format (if defined) and precision
44		formattedNumber: function (n, precision) {
45			var formatted = parseFloat(n).toFixed(precision),
46				format = L.drawLocal.format && L.drawLocal.format.numeric,
47				delimiters = format && format.delimiters,
48				thousands = delimiters && delimiters.thousands,
49				decimal = delimiters && delimiters.decimal;
50
51			if (thousands || decimal) {
52				var splitValue = formatted.split('.');
53				formatted = thousands ? splitValue[0].replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1' + thousands) : splitValue[0];
54				decimal = decimal || '.';
55				if (splitValue.length > 1) {
56					formatted = formatted + decimal + splitValue[1];
57				}
58			}
59
60			return formatted;
61		},
62
63		// @method readableArea(area, isMetric, precision): string
64		// Returns a readable area string in yards or metric.
65		// The value will be rounded as defined by the precision option object.
66		readableArea: function (area, isMetric, precision) {
67			var areaStr,
68				units,
69				precision = L.Util.extend({}, defaultPrecision, precision);
70
71			if (isMetric) {
72				units = ['ha', 'm'];
73				type = typeof isMetric;
74				if (type === 'string') {
75					units = [isMetric];
76				} else if (type !== 'boolean') {
77					units = isMetric;
78				}
79
80				if (area >= 1000000 && units.indexOf('km') !== -1) {
81					areaStr = L.GeometryUtil.formattedNumber(area * 0.000001, precision['km']) + ' km²';
82				} else if (area >= 10000 && units.indexOf('ha') !== -1) {
83					areaStr = L.GeometryUtil.formattedNumber(area * 0.0001, precision['ha']) + ' ha';
84				} else {
85					areaStr = L.GeometryUtil.formattedNumber(area, precision['m']) + ' m²';
86				}
87			} else {
88				area /= 0.836127; // Square yards in 1 meter
89
90				if (area >= 3097600) { //3097600 square yards in 1 square mile
91					areaStr = L.GeometryUtil.formattedNumber(area / 3097600, precision['mi']) + ' mi²';
92				} else if (area >= 4840) { //4840 square yards in 1 acre
93					areaStr = L.GeometryUtil.formattedNumber(area / 4840, precision['ac']) + ' acres';
94				} else {
95					areaStr = L.GeometryUtil.formattedNumber(area, precision['yd']) + ' yd²';
96				}
97			}
98
99			return areaStr;
100		},
101
102		// @method readableDistance(distance, units): string
103		// Converts a metric distance to one of [ feet, nauticalMile, metric or yards ] string
104		//
105		// @alternative
106		// @method readableDistance(distance, isMetric, useFeet, isNauticalMile, precision): string
107		// Converts metric distance to distance string.
108		// The value will be rounded as defined by the precision option object.
109		readableDistance: function (distance, isMetric, isFeet, isNauticalMile, precision) {
110			var distanceStr,
111				units,
112				precision = L.Util.extend({}, defaultPrecision, precision);
113
114			if (isMetric) {
115				units = typeof isMetric == 'string' ? isMetric : 'metric';
116			} else if (isFeet) {
117				units = 'feet';
118			} else if (isNauticalMile) {
119				units = 'nauticalMile';
120			} else {
121				units = 'yards';
122			}
123
124			switch (units) {
125				case 'metric':
126					// show metres when distance is < 1km, then show km
127					if (distance > 1000) {
128						distanceStr = L.GeometryUtil.formattedNumber(distance / 1000, precision['km']) + ' km';
129					} else {
130						distanceStr = L.GeometryUtil.formattedNumber(distance, precision['m']) + ' m';
131					}
132					break;
133				case 'feet':
134					distance *= 1.09361 * 3;
135					distanceStr = L.GeometryUtil.formattedNumber(distance, precision['ft']) + ' ft';
136
137					break;
138				case 'nauticalMile':
139					distance *= 0.53996;
140					distanceStr = L.GeometryUtil.formattedNumber(distance / 1000, precision['nm']) + ' nm';
141					break;
142				case 'yards':
143				default:
144					distance *= 1.09361;
145
146					if (distance > 1760) {
147						distanceStr = L.GeometryUtil.formattedNumber(distance / 1760, precision['mi']) + ' miles';
148					} else {
149						distanceStr = L.GeometryUtil.formattedNumber(distance, precision['yd']) + ' yd';
150					}
151					break;
152			}
153			return distanceStr;
154		},
155
156		// @method isVersion07x(): boolean
157		// Returns true if the Leaflet version is 0.7.x, false otherwise.
158		isVersion07x: function () {
159			var version = L.version.split('.');
160			//If Version is == 0.7.*
161			return parseInt(version[0], 10) === 0 && parseInt(version[1], 10) === 7;
162		},
163	});
164
165})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.