地理数据处理与空间分析
1. 地理数据格式处理
1.1 WKB 数据处理
WKB(Well - Known Binary)是一种用于表示几何对象的二进制格式。以下是处理 WKB 数据并转换为 JGeometry 对象的示例代码:
// Create a WKB processor
WKB wkb = new WKB();
// Read the size of the byte array
int n = ds.readInt();
// Read the SRID of the geometry
int srid = ds.readInt();
// Read the byte array that contains the WKB
byte[] b = new byte[n];
int l = ds.read (b, 0, n);
// Convert to JGeometry
geom = wkb.toJGeometry(b);
// Add the SRID
geom.setSRID(srid);
这里不需要指定二进制编码的风格(大端或小端),因为 toJGeometry() 方法会自动识别编码并透明处理。
1.2 GML 数据处理
WKT 和 WKB 有很多局限性,它们只支持简单的 2D 形状,不支持 3D 形状、圆弧或圆,也无法指定几何图形的投影。而地理标记语言(GML)是一种用于地理信息的 XML 编码,能提供更强大的功能。
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



