[MediaWiki-commits] [Gerrit] Introduced GlobeCoordinateParser - change (mediawiki...DataValues)

2013-08-20 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Introduced GlobeCoordinateParser
..


Introduced GlobeCoordinateParser

This new parser has the same behaviour as the old GeoCoordinateParser.
Now, the latter returns a simple LatLongValue and no longer does precision
detection. Existing behaviour of this component should not have changed
visibly to the outside.

Change-Id: I20012795ced95e8afda7f2c21fd32730dc408432
---
M ValueParsers/ValueParsers.classes.php
M ValueParsers/ValueParsers.php
M ValueParsers/includes/parsers/DdCoordinateParser.php
M ValueParsers/includes/parsers/DmCoordinateParser.php
M ValueParsers/includes/parsers/DmsCoordinateParser.php
M ValueParsers/includes/parsers/FloatCoordinateParser.php
M ValueParsers/includes/parsers/GeoCoordinateParser.php
M ValueParsers/includes/parsers/GeoCoordinateParserBase.php
A ValueParsers/includes/parsers/GlobeCoordinateParser.php
M ValueParsers/tests/phpunit/api/ApiParseValueTest.php
M ValueParsers/tests/phpunit/parsers/DdCoordinateParserTest.php
M ValueParsers/tests/phpunit/parsers/DmCoordinateParserTest.php
M ValueParsers/tests/phpunit/parsers/DmsCoordinateParserTest.php
M ValueParsers/tests/phpunit/parsers/FloatCoordinateParserTest.php
M ValueParsers/tests/phpunit/parsers/GeoCoordinateParserTest.php
A ValueParsers/tests/phpunit/parsers/GlobeCoordinateParserTest.php
16 files changed, 420 insertions(+), 276 deletions(-)

Approvals:
  Henning Snater: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/ValueParsers/ValueParsers.classes.php 
b/ValueParsers/ValueParsers.classes.php
index 3e37476..756e007 100644
--- a/ValueParsers/ValueParsers.classes.php
+++ b/ValueParsers/ValueParsers.classes.php
@@ -26,6 +26,7 @@
'ValueParsers\FloatCoordinateParser' => 
'includes/parsers/FloatCoordinateParser.php',
'ValueParsers\GeoCoordinateParser' => 
'includes/parsers/GeoCoordinateParser.php',
'ValueParsers\GeoCoordinateParserBase' => 
'includes/parsers/GeoCoordinateParserBase.php',
+   'ValueParsers\GlobeCoordinateParser' => 
'includes/parsers/GlobeCoordinateParser.php',
'ValueParsers\FloatParser' => 'includes/parsers/FloatParser.php',
'ValueParsers\IntParser' => 'includes/parsers/IntParser.php',
'ValueParsers\NullParser' => 'includes/parsers/NullParser.php',
diff --git a/ValueParsers/ValueParsers.php b/ValueParsers/ValueParsers.php
index 06b2571..73e3abb 100644
--- a/ValueParsers/ValueParsers.php
+++ b/ValueParsers/ValueParsers.php
@@ -46,7 +46,7 @@
 
 $wgValueParsers['bool'] = 'ValueParsers\BoolParser';
 $wgValueParsers['float'] = 'ValueParsers\FloatParser';
-$wgValueParsers['globecoordinate'] = 'ValueParsers\GeoCoordinateParser';
+$wgValueParsers['globecoordinate'] = 'ValueParsers\GlobeCoordinateParser';
 $wgValueParsers['int'] = 'ValueParsers\IntParser';
 $wgValueParsers['null'] = 'ValueParsers\NullParser';
 
diff --git a/ValueParsers/includes/parsers/DdCoordinateParser.php 
b/ValueParsers/includes/parsers/DdCoordinateParser.php
index c6f0a87..1789236 100644
--- a/ValueParsers/includes/parsers/DdCoordinateParser.php
+++ b/ValueParsers/includes/parsers/DdCoordinateParser.php
@@ -46,22 +46,6 @@
}
 
/**
-* @see GeoCoordinateParserBase::detectPrecision
-*/
-   protected function detectPrecision( $number ) {
-   // TODO: Implement localized decimal separator.
-   $split = explode( '.', $number );
-
-   $precision = 1;
-
-   if( isset( $split[1] ) ) {
-   $precision = pow( 10, -1 * strlen( $split[1] ) );
-   }
-
-   return $precision;
-   }
-
-   /**
 * @see GeoCoordinateParserBase::areValidCoordinates
 */
protected function areValidCoordinates( $normalizedCoordinateSegments ) 
{
diff --git a/ValueParsers/includes/parsers/DmCoordinateParser.php 
b/ValueParsers/includes/parsers/DmCoordinateParser.php
index 296af05..8039e36 100644
--- a/ValueParsers/includes/parsers/DmCoordinateParser.php
+++ b/ValueParsers/includes/parsers/DmCoordinateParser.php
@@ -38,33 +38,6 @@
}
 
/**
-* @see GeoCoordinateParserBase::detectPrecision
-*/
-   protected function detectPrecision( $number ) {
-   $minutes = $number * 60;
-
-   // Since we are in the DM parser, we know that precision needs 
at least to be an arcminute:
-   $precision = 1 / 60;
-
-   // The minute may be a float; In order to detect a proper 
precision, we convert the minutes
-   // to seconds.
-   if( $minutes - floor( $minutes ) > 0 ) {
-   $seconds = $minutes * 60;
-
-   $precision = 1 / 3600;
-
-   // TODO: Implement localized decimal separator.
-   $secondsSplit = explode( '.', $seconds );
-
-   if( isset(

[MediaWiki-commits] [Gerrit] Introduced GlobeCoordinateParser - change (mediawiki...DataValues)

2013-08-20 Thread Jeroen De Dauw (Code Review)
Jeroen De Dauw has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/79985


Change subject: Introduced GlobeCoordinateParser
..

Introduced GlobeCoordinateParser

This new parser has the same behaviour as the old GeoCoordinateParser.
The later now returnes a simple LatLongValue and no longer does precision
detection. Existing behaviour of this component should not have changed
visibily to the outside.

Change-Id: I20012795ced95e8afda7f2c21fd32730dc408432
---
M ValueParsers/ValueParsers.classes.php
M ValueParsers/ValueParsers.php
M ValueParsers/includes/parsers/DdCoordinateParser.php
M ValueParsers/includes/parsers/DmCoordinateParser.php
M ValueParsers/includes/parsers/DmsCoordinateParser.php
M ValueParsers/includes/parsers/FloatCoordinateParser.php
M ValueParsers/includes/parsers/GeoCoordinateParser.php
M ValueParsers/includes/parsers/GeoCoordinateParserBase.php
A ValueParsers/includes/parsers/GlobeCoordinateParser.php
M ValueParsers/tests/phpunit/api/ApiParseValueTest.php
M ValueParsers/tests/phpunit/parsers/DdCoordinateParserTest.php
M ValueParsers/tests/phpunit/parsers/DmCoordinateParserTest.php
M ValueParsers/tests/phpunit/parsers/DmsCoordinateParserTest.php
M ValueParsers/tests/phpunit/parsers/FloatCoordinateParserTest.php
M ValueParsers/tests/phpunit/parsers/GeoCoordinateParserTest.php
A ValueParsers/tests/phpunit/parsers/GlobeCoordinateParserTest.php
16 files changed, 417 insertions(+), 276 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DataValues 
refs/changes/85/79985/1

diff --git a/ValueParsers/ValueParsers.classes.php 
b/ValueParsers/ValueParsers.classes.php
index 3e37476..756e007 100644
--- a/ValueParsers/ValueParsers.classes.php
+++ b/ValueParsers/ValueParsers.classes.php
@@ -26,6 +26,7 @@
'ValueParsers\FloatCoordinateParser' => 
'includes/parsers/FloatCoordinateParser.php',
'ValueParsers\GeoCoordinateParser' => 
'includes/parsers/GeoCoordinateParser.php',
'ValueParsers\GeoCoordinateParserBase' => 
'includes/parsers/GeoCoordinateParserBase.php',
+   'ValueParsers\GlobeCoordinateParser' => 
'includes/parsers/GlobeCoordinateParser.php',
'ValueParsers\FloatParser' => 'includes/parsers/FloatParser.php',
'ValueParsers\IntParser' => 'includes/parsers/IntParser.php',
'ValueParsers\NullParser' => 'includes/parsers/NullParser.php',
diff --git a/ValueParsers/ValueParsers.php b/ValueParsers/ValueParsers.php
index 06b2571..73e3abb 100644
--- a/ValueParsers/ValueParsers.php
+++ b/ValueParsers/ValueParsers.php
@@ -46,7 +46,7 @@
 
 $wgValueParsers['bool'] = 'ValueParsers\BoolParser';
 $wgValueParsers['float'] = 'ValueParsers\FloatParser';
-$wgValueParsers['globecoordinate'] = 'ValueParsers\GeoCoordinateParser';
+$wgValueParsers['globecoordinate'] = 'ValueParsers\GlobeCoordinateParser';
 $wgValueParsers['int'] = 'ValueParsers\IntParser';
 $wgValueParsers['null'] = 'ValueParsers\NullParser';
 
diff --git a/ValueParsers/includes/parsers/DdCoordinateParser.php 
b/ValueParsers/includes/parsers/DdCoordinateParser.php
index c6f0a87..1789236 100644
--- a/ValueParsers/includes/parsers/DdCoordinateParser.php
+++ b/ValueParsers/includes/parsers/DdCoordinateParser.php
@@ -46,22 +46,6 @@
}
 
/**
-* @see GeoCoordinateParserBase::detectPrecision
-*/
-   protected function detectPrecision( $number ) {
-   // TODO: Implement localized decimal separator.
-   $split = explode( '.', $number );
-
-   $precision = 1;
-
-   if( isset( $split[1] ) ) {
-   $precision = pow( 10, -1 * strlen( $split[1] ) );
-   }
-
-   return $precision;
-   }
-
-   /**
 * @see GeoCoordinateParserBase::areValidCoordinates
 */
protected function areValidCoordinates( $normalizedCoordinateSegments ) 
{
diff --git a/ValueParsers/includes/parsers/DmCoordinateParser.php 
b/ValueParsers/includes/parsers/DmCoordinateParser.php
index 296af05..8039e36 100644
--- a/ValueParsers/includes/parsers/DmCoordinateParser.php
+++ b/ValueParsers/includes/parsers/DmCoordinateParser.php
@@ -38,33 +38,6 @@
}
 
/**
-* @see GeoCoordinateParserBase::detectPrecision
-*/
-   protected function detectPrecision( $number ) {
-   $minutes = $number * 60;
-
-   // Since we are in the DM parser, we know that precision needs 
at least to be an arcminute:
-   $precision = 1 / 60;
-
-   // The minute may be a float; In order to detect a proper 
precision, we convert the minutes
-   // to seconds.
-   if( $minutes - floor( $minutes ) > 0 ) {
-   $seconds = $minutes * 60;
-
-   $precision = 1 / 3600;
-
-   // TODO: Implement localized decimal separator.
-   $secondsSplit = explod