Script and makefile adjustments for updating extlib
[larjonas-mediagoblin.git] / extlib / leaflet / src / geo / LatLng.js
blobfb91654755ae6b63b3a39ee933a2c02fb2eefeff
1 /*
2 CM.LatLng represents a geographical point with latitude and longtitude coordinates.
3 */
5 L.LatLng = function(/*Number*/ lat, /*Number*/ lng, /*Boolean*/ noWrap) {
6 if (noWrap !== true) {
7 lat = Math.max(Math.min(lat, 90), -90); // clamp latitude into -90..90
8 lng = (lng + 180) % 360 + (lng < -180 ? 180 : -180); // wrap longtitude into -180..180
11 //TODO change to lat() & lng()
12 this.lat = lat;
13 this.lng = lng;
16 L.Util.extend(L.LatLng, {
17 DEG_TO_RAD: Math.PI / 180,
18 RAD_TO_DEG: 180 / Math.PI,
19 MAX_MARGIN: 1.0E-9 // max margin of error for the "equals" check
20 });
22 L.LatLng.prototype = {
23 equals: function(/*LatLng*/ obj) {
24 if (!(obj instanceof L.LatLng)) { return false; }
26 var margin = Math.max(Math.abs(this.lat - obj.lat), Math.abs(this.lng - obj.lng));
27 return margin <= L.LatLng.MAX_MARGIN;
30 toString: function() {
31 return 'LatLng(' +
32 L.Util.formatNum(this.lat) + ', ' +
33 L.Util.formatNum(this.lng) + ')';