@@ -82,8 +82,13 @@ int OLC_IsFull(const char* code, size_t size) {
82
82
return is_full (& info );
83
83
}
84
84
85
- int encodeIntegers (long long int lat , long long int lng , size_t length ,
86
- char * code , int maxlen ) {
85
+ int OLC_Encode (const OLC_LatLon * location , size_t length , char * code ,
86
+ int maxlen ) {
87
+ // Multiply degrees by precision. Use lround to explicitly round rather than
88
+ // truncate, which causes issues when using values like 0.1 that do not have
89
+ // precise floating point representations.
90
+ long long int lat = lround (location -> lat * kGridLatPrecisionInverse );
91
+ long long int lng = lround (location -> lon * kGridLonPrecisionInverse );
87
92
// Limit the maximum number of digits in the code.
88
93
if (length > kMaximumDigitCount ) {
89
94
length = kMaximumDigitCount ;
@@ -165,16 +170,6 @@ int encodeIntegers(long long int lat, long long int lng, size_t length,
165
170
return length ;
166
171
}
167
172
168
- int OLC_Encode (const OLC_LatLon * location , size_t length , char * code ,
169
- int maxlen ) {
170
- // Multiply degrees by precision. Use lround to explicitly round rather than
171
- // truncate, which causes issues when using values like 0.1 that do not have
172
- // precise floating point representations.
173
- long long int lat = lround (location -> lat * kGridLatPrecisionInverse );
174
- long long int lng = lround (location -> lon * kGridLonPrecisionInverse );
175
- return encodeIntegers (lat , lng , length , code , maxlen );
176
- }
177
-
178
173
int OLC_EncodeDefault (const OLC_LatLon * location , char * code , int maxlen ) {
179
174
return OLC_Encode (location , kPairCodeLength , code , maxlen );
180
175
}
0 commit comments