@@ -37,8 +37,8 @@ protected function generateRevOlcCode(float $latitude, float $longitude, int $co
3737 // Multiply values by their precision and convert to positive.
3838 // Rounding avoids/minimizes errors due to floating-point precision.
3939 // Since the numbers are positive, floor() is equivalent to intval().
40- $ latVal = floor (round (($ latitude + OpenLocationCode::LATITUDE_MAX ) * OpenLocationCode ::LAT_INTEGER_MULTIPLIER * 1e6 ) / 1e6 );
41- $ lngVal = floor (round (($ longitude + OpenLocationCode::LONGITUDE_MAX ) * OpenLocationCode ::LNG_INTEGER_MULTIPLIER * 1e6 ) / 1e6 );
40+ $ latVal = floor (round (($ latitude + OpenLocationCode::LATITUDE_MAX ) * self ::LAT_INTEGER_MULTIPLIER * 1e6 ) / 1e6 );
41+ $ lngVal = floor (round (($ longitude + OpenLocationCode::LONGITUDE_MAX ) * self ::LNG_INTEGER_MULTIPLIER * 1e6 ) / 1e6 );
4242
4343 // Compute the grid part of the code if necessary.
4444 if ($ codeLength > OpenLocationCode::PAIR_CODE_LENGTH ) {
@@ -76,8 +76,8 @@ public function decode(string $strippedCode): CodeArea
7676 // Initialize the values.
7777 // We will assume these values are floats to ensure 32bit PHP compatibility.
7878 // See relevant comments in encode() above.
79- $ latVal = -OpenLocationCode::LATITUDE_MAX * OpenLocationCode ::LAT_INTEGER_MULTIPLIER ;
80- $ lngVal = -OpenLocationCode::LONGITUDE_MAX * OpenLocationCode ::LNG_INTEGER_MULTIPLIER ;
79+ $ latVal = -OpenLocationCode::LATITUDE_MAX * self ::LAT_INTEGER_MULTIPLIER ;
80+ $ lngVal = -OpenLocationCode::LONGITUDE_MAX * self ::LNG_INTEGER_MULTIPLIER ;
8181 // Define the place value for the digits. We'll divide this down as we work through the code.
8282 $ latPlaceVal = self ::LAT_MSP_VALUE ;
8383 $ lngPlaceVal = self ::LNG_MSP_VALUE ;
@@ -99,10 +99,10 @@ public function decode(string $strippedCode): CodeArea
9999 unset($ digit );
100100 }
101101 unset($ i );
102- $ latitudeLo = $ latVal / OpenLocationCode ::LAT_INTEGER_MULTIPLIER ;
103- $ longitudeLo = $ lngVal / OpenLocationCode ::LNG_INTEGER_MULTIPLIER ;
104- $ latitudeHi = ($ latVal + $ latPlaceVal ) / OpenLocationCode ::LAT_INTEGER_MULTIPLIER ;
105- $ longitudeHi = ($ lngVal + $ lngPlaceVal ) / OpenLocationCode ::LNG_INTEGER_MULTIPLIER ;
102+ $ latitudeLo = $ latVal / self ::LAT_INTEGER_MULTIPLIER ;
103+ $ longitudeLo = $ lngVal / self ::LNG_INTEGER_MULTIPLIER ;
104+ $ latitudeHi = ($ latVal + $ latPlaceVal ) / self ::LAT_INTEGER_MULTIPLIER ;
105+ $ longitudeHi = ($ lngVal + $ lngPlaceVal ) / self ::LNG_INTEGER_MULTIPLIER ;
106106 return new CodeArea (
107107 $ latitudeLo ,
108108 $ longitudeLo ,
0 commit comments