[MediaWiki-commits] [Gerrit] Move a function to where it belongs - change (mediawiki...GeoData)
jenkins-bot has submitted this change and it was merged. Change subject: Move a function to where it belongs .. Move a function to where it belongs Change-Id: I2c95d824a5743dd24b426f625bce491639690743 --- M includes/api/ApiQueryGeoSearch.php M includes/api/ApiQueryGeoSearchDb.php M tests/MiscGeoDataTest.php 3 files changed, 29 insertions(+), 29 deletions(-) Approvals: Yurik: Looks good to me, approved jenkins-bot: Verified diff --git a/includes/api/ApiQueryGeoSearch.php b/includes/api/ApiQueryGeoSearch.php index 1677927..4688526 100644 --- a/includes/api/ApiQueryGeoSearch.php +++ b/includes/api/ApiQueryGeoSearch.php @@ -115,34 +115,6 @@ } } - /** -* Returns a range of tenths of degree -* -* @param float $start -* @param float $end -* @param int|null $granularity -* -* @return array -*/ - public static function intRange( $start, $end, $granularity = null ) { - global $wgGeoDataIndexGranularity; - - if ( !$granularity ) { - $granularity = $wgGeoDataIndexGranularity; - } - $start = round( $start * $granularity ); - $end = round( $end * $granularity ); - // @todo: works only on Earth - if ( $start > $end ) { - return array_merge( - range( -180 * $granularity, $end ), - range( $start, 180 * $granularity ) - ); - } else { - return range( $start, $end ); - } - } - public function getAllowedParams() { global $wgMaxGeoSearchRadius, $wgDefaultGlobe, $wgGeoDataDebug; $params = array ( diff --git a/includes/api/ApiQueryGeoSearchDb.php b/includes/api/ApiQueryGeoSearchDb.php index dfa29f0..cccadf7 100644 --- a/includes/api/ApiQueryGeoSearchDb.php +++ b/includes/api/ApiQueryGeoSearchDb.php @@ -102,4 +102,32 @@ } $this->addOption( 'USE INDEX', array( 'geo_tags' => 'gt_spatial' ) ); } + + /** +* Returns a range of tenths of degree +* +* @param float $start +* @param float $end +* @param int|null $granularity +* +* @return array +*/ + public static function intRange( $start, $end, $granularity = null ) { + global $wgGeoDataIndexGranularity; + + if ( !$granularity ) { + $granularity = $wgGeoDataIndexGranularity; + } + $start = round( $start * $granularity ); + $end = round( $end * $granularity ); + // @todo: works only on Earth + if ( $start > $end ) { + return array_merge( + range( -180 * $granularity, $end ), + range( $start, 180 * $granularity ) + ); + } else { + return range( $start, $end ); + } + } } diff --git a/tests/MiscGeoDataTest.php b/tests/MiscGeoDataTest.php index 62a98c1..ee3b973 100644 --- a/tests/MiscGeoDataTest.php +++ b/tests/MiscGeoDataTest.php @@ -8,7 +8,7 @@ * @dataProvider getIntRangeData */ public function testIntRange( $min, $max, $expected ) { - $this->assertEquals( $expected, ApiQueryGeoSearch::intRange( $min, $max ) ); + $this->assertEquals( $expected, ApiQueryGeoSearchDb::intRange( $min, $max ) ); } public function getIntRangeData() { -- To view, visit https://gerrit.wikimedia.org/r/262733 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I2c95d824a5743dd24b426f625bce491639690743 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/GeoData Gerrit-Branch: master Gerrit-Owner: MaxSem Gerrit-Reviewer: Yurik Gerrit-Reviewer: jenkins-bot <> ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Move a function to where it belongs - change (mediawiki...GeoData)
MaxSem has uploaded a new change for review. https://gerrit.wikimedia.org/r/262733 Change subject: Move a function to where it belongs .. Move a function to where it belongs Change-Id: I2c95d824a5743dd24b426f625bce491639690743 --- M includes/api/ApiQueryGeoSearch.php M includes/api/ApiQueryGeoSearchDb.php M tests/MiscGeoDataTest.php 3 files changed, 29 insertions(+), 29 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GeoData refs/changes/33/262733/1 diff --git a/includes/api/ApiQueryGeoSearch.php b/includes/api/ApiQueryGeoSearch.php index 1677927..4688526 100644 --- a/includes/api/ApiQueryGeoSearch.php +++ b/includes/api/ApiQueryGeoSearch.php @@ -115,34 +115,6 @@ } } - /** -* Returns a range of tenths of degree -* -* @param float $start -* @param float $end -* @param int|null $granularity -* -* @return array -*/ - public static function intRange( $start, $end, $granularity = null ) { - global $wgGeoDataIndexGranularity; - - if ( !$granularity ) { - $granularity = $wgGeoDataIndexGranularity; - } - $start = round( $start * $granularity ); - $end = round( $end * $granularity ); - // @todo: works only on Earth - if ( $start > $end ) { - return array_merge( - range( -180 * $granularity, $end ), - range( $start, 180 * $granularity ) - ); - } else { - return range( $start, $end ); - } - } - public function getAllowedParams() { global $wgMaxGeoSearchRadius, $wgDefaultGlobe, $wgGeoDataDebug; $params = array ( diff --git a/includes/api/ApiQueryGeoSearchDb.php b/includes/api/ApiQueryGeoSearchDb.php index dfa29f0..cccadf7 100644 --- a/includes/api/ApiQueryGeoSearchDb.php +++ b/includes/api/ApiQueryGeoSearchDb.php @@ -102,4 +102,32 @@ } $this->addOption( 'USE INDEX', array( 'geo_tags' => 'gt_spatial' ) ); } + + /** +* Returns a range of tenths of degree +* +* @param float $start +* @param float $end +* @param int|null $granularity +* +* @return array +*/ + public static function intRange( $start, $end, $granularity = null ) { + global $wgGeoDataIndexGranularity; + + if ( !$granularity ) { + $granularity = $wgGeoDataIndexGranularity; + } + $start = round( $start * $granularity ); + $end = round( $end * $granularity ); + // @todo: works only on Earth + if ( $start > $end ) { + return array_merge( + range( -180 * $granularity, $end ), + range( $start, 180 * $granularity ) + ); + } else { + return range( $start, $end ); + } + } } diff --git a/tests/MiscGeoDataTest.php b/tests/MiscGeoDataTest.php index 62a98c1..ee3b973 100644 --- a/tests/MiscGeoDataTest.php +++ b/tests/MiscGeoDataTest.php @@ -8,7 +8,7 @@ * @dataProvider getIntRangeData */ public function testIntRange( $min, $max, $expected ) { - $this->assertEquals( $expected, ApiQueryGeoSearch::intRange( $min, $max ) ); + $this->assertEquals( $expected, ApiQueryGeoSearchDb::intRange( $min, $max ) ); } public function getIntRangeData() { -- To view, visit https://gerrit.wikimedia.org/r/262733 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2c95d824a5743dd24b426f625bce491639690743 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/GeoData Gerrit-Branch: master Gerrit-Owner: MaxSem ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits