private function cardinal($value)
    {
        // If cardinal direction was not on previous coordinate it can be anything
        if (null === $this->nextCardinal) {
            $this->nextCardinal = Lexer::T_CARDINAL_LON === $this->lexer->lookahead['type'] ? Lexer::T_CARDINAL_LON : Lexer::T_CARDINAL_LAT;
        }

        // Match cardinal direction
        $cardinal = $this->match($this->nextCardinal);
        // By default don't change sign
        $sign     = 1;
        // Define value range
        $range    = 0;

        switch (strtolower($cardinal)) {
            case 's':
                // Southern latitudes are negative
                $sign = -1;
                // no break
            case 'n':
                // Set requirement for second coordinate
                $this->nextCardinal = Lexer::T_CARDINAL_LON;
                // Latitude values are +/- 90
                $range = 90;
                break;
            case 'w':
                // Western longitudes are negative
                $sign = -1;
                // no break
            case 'e':
                // Set requirement for second coordinate
                $this->nextCardinal = Lexer::T_CARDINAL_LAT;
                // Longitude values are +/- 180
                $range = 180;
                break;
        }

        // Throw exception if value is out of range
        if ($value > $range) {
            throw $this->rangeError('Degrees', $range, -1 * $range);
        }

        // Return value with sign
        return $value * $sign;
    }
private function cardinal($value)
    {
        // If cardinal direction was not on previous coordinate it can be anything
        if (null === $this->nextCardinal) {
            $this->nextCardinal = Lexer::T_CARDINAL_LON === $this->lexer->lookahead['type'] ? Lexer::T_CARDINAL_LON : Lexer::T_CARDINAL_LAT;
        }

        // Match cardinal direction
        $cardinal = $this->match($this->nextCardinal);
        // By default don't change sign
        $sign     = 1;
        // Define value range
        $range    = 0;

        switch (strtolower($cardinal)) {
            case 's':
                // Southern latitudes are negative
                $sign = -1;
                // no break
            case 'n':
                // Set requirement for second coordinate
                $this->nextCardinal = Lexer::T_CARDINAL_LON;
                // Latitude values are +/- 90
                $range = 90;
                break;
            case 'w':
                // Western longitudes are negative
                $sign = -1;
                // no break
            case 'e':
                // Set requirement for second coordinate
                $this->nextCardinal = Lexer::T_CARDINAL_LAT;
                // Longitude values are +/- 180
                $range = 180;
                break;
        }

        // Throw exception if value is out of range
        if ($value > $range) {
            throw $this->rangeError('Degrees', $range, -1 * $range);
        }

        // Return value with sign
        return $value * $sign;
    }
private function cardinal ( $ value ) { // If cardinal direction was not on previous coordinate it can be anything if ( null === $ this -> nextCardinal ) { $ this -> nextCardinal = Lexer :: T_CARDINAL_LON === $ this -> lexer -> lookahead [ 'type' ] ? Lexer :: T_CARDINAL_LON : Lexer :: T_CARDINAL_LAT ; } // Match cardinal direction $ cardinal = $ this -> match ( $ this -> nextCardinal ) ; // By default don't change sign $ sign = 1 ; // Define value range $ range = 0 ; switch ( strtolower ( $ cardinal ) ) { case 's' : // Southern latitudes are negative $ sign = - 1 ; // no break case 'n' : // Set requirement for second coordinate $ this -> nextCardinal = Lexer :: T_CARDINAL_LON ; // Latitude values are +/- 90 $ range = 90 ; break ; case 'w' : // Western longitudes are negative $ sign = - 1 ; // no break case 'e' : // Set requirement for second coordinate $ this -> nextCardinal = Lexer :: T_CARDINAL_LAT ; // Longitude values are +/- 180 $ range = 180 ; break ; } // Throw exception if value is out of range if ( $ value > $ range ) { throw $ this -> rangeError ( 'Degrees' , $ range , - 1 * $ range ) ; } // Return value with sign return $ value * $ sign ; }
Match cardinal direction and return sign

@param int|float $value

@return int
@throws RangeException
Match cardinal direction and return sign