Skip to content

Commit 424e3b2

Browse files
thiemowmdelucaswerkmeister
authored andcommitted
Remove unused globeCoordinate.Formatter
1 parent 448214c commit 424e3b2

File tree

6 files changed

+4
-612
lines changed

6 files changed

+4
-612
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ It contains various JavaScript related to the DataValues library.
88
## Release notes
99

1010
### 1.0.0 (dev)
11+
* Removed `globeCoordinate.Formatter`.
12+
* Removed the `globeCoordinate` utility class.
1113
* The library is now a pure JavaScript library.
1214
* Removed MediaWiki ResourceLoader module definitions.
1315

karma.conf.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ module.exports = function ( config ) {
77
'lib/util/util.inherit.js',
88
'lib/globeCoordinate/globeCoordinate.js',
99
'lib/globeCoordinate/globeCoordinate.GlobeCoordinate.js',
10-
'lib/globeCoordinate/globeCoordinate.Formatter.js',
1110
'src/dataValues.js',
1211
'src/DataValue.js',
1312
'src/values/*.js',

lib/globeCoordinate/globeCoordinate.Formatter.js

Lines changed: 0 additions & 167 deletions
This file was deleted.
Lines changed: 2 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -1,165 +1,7 @@
11
/**
2-
* Globe coordinate detection global routines
3-
* Original source: http://simia.net/valueparser/coordinate.js
4-
* VERSION: 0.1
2+
* Globe coordinate module
53
* @class globeCoordinate
64
* @singleton
75
* @license GPL-2.0+
8-
* @author Denny Vrandečić
9-
* @author H. Snater < mediawiki@snater.com >
106
*/
11-
this.globeCoordinate = ( function() {
12-
'use strict';
13-
14-
return {
15-
/**
16-
* Return a given decimal value applying a precision.
17-
*
18-
* @param {number} value
19-
* @param {number} precision
20-
* @return {number}
21-
*/
22-
toDecimal: function( value, precision ) {
23-
var logPrecision = Math.max( -9, Math.floor( Math.log( precision ) / Math.LN10 ) ),
24-
factor = Math.pow( 10, -1 * logPrecision );
25-
26-
return Math.round( value * factor ) / factor;
27-
},
28-
29-
/**
30-
* Returns a given decimal value converted to degree taking a precision into account.
31-
*
32-
* @param {number} value
33-
* @param {number} precision
34-
* @return {Object} Returned object has the following structure:
35-
* {
36-
* degree: {number},
37-
* minute: {number|undefined},
38-
* second: {number|undefined}
39-
* }
40-
* "minute" and/or "second" are undefined if not covered by the precision.
41-
*/
42-
toDegree: function( value, precision ) {
43-
var result = {};
44-
45-
value = Math.abs( value );
46-
47-
result.degree = Math.floor( value + 0.00000001 );
48-
49-
if( precision > 0.9999999999 ) {
50-
result.minute = undefined;
51-
} else {
52-
result.minute = Math.abs( Math.floor( ( value - result.degree + 0.000001 ) * 60 ) );
53-
}
54-
55-
if( precision > ( 0.9999999999 / 60 ) ) {
56-
result.second = undefined;
57-
} else {
58-
result.second = ( value - result.degree - result.minute / 60 ) * 3600;
59-
60-
if( precision > ( 0.9999999999 / 3600 ) ) {
61-
result.second = Math.abs( Math.round( result.second ) );
62-
} else if( precision > ( 0.9999999999 / 36000 ) ) {
63-
result.second = Math.abs( Math.round( result.second * 10 ) / 10 );
64-
} else if( precision > ( 0.9999999999 / 360000 ) ) {
65-
result.second = Math.abs( Math.round( result.second * 100 ) / 100 );
66-
} else {
67-
result.second = Math.abs( Math.round( result.second * 1000 ) / 1000 );
68-
}
69-
}
70-
71-
// TODO: precision might be a floating point number and might cause minutes/seconds
72-
// to be "generated".
73-
if( precision > 1 ) {
74-
result.degree = Math.round( result.degree / precision ) * precision;
75-
76-
// JavaScript may cause some disturbance regarding rounding and precision. The
77-
// result should not have a higher floating point number precision than the
78-
// applied precision.
79-
var degreeFloat = String( result.degree ).split( '.' ),
80-
precisionFloat = String( precision ).split( '.' );
81-
82-
if(
83-
degreeFloat[1] && precisionFloat[1]
84-
&& degreeFloat[1].length > precisionFloat[1].length
85-
) {
86-
var trimmedPrecision = degreeFloat[1].substr( 0, precisionFloat[1].length );
87-
result.degree = parseFloat( degreeFloat[0] + '.' + trimmedPrecision );
88-
}
89-
}
90-
91-
return result;
92-
},
93-
94-
/**
95-
* Returns a coordinate's ISO 6709 string representation.
96-
*
97-
* @param {Object} decimalCoordinateDefinition
98-
* Object with the following structure:
99-
* {
100-
* latitude: {number},
101-
* longitude: {number},
102-
* precision: {number}
103-
* }
104-
* @return {string}
105-
*/
106-
iso6709: function( decimalCoordinateDefinition ) {
107-
var latitude = decimalCoordinateDefinition.latitude,
108-
longitude = decimalCoordinateDefinition.longitude,
109-
precision = decimalCoordinateDefinition.precision,
110-
lat = globeCoordinate.toDegree( latitude, precision ),
111-
lon = globeCoordinate.toDegree( longitude, precision ),
112-
latISO,
113-
lonISO;
114-
115-
/**
116-
* Strips a number's sign and fills the number's integer part with zeroes according to a
117-
* given string length.
118-
*
119-
* @param {number} number
120-
* @param {string} length
121-
*/
122-
function pad( number, length ) {
123-
var absolute = Math.abs( number || 0 ),
124-
string = String( absolute ),
125-
exploded = string.split( '.' );
126-
127-
if( exploded[0].length === length ) {
128-
return string;
129-
}
130-
131-
return new Array( length - exploded[0].length + 1 ).join( '0' )
132-
+ exploded[0]
133-
+ ( ( exploded[1] ) ? '.' + exploded[1] : '' );
134-
}
135-
136-
latISO = ( latitude < 0 ? '-' : '+' )
137-
+ pad( lat.degree, 2 )
138-
+ ( precision < 1 ? pad( lat.minute, 2 ) : '' )
139-
+ ( precision < 1 / 60 ? pad( lat.second, 2 ) : '' );
140-
141-
lonISO = ( longitude < 0 ? '-' : '+' )
142-
+ pad( lon.degree, 3 )
143-
+ ( precision < 1 ? pad( lon.minute, 2 ) : '' )
144-
+ ( precision < 1 / 60 ? pad( lon.second, 2 ) : '' );
145-
146-
// Synchronize precision (longitude degree needs to be 1 digit longer):
147-
if( lonISO.indexOf( '.' ) !== -1 && latISO.indexOf( '.' ) === -1 ) {
148-
latISO += '.';
149-
}
150-
while( latISO.length < lonISO.length - 1 ) {
151-
latISO += '0';
152-
}
153-
if( latISO.indexOf( '.' ) !== -1 && lonISO.indexOf( '.' ) === -1 ) {
154-
lonISO += '.';
155-
}
156-
while( lonISO.length < latISO.length + 1 ) {
157-
lonISO += '0';
158-
}
159-
160-
return latISO + lonISO + '/';
161-
}
162-
163-
};
164-
165-
}() );
7+
this.globeCoordinate = {};

0 commit comments

Comments
 (0)