Skip to content

Commit fba3383

Browse files
author
unknown
committed
Add handling for lat/lon out of bounds in test set generation.
1 parent bc1a495 commit fba3383

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

example/mapcode.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,20 @@ static void generateAndOutputMapcodes(double lat, double lon, int iShowError) {
277277

278278
char* results[MAX_NR_OF_MAPCODE_RESULTS];
279279
int context = 0;
280+
281+
while (lon > 180) {
282+
lon -= 360;
283+
}
284+
while (lon < -180) {
285+
lon += 360;
286+
}
287+
while (lat > 90) {
288+
lat -= 180;
289+
}
290+
while (lat < -90) {
291+
lat += 180;
292+
}
293+
280294
const int nrResults = encodeLatLonToMapcodes(results, lat, lon, context);
281295
if (nrResults <= 0) {
282296
if (iShowError) {

0 commit comments

Comments
 (0)