Method: OpenLocationCode::Encoder#process
- Defined in:
- lib/open_location_code/encoder.rb
#process ⇒ String
Encode latitude and longitude
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/open_location_code/encoder.rb', line 157 def process if code_length < 2 || (code_length < SEPARATOR_POSITION && code_length % 2 == 1) raise OLCError, 'Invalid Open Location Code length' end # Latitude 90 needs to be adjusted to be just less, so the returned code # can also be decoded. if latitude == 90 self.latitude -= compute_latitude_precision end code = encode_pairs([code_length, PAIR_CODE_LENGTH].min) # If the requested length indicates we want grid refined codes. if code_length > PAIR_CODE_LENGTH code += encode_grid(code_length - PAIR_CODE_LENGTH) end code end |