1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-02-08 04:25:12 +01:00
GPXSee/src/map/IMG/nodfile.h

107 lines
2.7 KiB
C
Raw Normal View History

2021-04-10 15:27:40 +02:00
#ifndef IMG_NODFILE_H
#define IMG_NODFILE_H
2022-03-25 19:28:32 +01:00
#include "section.h"
#include "subfile.h"
2021-04-10 15:27:40 +02:00
namespace IMG {
class NODFile : public SubFile
{
public:
2020-09-18 20:56:00 +02:00
struct BlockInfo
{
2021-09-29 19:52:39 +02:00
struct BlockHeader
2020-09-18 20:56:00 +02:00
{
2021-09-30 20:26:16 +02:00
quint32 nodeLonBase;
quint32 nodeLatBase;
quint32 linkInfoOffsetBase;
2021-09-29 19:52:39 +02:00
quint16 flags;
quint16 linkInfoSize;
quint8 linksCount;
quint8 nodesCount;
quint8 linkTypesCount;
quint32 size() const {return 0x13 + ((flags >> 0xb) & 1);}
};
quint32 offset;
BlockHeader hdr;
};
2020-09-18 20:56:00 +02:00
struct LinkInfo
{
quint32 linkOffset;
2020-09-18 20:56:00 +02:00
quint32 nodeOffset;
quint32 flags;
};
2020-09-18 20:56:00 +02:00
struct NodeInfo
{
QPoint pos;
quint8 flags;
quint8 bytes;
};
struct AdjacencyInfo
{
AdjacencyInfo(Handle &hdl, const BlockInfo &blockInfo,
quint32 linkId, const LinkInfo &linkInfo) : extHdl(hdl),
2020-09-18 20:56:00 +02:00
blockInfo(blockInfo), nodeOffset(linkInfo.nodeOffset),
linkOffset(linkInfo.linkOffset), linkId(linkId)
{}
Handle &extHdl;
2020-09-26 18:56:26 +02:00
BlockInfo blockInfo;
NodeInfo nodeInfo;
2020-09-18 20:56:00 +02:00
quint32 nodeOffset;
quint32 linkOffset;
quint32 linkId;
2020-09-29 18:53:49 +02:00
bool eog;
2020-09-18 20:56:00 +02:00
};
2022-03-25 19:28:32 +01:00
NODFile(const IMGData *img)
: SubFile(img), _indexFlags(0), _indexRecordSize(0), _blockRecordSize(0),
_blockShift(0), _nodeShift(0), _indexIdSize(0) {}
NODFile(const QString *path)
: SubFile(path), _indexFlags(0), _indexRecordSize(0), _blockRecordSize(0),
_blockShift(0), _nodeShift(0), _indexIdSize(0) {}
NODFile(const SubFile *gmp, quint32 offset)
: SubFile(gmp, offset), _indexFlags(0), _indexRecordSize(0),
2020-09-26 16:02:14 +02:00
_blockRecordSize(0), _blockShift(0), _nodeShift(0), _indexIdSize(0) {}
bool load(Handle &hdl);
quint32 indexIdSize() const {return _indexIdSize;}
2020-09-18 20:56:00 +02:00
bool blockInfo(Handle &hdl, quint32 blockId, BlockInfo &blockInfo) const;
bool linkInfo(Handle &hdl, const BlockInfo &blockInfo, quint32 linkId,
LinkInfo &linkInfo) const;
bool linkType(Handle &hdl, const BlockInfo &blockInfo, quint8 linkId,
quint32 &type) const;
int nextNode(Handle &hdl, AdjacencyInfo &adjInfo) const;
private:
2020-09-18 20:56:00 +02:00
bool nodeInfo(Handle &hdl, const BlockInfo &blockInfo, quint32 nodeOffset,
NodeInfo &nodeInfo) const;
bool nodeOffset(Handle &hdl, const BlockInfo &blockInfo, quint8 nodeId,
quint32 &nodeOffset) const;
bool absAdjInfo(Handle &hdl, AdjacencyInfo &adj) const;
bool relAdjInfo(Handle &hdl, AdjacencyInfo &adj) const;
bool adjacencyInfo(Handle &hdl, AdjacencyInfo &adj) const
{
return (adj.nodeInfo.flags & 0x20) ? absAdjInfo(hdl, adj)
: relAdjInfo(hdl, adj);
}
bool nodeBlock(Handle &hdl, quint32 nodeOffset, BlockInfo &blockInfo) const;
bool readBlock(Handle &hdl, quint32 blockOffset, BlockInfo &blockInfo) const;
2022-03-25 19:28:32 +01:00
Section _block, _index;
quint32 _flags, _indexFlags;
quint16 _indexRecordSize, _blockRecordSize;
2020-09-26 16:12:10 +02:00
quint8 _blockShift, _nodeShift, _indexIdSize;
};
2021-04-10 15:27:40 +02:00
}
#endif // IMG_NETFILE_H