Point(单点) 的初始定义:
1.直接定义
public Point createPoint() {
Point pt = new Point(0.05, 0.05);
return pt;
}
2.读取JSON数据
关键函数:OperatorImportFromJson.local().executeexecute(Geometry.Type type, String string); Type :Geometry.Type寻找,这里是Point string :JSON字符串
public 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.读取GeoJSON数据
OperatorImportFromGeoJson.local().execute(int importFlags, Geometry.Type type, String geoJsonString, ProgressTracker progressTracker); importFlags :坐标系 type :Geometry.Type寻找,这里是Point geoJsonString :GeoJSON字符串 progressTracker :null
public 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.读取WKT数据
OperatorImportFromWkt.local().execute(int import_flags, Geometry.Type type,String wkt_string, ProgressTracker progress_tracker); import_flags :同上 Type :同上 wkt_string :WKT字符串 progressTracker :null
public Point createPointFromWKT() throws IOException {
String wktString = "Point (-106.4453583 39.11775)";
Geometry geom