WKB详解

Well-known binary (WKB) representation
This section describes the well-known binary representation for geometries.

The OpenGIS Consortium "Simple Features for SQL " specification defines the well-known binary representation. This representation is also defined by the International Organization for Standardization (ISO) "SQL/MM Part: 3 Spatial " standard. See the related reference section at the end of this topic for information on functions that accept and produce the WKB.

The basic building block for well-known binary representations is the byte stream for a point, which consists of two double values. The byte streams for other geometries are built using the byte streams for geometries that are already defined.

The following example illustrates the basic building block for well-known binary representations.

// Basic Type definitions
// byte : 1 byte
// uint32 : 32 bit unsigned integer (4 bytes)
// double : double precision number (8 bytes)

// Building Blocks : Point, LinearRing

Point {
double x;
double y;
};
LinearRing {
uint32 numPoints;
Point points[numPoints];
};
enum wkbGeometryType {
wkbPoint = 1,
wkbLineString = 2,
wkbPolygon = 3,
wkbMultiPoint = 4,
wkbMultiLineString = 5,
wkbMultiPolygon = 6
};
enum wkbByteOrder {
wkbXDR = 0, // Big Endian
wkbNDR = 1 // Little Endian
};
WKBPoint {
byte byteOrder;
uint32 wkbType; // 1=wkbPoint
Point point;
};
WKBLineString {
byte byteOrder;
uint32 wkbType; // 2=wkbLineString
uint32 numPoints;
Point points[numPoints];
};

WKBPolygon {
byte byteOrder;
uint32 wkbType; // 3=wkbPolygon
uint32 numRings;
LinearRing rings[numRings];
};
WKBMultiPoint {
byte byteOrder;
uint32 wkbType; // 4=wkbMultipoint
uint32 num_wkbPoints;
WKBPoint WKBPoints[num_wkbPoints];
};
WKBMultiLineString {
byte byteOrder;
uint32 wkbType; // 5=wkbMultiLineString
uint32 num_wkbLineStrings;
WKBLineString WKBLineStrings[num_wkbLineStrings];
};

wkbMultiPolygon {
byte byteOrder;
uint32 wkbType; // 6=wkbMultiPolygon
uint32 num_wkbPolygons;
WKBPolygon wkbPolygons[num_wkbPolygons];
};

WKBGeometry {
union {
WKBPoint point;
WKBLineString linestring;
WKBPolygon polygon;
WKBMultiPoint mpoint;
WKBMultiLineString mlinestring;
WKBMultiPolygon mpolygon;
}
};

The following figure shows an example of a geometry in well-known binary representation using NDR coding.

Figure 58. Geometry representation in NDR format. (B=1) of type polygon (T=3) with 2 linears (NR=2), where each ring has 3 points (NP=3).

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值