接着上篇文章继续
2)Point (点)
一个 Point 由一对双精度坐标组成,存储顺序为 X,Y。
文章来源:https://www.toymoban.com/news/detail-444852.html
/**
* PointGeometry记录读取
* */
static Geometry renderPointGeometry(byte[] recordContent,GeometryFactory geometryFactory) {
int shapetype2 = ByteBuffer.wrap(recordContent, 0, 4).order(ByteOrder.LITTLE_ENDIAN).getInt();
double x = ByteBuffer.wrap(recordContent, 4, 8).order(ByteOrder.LITTLE_ENDIAN).getDouble();
double y = ByteBuffer.wrap(recordContent, 12, 8).order(ByteOrder.LITTLE_ENDIAN).getDouble();
Coordinate[] Points = new Coordinate[0];
Points[0]=new Coordinate(x,y);
CoordinateSequence coordinates=new CoordinateArraySequence(Points);
return new Point(coordinates,geometryFactory);
}
3)MultiPoint (多点)
一个 MultiPoint 描述一组点, 具体如下:
文章来源地址https://www.toymoban.com/news/detail-444852.html
/**
* MutilPointGeometry记录读取
* */
static Geometry renderMutilPointGeometry(byte[] recordContent,GeometryFactory geometryFactory) {
int shapetype2 = ByteBuffer.wrap(recordContent, 0, 4).order(ByteOrder.LITTLE_ENDIAN).getInt();
//记录四至范围
double[] boundingBox = new double[4];
for (int i = 0; i < boundingBox.length; i++) {
boundingBox[i] = ByteBuffer.wrap(recordContent, 4 + i * 8, 8).order(ByteOrder.LITTLE_ENDIAN).getDouble();
}
int pointNum = ByteBuffer.wrap(recordContent, 36, 4).order(ByteOrder.LITTLE_ENDIAN).getInt();
byte[] pointByteContent=new byte[recordContent.length-40];
System.arraycopy(recordContent, 40, pointByteContent,0, (recordContent.length-40));
Point[] Points = new Point[pointNum];
for (int j = 0; j < pointNum; j++) {
Coordinate coordinate=new Coordinate();
if(j<pointNum-1) {
coordinate
到了这里,关于Android不基于第三发依赖包解析shp文件(2)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!