日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

geometry-api-java 学习笔记(三)多点 multipoint

發(fā)布時間:2024/1/23 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 geometry-api-java 学习笔记(三)多点 multipoint 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

multipoint 是一組有序點的集合。一個有效的multipoint,集合中的每一個點是不同的。

如果距離x坐標(biāo)和y坐標(biāo)之間的距離小于0.001米,multipoint不是一個有效的multipoint。

JSON 格式化

一個multipoint被表示成一個json字符串,格式化成一個points點的集合和一個空間坐標(biāo)系,還具有布爾類型的hasM和hasZ字段,它倆默認(rèn)值為false。

points數(shù)組的每個成員可能是一個具有2、3或者4個成員的數(shù)組,其中如果有2個元素表示2Dpoints,3個元素表示3Dpoints。


一個空multipoint表示成一個points的空數(shù)組。

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": []}

創(chuàng)建一個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:

Create this multipoint

MultiPoint class methods

We create a new MultiPoint and add points by calling the add method.

static MultiPoint createMultipoint1() {MultiPoint mPoint = new MultiPoint();// Add pointsmPoint.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 the execute 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 the executemethod 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 the executemethod 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; }

總結(jié)

以上是生活随笔為你收集整理的geometry-api-java 学习笔记(三)多点 multipoint的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。