| | | 1 | | namespace Itinero.Network.Tiles; |
| | | 2 | | |
| | | 3 | | internal static class DataHelpers |
| | | 4 | | { |
| | | 5 | | public static uint? DecodeNullableData(this uint data) |
| | 6664 | 6 | | { |
| | 6664 | 7 | | if (data == 0) |
| | 4467 | 8 | | { |
| | 4467 | 9 | | return null; |
| | | 10 | | } |
| | | 11 | | |
| | 2197 | 12 | | return data - 1; |
| | 6664 | 13 | | } |
| | | 14 | | |
| | | 15 | | public static uint EncodeAsNullableData(this uint? data) |
| | 1293 | 16 | | { |
| | 1293 | 17 | | if (!data.HasValue) |
| | 917 | 18 | | { |
| | 917 | 19 | | return 0; |
| | | 20 | | } |
| | | 21 | | |
| | 376 | 22 | | return data.Value + 1; |
| | 1293 | 23 | | } |
| | | 24 | | |
| | | 25 | | public static uint EncodeToNullableData(this uint data) |
| | 640 | 26 | | { |
| | 640 | 27 | | return data + 1; |
| | 640 | 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 | | } |