GanosBase surface models can be represented in Well-Known Binary (WKB) format. The WKB format can ensure data precision and facilitate transmission.
Overview
In the process of representing GanosBase surface models in WKB format, data is extracted from SFmesh objects and converted into numerical sequences. These numerical sequences are then serialized based on the specified byte order.
WKB supports two types of byte orders: Network Data Representation (NDR, also known as Little Endian) and External Data Representation (XDR, also known as Big Endian).
Geometric structures
In addition to basic types defined in the Open Geospatial Consortium (OGC) Simple Feature model, GanosBase surface models also support the following geometric structures:
IndexSurface
TriangleStrip
TriangleFan
For more information, see Data models in surface mesh models.
Numerical definitions
Uint1: 8-bit (1 byte) unsigned integer.
Byte: 8-bit (1 byte) signed integer.
Uint16: 16-bit (2 bytes) unsigned integer.
Uint32: 32-bit (4 bytes) unsigned integer.
Float: 32-bit (4 bytes) floating-point number, represented by using the IEEE 754 standard.
Double: 64-bit (8 bytes) floating-point number, represented by using the IEEE 754 standard.
The preceding numerical definitions apply to the XDR and NDR byte orders.
Specifications
The Extended Well-Known Text (EWKT) specifications are developed as an extension of WKT to incorporate spatial reference system identifiers (SRIDs). Specific member variables are available only if you specify the SRID.
Definitions
General definitions
// Basic Type definitions
// byte : 1 byte
// uint8: 1 byte
// uint16: 2 byte
// uint32 : 32 bit unsigned integer (4 bytes)
// float: single precison number (4 bytes)
// double : double precision number (8 bytes)
enum WKBByteOrder {
wkbXDR = 0, // Big Endian
wkbNDR = 1 // Little Endian
}
// point type
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 Point
NormalPoint {
float x;
float y;
float z;
}
NormalPointArray {
uint32 numPoints;
NormalPoint points[numPoints];
}
// Texcoord Point
TexcoordPoint {
float x;
float y;
}
TexcoordPointArray {
uint32 numPoints;
TexcoordPoint points[numPoints];
}
// String
String
{
uint32 stringLength;
byte string[stringLength];
}
// Var int
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 WKBGEOMFLAG0x04000000
#define WKBNORMALFLAG 0x02000000
#define WKBTEXCOORDFLAG0x01000000
#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 */ byte byteOrder;
uint32 wkbType;
/*
#define WKBZOFFSET 0x80000000
#define WKBMOFFSET 0x40000000
#define WKBSRIDFLAG 0x20000000
#define WKBGEOMFLAG0x04000000
#define WKBNORMALFLAG 0x02000000
#define WKBTEXCOORDFLAG0x01000000
#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]; /* 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 */
}