geometry-api-java 学习笔记(三)多点 multipoint
2017-07-05 11:40
736 查看
multipoint 是一组有序点的集合。一个有效的multipoint,集合中的每一个点是不同的。
如果距离x坐标和y坐标之间的距离小于0.001米,multipoint不是一个有效的multipoint。
points数组的每个成员可能是一个具有2、3或者4个成员的数组,其中如果有2个元素表示2Dpoints,3个元素表示3Dpoints。
一个空multipoint表示成一个points的空数组。
Syntax语法
Each of the code samples below creates a multipoint with six points.
The multipoint looks like this:
Create this multipoint
We create a new
如果距离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 theMultiPointclass methods or one of the import operators.
Each of the code samples below creates a multipoint with six points.
The multipoint looks like this:
Create this multipoint
MultiPoint
class methods
We create a new MultiPointand add points by calling the
addmethod.
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 theexecutemethod 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 theexecutemethod 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 theexecutemethod 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 学习笔记(七)拓扑运算之cut
- geometry-api-java 学习笔记(二)点 Point
- geometry-api-java 学习笔记(六)多边形 Envelope
- geometry-api-java 学习笔记(一)概述
- geometry-api-java 学习笔记(五)多边形 Polygons
- geometry-api-java 学习笔记(八)分割Intersection
- geometry-api-java 学习笔记(四)多线段 polyline
- Java Sound API 学习笔记[转载]
- ant学习笔记(四)ant整合javadoc直接生成java文档api并将其打包之后上传到FTP服务器上面
- Android(java)学习笔记143:android提供打开各种文件的API接口:setDataAndType
- Core Java 学习笔记——1.术语/环境配置/Eclipse汉化字体快捷键/API文档
- Java学习笔记之常用API学习笔记2
- 黑马程序员_学习笔记:12) 其他API:java.lang.Runtime、java.util.Math、java.util.Date、java.util. Calendar
- Java基础班学习笔记(11)API常用类(三)
- Java学习笔记之常用API学习笔记3
- java学习笔记——API中的常用类和StringBuffer
- JavaWeb--学习笔记(一)--API
- Java-API学习笔记---Object
- JAVA学习笔记(十八)- API常用类
- Java-API学习笔记---Integer