GanosBase surface models can be represented in Well-Known Binary (WKB) format. WKB ensures data precision and facilitates transmission.
How it works
WKB encodes a GanosBase SFMesh object by extracting its data into a sequence of typed numerical values, then serializing those values in the specified byte order.
Two byte orders are supported:
| Byte order | Constant | Value |
|---|---|---|
| Little Endian | NDR (Network Data Representation) | 1 |
| Big Endian | XDR (External Data Representation) | 0 |
Numerical types
All field sizes and encodings follow these type definitions. The definitions apply to both NDR and XDR byte orders.
| Type | Size | Description |
|---|---|---|
Uint1 | 1 byte (8-bit) | Unsigned integer |
Byte | 1 byte (8-bit) | Signed integer |
Uint16 | 2 bytes (16-bit) | Unsigned integer |
Uint32 | 4 bytes (32-bit) | Unsigned integer |
Float | 4 bytes (32-bit) | Floating-point number (IEEE 754) |
Double | 8 bytes (64-bit) | Floating-point number (IEEE 754) |
Geometric types
GanosBase supports all geometry types from the Open Geospatial Consortium (OGC) Simple Feature model, plus three extended types for surface mesh representation:
IndexSurface — indexed vertex surface (type code 22)
TriangleStrip — triangle strip surface (type code 20)
TriangleFan — triangle fan surface (type code 21)
For details on how these types model 3D geometry, see Data models in surface mesh models.
SRID support
Extended Well-Known Text (EWKT) is an extension of Well-Known Text (WKT) that incorporates Spatial Reference System Identifiers (SRIDs). In WKB structures, fields marked /* if WKBSRIDFLAG */ are present only when an SRID is specified.
Definitions
General definitions
// Basic type definitions
// byte : 1 byte
// uint8 : 1 byte
// uint16: 2 bytes
// uint32: 32-bit unsigned integer (4 bytes)
// float : single-precision number (4 bytes)
// double: double-precision number (8 bytes)
enum WKBByteOrder {
wkbXDR = 0, // Big Endian
wkbNDR = 1 // Little Endian
}
// Point types
Point2D {
double x;
double y
}
Point3D {
double x;
double y,
double z
}
Point4D {
double x;
double y,
double z,
double m
}
Point {
union
{
Point2D point2d;
Point3D point3d;
Point4D point4d;
}
}
// LinearRing
LinearRing {
uint32 numPoints;
Point points[numPoints];
}
// Normal vector
NormalPoint {
float x;
float y;
float z;
}
NormalPointArray {
uint32 numPoints;
NormalPoint points[numPoints];
}
// Texture coordinate
TexcoordPoint {
float x;
float y;
}
TexcoordPointArray {
uint32 numPoints;
TexcoordPoint points[numPoints];
}
// String
String
{
uint32 stringLength;
byte string[stringLength];
}
// Variable-length integer
enum IntType {
Int8 = 1;
Int16 = 2;
Int32 = 4;
}
varint {
union {
uint8 uint8;
uint16 uint16;
uint32 uint32;
}
}
varintArray {
uint32 numInt;
byte intType; // WKBIntType
varint values[numInt];
}Extended geometry types
TriangleStrip
WKBTriangleStrip {
byte byteOrder;
static uint32 wkbType = 20;
/*
#define WKBZOFFSET 0x80000000
#define WKBMOFFSET 0x40000000
#define WKBSRIDFLAG 0x20000000
*/
uint32 srid; /* if WKBSRIDFLAG */
uint32 numRings = 1;
LinearRing ring;
}TriangleFan
WKBTriangleFan {
byte byteOrder;
static uint32 wkbType = 21;
/*
#define WKBZOFFSET 0x80000000
#define WKBMOFFSET 0x40000000
#define WKBSRIDFLAG 0x20000000
*/
uint32 srid; /* if WKBSRIDFLAG */
uint32 numRings = 1;
LinearRing rings
}IndexSurface
WKBIndexsurface {
byte byteOrder;
static uint32 wkbType = 22;
/*
#define WKBZOFFSET 0x80000000
#define WKBMOFFSET 0x40000000
#define WKBSRIDFLAG 0x20000000
*/
uint32 srid; /* if WKBSRIDFLAG */
LinearRing ring;
varintArray VertexIndex;
varintArray VertexNum;
}GeometryCollection
WKBGeometry {
Union {
WKBPoint point;
WKBLineString linestring;
WKBPolygon polygon;
WKBMultiPoint mpoint;
WKBMultiLineString mlinestring;
WKBMultiPolygon mpolygon;
WKBTriangleStrip strip;
WKBTriangleFan fan;
WKBIndexsurface indexsurface;
}
};
WKBGeometryCollection {
byte byte_order;
static uint32 wkbType = 7;
uint32 numGeometries;
WKBGeometry geometries[numGeometries];
}Texture
enum wkbTFormat
{
wkbTFRaw = 0;
wkbTFJPG = 1;
wkbTFPNG = 2;
}
enum wkbTType
{
wkbTTFile = 1;
wkbTTDB = 2;
wkbTTBytes = 3;
wkbTTWeb = 4;
}
WKBTexture {
byte byteOrder;
static byte version = 1;
byte compress = 0;
byte format; /* wkbTFormat */
static byte wrap = 0;
byte type; /* wkbTType */
byte depth; /* 1, 2, or 4 */
uint32 width;
uint32 height;
uint32 dataLength;
byte data[dataLength];
String name;
}Material
WKBMaterial {
byte byteOrder;
static byte version = 1;
uint1 type;
uint4 numTextures;
WKBTexture textures[numTextures];
WKBString name;
WKBString data;
}MeshGeom
WKBMeshGeom
{
byte byteOrder;
uint32 wkbType;
/*
#define WKBZOFFSET 0x80000000
#define WKBMOFFSET 0x40000000
#define WKBSRIDFLAG 0x20000000
#define WKBGEOMFLAG 0x04000000
#define WKBNORMALFLAG 0x02000000
#define WKBTEXCOORDFLAG 0x01000000
#define WKBREFFLAG 0x00400000
#define WKBSOLIDFLAG 0x00200000
*/
uint32 srid; /* if WKBSRIDFLAG */
WKBGeometryCollection patches; /* if WKBGEOMFLAG */
uint32 numNormalPointArray; /* if WKBNORMALFLAG */
NormalPointArray normalPoints[numNormalPointArray]; /* if WKBNORMALFLAG */
uint32 numTexcoordPointArray; /* if WKBTEXCOORDFLAG */
TexcoordPointArray texcoordPoints[numTexcoordPointArray]; /* if WKBTEXCOORDFLAG */
String path; /* if WKBREFFLAG */
}SFMesh
WKBMatrix {
double matrix[12];
}
WKBNode
{
uint8 flags;
/*
#define WKBPRIMITIVEFLAG 0x01u<<0
#define WKBMATRIXFLAG 0x01u<<2
#define WKBIDFLAG 0x01u<<3
*/
uint32 primitive; /* if WKBPRIMITIVEFLAG */
varintArray children; /* if not WKBPRIMITIVEFLAG */
WKBMatrix matrix; /* if WKBMATRIXFLAG */
uint32 id; /* if WKBIDFLAG */
}
WKBPrimitive {
uint8 flags;
uint8 reserved;
uint16 materialId;
uint32 index;
}
SFMesh
{
byte byteOrder;
static byte magic = 'M';
static byte version = 1;
uint16 flags;
/*
#define WKBMESHZFLAG 0x0001u /* have z */
#define WKBMESHMFLAG 0x0001u<<1 /* have M */
#define WKBMESHREFFLAG 0x0001u<<4 /* is ref */
#define WKBMESHGEOMFLAG 0x0001u<<5 /* have meshgeom */
#define WKBMESHMESHFLAG 0x0001u<<6 /* have mesh */
#define WKBMESHTEXTUREFLAG 0x0001u<<7 /* have texture */
#define WKBMESHMATERIALFLAG 0x0001u<<8 /* have material */
#define WKBMESHLODFLAG 0x0001u<<9 /* have lod */
#define WKBMESHSRIDFLAG 0x0001u<<11 /* have srid */
#define WKBMESHUSERFLAG 0x0001u<<12 /* have user data */
#define WKBMESHBINFLAG 0x0001u<<13 /* have bin data */
#define WKBMESHEXFLAG 0x0001u<<14 /* have exflags */
#define WKBMESHSYSFLAG 0x0001u<<15 /* have system data */
*/
uint32 exflags; /* if WKBMESHEXFLAG */
uint32 srid; /* if WKBMESHSRIDFLAG */
uint16 lod; /* if WKBMESHLODFLAG */
uint32 root; /* if not WKBMESHREFFLAG */
uint32 numMeshgeom; /* if WKBMESHGEOMFLAG */
WKBMeshgeom meshgeoms[numMeshgeom]; /* if WKBMESHGEOMFLAG */
uint32 numSFMesh; /* if WKBMESHMESHFLAG */
WKBSFMesh sfmesh[numSFMesh]; /* if WKBMESHMESHFLAG */
uint32 numTexture; /* if WKBMESHTEXTUREFLAG */
WKBTexture textures[numTexture]; /* if WKBMESHTEXTUREFLAG */
uint32 numNode; /* if not WKBMESHREFFLAG */
WKBNode nodes[numNode]; /* if not WKBMESHREFFLAG */
uint32 numPrimitives; /* if not WKBMESHREFFLAG */
WKBPrimitive primitives[numPrimitives]; /* if not WKBMESHREFFLAG */
String path; /* if WKBMESHREFFLAG */
String userdata; /* if WKBMESHUSERFLAG */
String bindata; /* if WKBMESHBINFLAG */
String sysdata; /* if WKBMESHSYSFLAG */
}Type code reference
| Type | wkbType value |
|---|---|
WKBTriangleStrip | 20 |
WKBTriangleFan | 21 |
WKBIndexsurface | 22 |
WKBGeometryCollection | 7 |
Flag reference
MeshGeom flags
| Flag | Value | Description |
|---|---|---|
WKBZOFFSET | 0x80000000 | Has Z dimension |
WKBMOFFSET | 0x40000000 | Has M dimension |
WKBSRIDFLAG | 0x20000000 | Has SRID |
WKBGEOMFLAG | 0x04000000 | Has geometry collection |
WKBNORMALFLAG | 0x02000000 | Has normal vectors |
WKBTEXCOORDFLAG | 0x01000000 | Has texture coordinates |
WKBREFFLAG | 0x00400000 | Is a reference (external path) |
WKBSOLIDFLAG | 0x00200000 | Is a solid |
SFMesh flags
| Flag | Value | Description |
|---|---|---|
WKBMESHZFLAG | 0x0001u | Has Z coordinate |
WKBMESHMFLAG | 0x0001u<<1 | Has M coordinate |
WKBMESHREFFLAG | 0x0001u<<4 | Is a reference |
WKBMESHGEOMFLAG | 0x0001u<<5 | Has MeshGeom |
WKBMESHMESHFLAG | 0x0001u<<6 | Has sub-meshes |
WKBMESHTEXTUREFLAG | 0x0001u<<7 | Has textures |
WKBMESHMATERIALFLAG | 0x0001u<<8 | Has materials |
WKBMESHLODFLAG | 0x0001u<<9 | Has level of detail |
WKBMESHSRIDFLAG | 0x0001u<<11 | Has SRID |
WKBMESHUSERFLAG | 0x0001u<<12 | Has user data |
WKBMESHBINFLAG | 0x0001u<<13 | Has binary data |
WKBMESHEXFLAG | 0x0001u<<14 | Has extended flags |
WKBMESHSYSFLAG | 0x0001u<<15 | Has system data |
WKBNode flags
| Flag | Value | Description |
|---|---|---|
WKBPRIMITIVEFLAG | 0x01u<<0 | Node is a primitive |
WKBMATRIXFLAG | 0x01u<<2 | Has transformation matrix |
WKBIDFLAG | 0x01u<<3 | Has ID |