DecodeGeoInvertedKey decodes the bounding box from the geo inverted key. The cellid is skipped in the decoding.
(b []byte)
| 1087 | // DecodeGeoInvertedKey decodes the bounding box from the geo inverted key. |
| 1088 | // The cellid is skipped in the decoding. |
| 1089 | func DecodeGeoInvertedKey(b []byte) (loX, loY, hiX, hiY float64, remaining []byte, err error) { |
| 1090 | // Minimum: 1 byte marker + 1 byte cell length + |
| 1091 | // 1 byte bbox encoding kind + 16 bytes for 2 floats |
| 1092 | if len(b) < 3+2*uint64AscendingEncodedLength { |
| 1093 | return 0, 0, 0, 0, b, |
| 1094 | errors.Errorf("inverted key length %d too small", len(b)) |
| 1095 | } |
| 1096 | if b[0] != geoInvertedIndexMarker { |
| 1097 | return 0, 0, 0, 0, b, errors.Errorf("marker is not geoInvertedIndexMarker") |
| 1098 | } |
| 1099 | b = b[1:] |
| 1100 | var cellLen int |
| 1101 | if cellLen, err = getVarintLen(b); err != nil { |
| 1102 | return 0, 0, 0, 0, b, err |
| 1103 | } |
| 1104 | if len(b) < cellLen+17 { |
| 1105 | return 0, 0, 0, 0, b, |
| 1106 | errors.Errorf("insufficient length for encoded bbox in inverted key: %d", len(b)-cellLen) |
| 1107 | } |
| 1108 | encodingKind := geoInvertedBBoxEncodingKind(b[cellLen]) |
| 1109 | if encodingKind != geoInvertedTwoFloats && encodingKind != geoInvertedFourFloats { |
| 1110 | return 0, 0, 0, 0, b, |
| 1111 | errors.Errorf("unknown encoding kind for bbox in inverted key: %d", encodingKind) |
| 1112 | } |
| 1113 | b = b[cellLen+1:] |
| 1114 | if b, loX, err = DecodeUntaggedFloatValue(b); err != nil { |
| 1115 | return 0, 0, 0, 0, b, err |
| 1116 | } |
| 1117 | if b, loY, err = DecodeUntaggedFloatValue(b); err != nil { |
| 1118 | return 0, 0, 0, 0, b, err |
| 1119 | } |
| 1120 | if encodingKind == geoInvertedFourFloats { |
| 1121 | if b, hiX, err = DecodeUntaggedFloatValue(b); err != nil { |
| 1122 | return 0, 0, 0, 0, b, err |
| 1123 | } |
| 1124 | if b, hiY, err = DecodeUntaggedFloatValue(b); err != nil { |
| 1125 | return 0, 0, 0, 0, b, err |
| 1126 | } |
| 1127 | } else { |
| 1128 | hiX = loX |
| 1129 | hiY = loY |
| 1130 | } |
| 1131 | return loX, loY, hiX, hiY, b, nil |
| 1132 | } |
| 1133 | |
| 1134 | // EncodeNullDescending is the descending equivalent of EncodeNullAscending. |
| 1135 | func EncodeNullDescending(b []byte) []byte { |
nothing calls this directly
no test coverage detected
searching dependent graphs…