@@ -11,14 +11,18 @@ normal usage:
11
11
``` d
12
12
import openlocationcode;
13
13
14
+ double lat = 54;
15
+ double lon = 4;
16
+
14
17
// get geo coordinates from plus code string
15
18
OpenLocationCode plusCode = OpenLocationCode.fromString("8FVC2222+22GCCCC");
16
19
writeln(plusCode.decode());
17
- // ->
20
+ // -> OpenLocationCodeArea(47.0001, 8.00006, 47.0001, 8.00006, 15)
18
21
19
22
// get plus code string from geo coordinates
20
23
OpenLocationCode generatedPlusCode = OpenLocationCode.encode(lat, lon);
21
24
writeln(generatedPlusCode.code);
25
+ // -> 9F662222+22
22
26
```
23
27
24
28
---
@@ -28,20 +32,25 @@ writeln(generatedPlusCode.code);
28
32
``` d
29
33
import openlocationcode;
30
34
35
+ double lat = 54;
36
+ double lon = 4;
37
+
31
38
// get geo coordinates from plus code string
32
39
string input = "8FVC2222+22GCCCC";
33
- if (!input.isValidCode)
40
+ // make sure to only use uppercase characters in your input!
41
+ if (!input.isValidUppercaseCode)
34
42
return error;
35
43
OpenLocationCode plusCode = OpenLocationCode.fromTrustedString(input);
36
44
37
45
if (!plusCode.isFull)
38
46
return error;
39
47
OpenLocationCodeArea 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
41
50
42
51
// get plus code string from geo coordinates
43
52
ubyte[maxOLCLength] buffer;
44
53
scope 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
47
56
```
0 commit comments