geometry-api-java 学习笔记(三)多点 multipoint
来源:互联网 发布:sql优化 面试题 编辑:程序博客网 时间:2024/06/06 16:25
multipoint 是一组有序点的集合。一个有效的multipoint,集合中的每一个点是不同的。
如果距离x坐标和y坐标之间的距离小于0.001米,multipoint不是一个有效的multipoint。
JSON 格式化
一个multipoint被表示成一个json字符串,格式化成一个points点的集合和一个空间坐标系,还具有布尔类型的hasM和hasZ字段,它俩默认值为false。
points数组的每个成员可能是一个具有2、3或者4个成员的数组,其中如果有2个元素表示2Dpoints,3个元素表示3Dpoints。
一个空multipoint表示成一个points的空数组。
Syntax语法
{ "hasZ" : true | false, "hasM" : true | false, "points": [[<x1>,<y1>,<z1>,<m1>], ... ,[<xn>,<yn>,<zn>,<mn>]], "spatialReference" : {"wkid" : <wkid>}}
2D multipoint
{ "points": [[32462,-57839],[43892,-49160],[35637,-65035],[46009,-60379]], "spatialReference" : {"wkid" : 54004}}
3D multipoint with Ms
Note that the third point does not have a z-value, and the fourth point does not have an m-value.
{ "hasZ" : true, "hasM" : true, "points": [[32462,-57839,20,1],[43892,-49160,25,2],[35637,-65035,null,3],[46009,-60379,22]], "spatialReference" : {"wkid" : 54004}}
Empty multipoint
{"points": []}
创建一个multipoint
To create a multipoint, we can use the MultiPoint
class methods or one of the import operators.
Each of the code samples below creates a multipoint with six points.
The multipoint looks like this:
MultiPoint
class methods
We create a new MultiPoint
and add points by calling the add
method.
static MultiPoint createMultipoint1() { MultiPoint mPoint = new MultiPoint(); // Add points mPoint.add(1, 1); mPoint.add(0.5, -0.5); mPoint.add(1, -1.5); mPoint.add(-1, -1); mPoint.add(-2, -0.5); mPoint.add(-1.5, 1.5); return mPoint;}
Import from JSON
We first create the JSON string which represents the multipoint. We then call theexecute
method of OperatorImportFromJson
.
static MultiPoint createMultipointFromJson() throws JsonParseException, IOException { String jsonString = "{\"points\":[[1,1],[0.5,-0.5],[1,-1.5],[-1,-1],[-2,-0.5],[-1.5,1.5]]," + "\"spatialReference\":{\"wkid\":4326}}"; MapGeometry mapGeom = OperatorImportFromJson.local().execute(Geometry.Type.MultiPoint, jsonString); return (MultiPoint)mapGeom.getGeometry();}
Import from GeoJSON
We first create the GeoJSON string which represents the multipoint. We then call theexecute
method of OperatorImportFromGeoJson
.
static MultiPoint createMultipointFromGeoJson() throws JsonParseException, IOException { String geoJsonString = "{\"type\":\"MultiPoint\"," + "\"coordinates\":[[1,1],[0.5,-0.5],[1,-1.5],[-1,-1],[-2,-0.5],[-1.5,1.5]]," + "\"crs\":\"EPSG:4326\"}"; MapGeometry mapGeom = OperatorImportFromGeoJson.local().execute(GeoJsonImportFlags.geoJsonImportDefaults, Geometry.Type.MultiPoint, geoJsonString, null); return (MultiPoint)mapGeom.getGeometry();}
Import from WKT
We first create the WKT string which represents the multipoint. We then call theexecute
method of OperatorImportFromWkt
.
static MultiPoint createMultipointFromWKT() throws JsonParseException, IOException { String wktString = "MULTIPOINT ((1 1),(0.5 -0.5),(1 -1.5),(-1 -1),(-2 -0.5),(-1.5 1.5))"; Geometry geom = OperatorImportFromWkt.local().execute(WktImportFlags.wktImportDefaults, Geometry.Type.MultiPoint, wktString, null); return (MultiPoint)geom;}
- geometry-api-java 学习笔记(三)多点 multipoint
- geometry-api-java 学习笔记(一)概述
- geometry-api-java 学习笔记(二)点 Point
- geometry-api-java 学习笔记(四)多线段 polyline
- geometry-api-java 学习笔记(五)多边形 Polygons
- geometry-api-java 学习笔记(六)多边形 Envelope
- geometry-api-java 学习笔记(八)分割Intersection
- geometry-api-java 学习笔记(七)拓扑运算之cut
- 百度地图API学习笔记(三)
- mysql取Geometry类型MULTIPOINT的中心和POINT类型
- java微信公众号开发学习笔记(三)——免费api调用
- JAVA API 学习笔记(迭代器)和集合的三种遍历方式以及优缺点分析
- Java学习笔记(三)
- java学习笔记(三)
- java学习笔记(三)
- Java学习笔记(三)
- Java学习笔记(三)
- java学习笔记(三)
- 基于BaseHTTPServer写的代理Post方法源码(只做参考,性能待优化)
- 第二章 js输出、语句、变量、注释
- 自定义Toast实现各种炫酷效果
- 在unity3d中接受MQTT消息协议数据C# .net,M2Mqtt
- iOS cell与cell.contentView的区别
- geometry-api-java 学习笔记(三)多点 multipoint
- qt线程
- lua判断点在任意多边形内部
- Android APK加固完善篇
- 用caffe自带工具绘制loss accuracy
- 关于BeagleBone Black Wireless 的 Wi-Fi 设置
- linux sed 命令
- 硬盘分区(主分区、扩展分区、逻辑分区)
- csv文件导出时分列问题