Sha256: 2c4338c4434d8e7321e1aa7bc991fd31dd5921bac4ec20915c404c1f82f99037
Contents?: true
Size: 1.71 KB
Versions: 1
Compression:
Stored size: 1.71 KB
Contents
L.GeometryUtil = L.extend(L.GeometryUtil || {}, { // Ported from the OpenLayers implementation. See https://github.com/openlayers/openlayers/blob/master/lib/OpenLayers/Geometry/LinearRing.js#L270 geodesicArea: function (latLngs) { var pointsCount = latLngs.length, area = 0.0, d2r = L.LatLng.DEG_TO_RAD, p1, p2; if (pointsCount > 2) { for (var i = 0; i < pointsCount; i++) { p1 = latLngs[i]; p2 = latLngs[(i + 1) % pointsCount]; area += ((p2.lng - p1.lng) * d2r) * (2 + Math.sin(p1.lat * d2r) + Math.sin(p2.lat * d2r)); } area = area * 6378137.0 * 6378137.0 / 2.0; } return Math.abs(area); }, readableArea: function (area, isMetric) { var areaStr; if (isMetric) { if (area >= 10000) { areaStr = (area * 0.0001).toFixed(2) + ' ha'; } else { areaStr = area.toFixed(2) + ' m²'; } } else { area *= 0.836127; // Square yards in 1 meter if (area >= 3097600) { //3097600 square yards in 1 square mile areaStr = (area / 3097600).toFixed(2) + ' mi²'; } else if (area >= 4840) {//48040 square yards in 1 acre areaStr = (area / 4840).toFixed(2) + ' acres'; } else { areaStr = Math.ceil(area) + ' yd²'; } } return areaStr; }, readableDistance: function (distance, isMetric) { var distanceStr; if (isMetric) { // show metres when distance is < 1km, then show km if (distance > 1000) { distanceStr = (distance / 1000).toFixed(2) + ' km'; } else { distanceStr = Math.ceil(distance) + ' m'; } } else { distance *= 1.09361; if (distance > 1760) { distanceStr = (distance / 1760).toFixed(2) + ' miles'; } else { distanceStr = Math.ceil(distance) + ' yd'; } } return distanceStr; } });
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
leaflet-js-0.8.dev2 | lib/leaflet.draw/src/ext/GeometryUtil.js |