geometry-api-java 学习笔记(二)点 Point
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                geometry-api-java 学习笔记(二)点 Point
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.                        
                                一個(gè)點(diǎn)代表了一個(gè)位置在空間和其他所有幾何類型的構(gòu)建塊。至少一個(gè)點(diǎn)包含一個(gè)x坐標(biāo)和y坐標(biāo)。一個(gè)點(diǎn)的坐標(biāo)可以用英尺和米等單位,也可以用角度或弧度等單位。具體與相關(guān)的空間所指定坐標(biāo)的單位一致即可,對(duì)于地理坐標(biāo)系統(tǒng),x坐標(biāo)是經(jīng)度用y坐標(biāo)是緯度。
JSON format
一個(gè)點(diǎn)可以代表一個(gè)json字符串,一個(gè)點(diǎn)的json字符串格式包含x、y和? 可選的空間參考系,一個(gè)點(diǎn)也可能有m和z字段。
一個(gè)點(diǎn)表示空值,可以用null或者Nan,一個(gè)空的點(diǎn)在空間中是沒(méi)有位置的。
 
Syntax語(yǔ)法
 
 
 { "x": <x>, "y": <y>, "z": <z>, "m": <m>, "spatialReference" : {"wkid" : <wkid>} } 
 
2D point? 2D點(diǎn)語(yǔ)法
 
 
 { "x": 32462, "y": -57839, "spatialReference" : {"wkid" : 54004} } 
 
3D point with Ms???? 3D點(diǎn)語(yǔ)法
 
 
 { "x": 32462, "y": -57839, "z": 20, "m": 1, "spatialReference" : {"wkid" : 54004} } 
 
Empty point???? 空點(diǎn)語(yǔ)法
 
 
 { "x": null } { "x": "NaN" } 
 
用java創(chuàng)建點(diǎn)主要有一下4種方式:
 
1.Point 類的方法
 
 
 
直接用構(gòu)造函數(shù)創(chuàng)建
 
2. 通過(guò)引入json字符串
 
 
 static Point createPointFromJson() throws JsonParseException, IOException {String jsonString = "{\"x\":-106.4453583,\"y\":39.11775,\"spatialReference\":{\"wkid\":4326}}";MapGeometry mapGeom = OperatorImportFromJson.local().execute(Geometry.Type.Point, jsonString);return (Point)mapGeom.getGeometry();
}
 
 
3.通過(guò)GeoJSON
static Point createPointFromGeoJson() throws JsonParseException, IOException {String geoJsonString = "{\"type\":\"Point\",\"coordinates\":[-106.4453583,39.11775],\"crs\":\"EPSG:4326\"}";MapGeometry mapGeom = OperatorImportFromGeoJson.local().execute(GeoJsonImportFlags.geoJsonImportDefaults, Geometry.Type.Point, geoJsonString, null);return (Point)mapGeom.getGeometry(); }4. 通過(guò)WKT
We first create the WKT string which represents the point. We then call the executemethod of OperatorImportFromWkt.
static Point createPointFromWKT() throws JsonParseException, IOException {String wktString = "Point (-106.4453583 39.11775)";Geometry geom = OperatorImportFromWkt.local().execute(WktImportFlags.wktImportDefaults, Geometry.Type.Point, wktString, null);return (Point)geom;}總結(jié)
以上是生活随笔為你收集整理的geometry-api-java 学习笔记(二)点 Point的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
 
                            
                        - 上一篇: geometry-api-java 学
- 下一篇: Scala入门到精通——第二十节 类型参
