| | 1 | | namespace Itinero.Network.Tiles; |
| | 2 | |
|
| | 3 | | internal static class DataHelpers |
| | 4 | | { |
| | 5 | | public static uint? DecodeNullableData(this uint data) |
| 5540 | 6 | | { |
| 5540 | 7 | | if (data == 0) |
| 3663 | 8 | | { |
| 3663 | 9 | | return null; |
| | 10 | | } |
| | 11 | |
|
| 1877 | 12 | | return data - 1; |
| 5540 | 13 | | } |
| | 14 | |
|
| | 15 | | public static uint EncodeAsNullableData(this uint? data) |
| 1149 | 16 | | { |
| 1149 | 17 | | if (!data.HasValue) |
| 799 | 18 | | { |
| 799 | 19 | | return 0; |
| | 20 | | } |
| | 21 | |
|
| 350 | 22 | | return data.Value + 1; |
| 1149 | 23 | | } |
| | 24 | |
|
| | 25 | | public static uint EncodeToNullableData(this uint data) |
| 568 | 26 | | { |
| 568 | 27 | | return data + 1; |
| 568 | 28 | | } |
| | 29 | |
|
| | 30 | | public static ulong EncodeAsNullableData(this ulong? data) |
| 0 | 31 | | { |
| 0 | 32 | | if (!data.HasValue) |
| 0 | 33 | | { |
| 0 | 34 | | return 0; |
| | 35 | | } |
| | 36 | |
|
| 0 | 37 | | return data.Value + 1; |
| 0 | 38 | | } |
| | 39 | |
|
| | 40 | | public static ulong? DecodeNullableData(this ulong data) |
| 0 | 41 | | { |
| 0 | 42 | | if (data == 0) |
| 0 | 43 | | { |
| 0 | 44 | | return null; |
| | 45 | | } |
| | 46 | |
|
| 0 | 47 | | return data - 1; |
| 0 | 48 | | } |
| | 49 | | } |