@@ -11,14 +11,18 @@ normal usage:
1111``` d
1212import openlocationcode;
1313
14+ double lat = 54;
15+ double lon = 4;
16+
1417// get geo coordinates from plus code string
1518OpenLocationCode plusCode = OpenLocationCode.fromString("8FVC2222+22GCCCC");
1619writeln(plusCode.decode());
17- // ->
20+ // -> OpenLocationCodeArea(47.0001, 8.00006, 47.0001, 8.00006, 15)
1821
1922// get plus code string from geo coordinates
2023OpenLocationCode generatedPlusCode = OpenLocationCode.encode(lat, lon);
2124writeln(generatedPlusCode.code);
25+ // -> 9F662222+22
2226```
2327
2428---
@@ -28,20 +32,25 @@ writeln(generatedPlusCode.code);
2832``` d
2933import openlocationcode;
3034
35+ double lat = 54;
36+ double lon = 4;
37+
3138// get geo coordinates from plus code string
3239string input = "8FVC2222+22GCCCC";
33- if (!input.isValidCode)
40+ // make sure to only use uppercase characters in your input!
41+ if (!input.isValidUppercaseCode)
3442 return error;
3543OpenLocationCode plusCode = OpenLocationCode.fromTrustedString(input);
3644
3745if (!plusCode.isFull)
3846 return error;
3947OpenLocationCodeArea area = plusCode.decodeTrustedFull();
40- printf("area around %d, %d", area.centerLatitude, area.centerLongitude);
48+ printf("area around %f, %f\n", area.centerLatitude, area.centerLongitude);
49+ // -> area around 47.000062, 8.000063
4150
4251// get plus code string from geo coordinates
4352ubyte[maxOLCLength] buffer;
4453scope ubyte[] generatedPlusCodeString = OpenLocationCode.encode(buffer, lat, lon);
45- printf("%s ", cast(char[])generatedPlusCodeString );
46-
54+ printf("%.*s\n ", generatedPlusCodeString.length, &generatedPlusCodeString[0] );
55+ // -> 9F662222+22
4756```
0 commit comments