Guess数据类型

问题描述 投票:0回答:1

我目前尝试猜测以下原始字节具有什么数据类型。

25B3 E548 0200 0000 0003 BF1F D44B 217C 5440 B64E 74B6 E16B 5A40 8B54 F861 F2A9 5440 68C3 95DF C88A 5A40 1021 9EB2 16D6 5440 374D 0D3C FBAB 5A40 01EC2 1815 6400 5540 D628 2EA3>

ra

它保存在一个名为outlinePath的变量中,与形状有关。原始字节使用NSKeyedArchiver在base64中编码。

我已经尝试过float32数组和int16。但是,两者都不是合情合理的。

这是我想出的代码。这段代码可以在数据集的其他部分正常工作:

/**
 * Convert the base64 encoded float32 array to actually float32 values
 * @param buffer base64 encoded string
 */
export function convertBase64Floats(buffer: string) {
    // Decode base64
    const decodedBuffer = new Buffer(buffer, 'base64');
    // Float32 => 4 bytes
    // Get number of float values
    const floatValuesCount = decodedBuffer.length / 4;
    // New array with correct floats
    const arrayOfFloats: number[] = [];
    // Get float32s from buffer
    for (let i = 0; i < floatValuesCount; i++) {
        const offset = i * 4;
        const float = decodedBuffer.readFloatLE(offset);
        arrayOfFloats.push(float);
    }
    // Return new array of correct float values
    return arrayOfFloats;
}

export function convertInt32Array(buffer: Buffer, useBE: boolean = false) {
    const intValuesCount = buffer.length / 4;
    const arrayOfInts: number[] = [];
    for (let i = 0; i < intValuesCount; i++) {
        const offset = i * 4;
        const float = useBE ? buffer.readInt32BE(offset) : buffer.readInt32LE(offset);
        arrayOfInts.push(float);
    }
    return arrayOfInts;
}

/**
 * Convert the base64 encoded int32 array to actually int32 values
 * @param buffer base64 encoded string
 * @param useBE use readInt32BE instead of readInt32LE
 */
export function convertBase64Integers(buffer: string, useBE: boolean = false) {
    // Decode base64
    const decodedBuffer = new Buffer(buffer, 'base64');
    // Int32 => 4 bytes
    // Get number of integer values
    const intValuesCount = decodedBuffer.length / 4;
    // New array with correct floats
    const arrayOfInts: number[] = [];
    // Get float32s from buffer
    for (let i = 0; i < intValuesCount; i++) {
        const offset = i * 4;
        const float = useBE ? decodedBuffer.readInt32BE(offset) : decodedBuffer.readInt32LE(offset);
        arrayOfInts.push(float);
    }
    // Return new array of correct float values
    return arrayOfInts;
}

同一数据集还包含外观相似的变量strokePath。也是一个带有坐标的数组,称为extremePoints。

这里是完整数据集的链接,编码为json:https://pastebin.com/sadZAvyS

数据集表示以下形状:

enter image description here

也许有更多几何形状经验的人可以向我解释,这种数据结构如何表示局部形状。

编辑:我刚刚注意到,这也可能只是部分形状中一个小元素的数据。

我目前尝试猜测以下原始字节具有什么数据类型。 25B3 E548 0200 0000 0003 BF1F D44B 217C 5440 B64E 74B6 E16B 5A40 8B54 F861 F2A9 5440 68C3 95DF C88A 5A40 1021 9EB2 16D6 5440 374D ...

format byte shapes
1个回答
0
投票
[

不是一个答案,而是一个开始:

© www.soinside.com 2019 - 2024. All rights reserved.