Aude has submitted this change and it was merged.
Change subject: Fix for globeCoordinate's toDegree()
......................................................................
Fix for globeCoordinate's toDegree()
toDegree() needs to operate on the absolute value to deliver correct results.
Change-Id: I76f0f24c5df9823e8f1aa04932e41dcda1bd1aac
---
M DataValues/resources/globeCoordinate.js/src/globeCoordinate.GlobeCoordinate.js
M DataValues/resources/globeCoordinate.js/src/globeCoordinate.js
M
DataValues/resources/globeCoordinate.js/tests/globeCoordinate.GlobeCoordinate.tests.js
M DataValues/resources/globeCoordinate.js/tests/globeCoordinate.tests.js
4 files changed, 6 insertions(+), 5 deletions(-)
Approvals:
Aude: Verified; Looks good to me, approved
jenkins-bot: Verified
diff --git
a/DataValues/resources/globeCoordinate.js/src/globeCoordinate.GlobeCoordinate.js
b/DataValues/resources/globeCoordinate.js/src/globeCoordinate.GlobeCoordinate.js
index 362e07b..a820aca 100644
---
a/DataValues/resources/globeCoordinate.js/src/globeCoordinate.GlobeCoordinate.js
+++
b/DataValues/resources/globeCoordinate.js/src/globeCoordinate.GlobeCoordinate.js
@@ -254,10 +254,10 @@
// There is no need to include minute in the result if
minute and second have no value.
// If second has no value, it can be dropped anyway.
return ''
- + ( ( ( lat.degree < 0 ) ? '-' : '+' ) + pad(
lat.degree, 2 ) )
+ + ( ( ( this.getLatitude() < 0 ) ? '-' : '+' )
+ pad( lat.degree, 2 ) )
+ ( ( lat.minute || lat.second ) ? pad(
lat.minute, 2 ) : '' )
+ ( ( lat.second ) ? pad( lat.second, 2 ) : '' )
- + ( ( ( lon.degree < 0 ) ? '-' : '+' ) + pad(
lon.degree, 3 ) )
+ + ( ( ( this.getLongitude() < 0 ) ? '-' : '+' )
+ pad( lon.degree, 3 ) )
+ ( ( lon.minute || lon.second ) ? pad(
lon.minute, 2 ) : '' )
+ ( ( lon.second ) ? pad( lon.second, 2 ) : '' )
+ '/';
diff --git a/DataValues/resources/globeCoordinate.js/src/globeCoordinate.js
b/DataValues/resources/globeCoordinate.js/src/globeCoordinate.js
index c6c4a2a..524d781 100644
--- a/DataValues/resources/globeCoordinate.js/src/globeCoordinate.js
+++ b/DataValues/resources/globeCoordinate.js/src/globeCoordinate.js
@@ -181,7 +181,8 @@
* @return {Object}
*/
toDegree: function( value, precision ) {
- var result = {};
+ var value = Math.abs( value ),
+ result = {};
result.degree = Math.floor( value + 0.00000001 );
diff --git
a/DataValues/resources/globeCoordinate.js/tests/globeCoordinate.GlobeCoordinate.tests.js
b/DataValues/resources/globeCoordinate.js/tests/globeCoordinate.GlobeCoordinate.tests.js
index d71d0ff..9b0a875 100644
---
a/DataValues/resources/globeCoordinate.js/tests/globeCoordinate.GlobeCoordinate.tests.js
+++
b/DataValues/resources/globeCoordinate.js/tests/globeCoordinate.GlobeCoordinate.tests.js
@@ -23,7 +23,7 @@
'1\' 1"': '+010001+000/',
'1\' 1.1"': '+010001.1+000/',
'89° 59" 59\' 1.123\'': '+8959+0590001.123/',
- '5\'N 0\' 10.5"W': '+05-0015949.5/'
+ '5°\'N 0° 0\' 10.5"W': '+05-0000010.5/'
};
QUnit.module( 'globeCoordinate.GlobeCoordinate.js' );
diff --git
a/DataValues/resources/globeCoordinate.js/tests/globeCoordinate.tests.js
b/DataValues/resources/globeCoordinate.js/tests/globeCoordinate.tests.js
index abc4630..eacf35a 100644
--- a/DataValues/resources/globeCoordinate.js/tests/globeCoordinate.tests.js
+++ b/DataValues/resources/globeCoordinate.js/tests/globeCoordinate.tests.js
@@ -258,7 +258,7 @@
);
assert.equal(
- globeCoordinate.degreeText( -10, -1.5, 0.1 ),
+ globeCoordinate.degreeText( -10, -2.5, 0.1 ),
'10°0\'S, 2°30\'W',
'Verified output: 10°0\'S, 2°30\'W'
);
--
To view, visit https://gerrit.wikimedia.org/r/67959
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I76f0f24c5df9823e8f1aa04932e41dcda1bd1aac
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DataValues
Gerrit-Branch: mw1.22-wmf6
Gerrit-Owner: Aude <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Henning Snater <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits