Skip to content

Commit fa6d7f9

Browse files
authored
rejoin split encode function (#715)
* rejoin split encode function * remove blank line
1 parent 0de8469 commit fa6d7f9

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

c/src/olc.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,13 @@ int OLC_IsFull(const char* code, size_t size) {
8282
return is_full(&info);
8383
}
8484

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);
8792
// Limit the maximum number of digits in the code.
8893
if (length > kMaximumDigitCount) {
8994
length = kMaximumDigitCount;
@@ -165,16 +170,6 @@ int encodeIntegers(long long int lat, long long int lng, size_t length,
165170
return length;
166171
}
167172

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-
178173
int OLC_EncodeDefault(const OLC_LatLon* location, char* code, int maxlen) {
179174
return OLC_Encode(location, kPairCodeLength, code, maxlen);
180175
}

0 commit comments

Comments
 (0)