Skip to content

Commit 7693304

Browse files
committed
Fix shortening code
1 parent 6409730 commit 7693304

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/OpenLocationCode.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ public static function isPaddedByCode($code){
225225
return (new self($code))->isPadded();
226226
}
227227

228+
/**
229+
* @param double $referenceLatitude
230+
* @param double $referenceLongitude
231+
* @return OpenLocationCode
232+
*/
228233
public function shorten($referenceLatitude,$referenceLongitude){
229234
if(!$this->isFull()){
230235
throw new InvalidArgumentException('shorten() method could only be called on a full code.');
@@ -234,8 +239,7 @@ public function shorten($referenceLatitude,$referenceLongitude){
234239
}
235240

236241
$codeArea = $this->decode();
237-
var_dump($codeArea);
238-
$range = max(abs($referenceLatitude - $codeArea->getCenterLatitude()),$referenceLongitude - $codeArea->getCenterLongitude());
242+
$range = max(abs($referenceLatitude - $codeArea->getCenterLatitude()),abs($referenceLongitude - $codeArea->getCenterLongitude()));
239243

240244
for($i=4;$i>=1;$i--){
241245
if($range<(self::computeLatitudePrecision($i*2)*0.3)){

tests/ShorteningTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ public function testShortening(){
2626
if('B'!==$testData->testType && 'S'!==$testData->testType){
2727
continue;
2828
}
29-
var_dump($testData);
3029
$olc = new OpenLocationCode($testData->code);
3130
$shortened = $olc->shorten($testData->referenceLatitude,$testData->referenceLongitude);
3231
$this->assertEquals($testData->shortCode,$shortened->getCode(),'Wrong shortening of code '.$testData->code);

0 commit comments

Comments
 (0)