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 = OperatorImportFromWkt.local().execute(WktImportFlags.wktImportDefaults, Geometry.Type.Point, wktString, null);return (Point)geom;}
PointLearn PointLearn = new PointLearn();
Point p1 = PointLearn.createPoint();
Point p2 = PointLearn.createPointFromWKT();
Point p3 = PointLearn.createPointFromJson();
Point p4 = PointLearn.createPointFromGeoJson();

MultiPoint(多点) 的初始定义:

存储样式

{"hasZ" : true | false,"hasM" : true | false,"points": [[<x1>,<y1>,<z1>,<m1>], ... ,[<xn>,<yn>,<zn>,<mn>]],"spatialReference" : {"wkid" : <wkid>}
}

1.MultiPoint类

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;
}

2.from JSON

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();
}

3.from GeoJSON

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();
}

4.from WKT

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;
}

Polyline 的初始定义

1.Polyline类

static Polyline createPolyline1() {Polyline line = new Polyline();// Path 1line.startPath(6.9, 9.1);line.lineTo(7, 8.8);// Path 2line.startPath(6.8, 8.8);line.lineTo(7, 9);line.lineTo(7.2, 8.9);line.lineTo(7.4, 9);// Path 3line.startPath(7.4, 8.9);line.lineTo(7.25, 8.6);line.lineTo(7.15, 8.8);return line;}

2.from JSON

static Polyline createPolygonFromJson() throws JsonParseException, IOException {String jsonString = "{\"paths\":[[[6.8,8.8],[7,9],[7.2,8.9],[7.4,9]],"+ "[[7.4,8.9],[7.25,8.6],[7.15,8.8]],[[6.9, 9.1],[7, 8.8]]],"+ "\"spatialReference\":{\"wkid\":4326}}";MapGeometry mapGeom = OperatorImportFromJson.local().execute(Geometry.Type.Polyline, jsonString);return (Polyline)mapGeom.getGeometry();}

3.from GeoJSON

static Polyline createPolylineFromGeoJson() throws JsonParseException, IOException {String geoJsonString = "{\"type\":\"MultiLineString\","+ "\"coordinates\":[[[6.8,8.8],[7,9],[7.2,8.9],[7.4,9]],"+ "[[7.4,8.9],[7.25,8.6],[7.15,8.8]],[[6.9, 9.1],[7, 8.8]]],"+ "\"crs\":\"EPSG:4326\"}";MapGeometry mapGeom = OperatorImportFromGeoJson.local().execute(GeoJsonImportFlags.geoJsonImportDefaults, Geometry.Type.Polyline, geoJsonString, null);return (Polyline)mapGeom.getGeometry();}

4.from WKT

static Polyline createPolylineFromWKT() throws JsonParseException, IOException {String wktString = "MULTILINESTRING ((6.9 9.1,7 8.8),(6.8 8.8,7 9,7.2 8.9,7.4 9),(7.4 8.9,7.25 8.6,7.15 8.8))";Geometry geom = OperatorImportFromWkt.local().execute(WktImportFlags.wktImportDefaults, Geometry.Type.Polyline, wktString, null);return (Polyline)geom;}
}

Polygon的初始定义

1.Polygon类

public static Polygon createPolygon1()
{Polygon poly = new Polygon();// clockwise => outer ringpoly.startPath(0, 0);poly.lineTo(-0.5, 0.5);poly.lineTo(0.5, 1);poly.lineTo(1, 0.5);poly.lineTo(0.5, 0);// holepoly.startPath(0.5, 0.2);poly.lineTo(0.6, 0.5);poly.lineTo(0.2, 0.9);poly.lineTo(-0.2, 0.5);poly.lineTo(0.1, 0.2);poly.lineTo(0.2, 0.3);// islandpoly.startPath(0.1, 0.7);poly.lineTo(0.3, 0.7);poly.lineTo(0.3, 0.4);poly.lineTo(0.1, 0.4);return poly;
}

2.from JSON

static Polygon createPolygonFromJson() throws JsonParseException, IOException
{String jsonString = "{\"rings\":[[[0.5,0.2],[0.6,0.5],[0.2,0.9],[-0.2,0.5],[0.1,0.2],[0.2,0.3],[0.5,0.2]],"+ "[[0.0,0.0],[-0.5,0.5],[0.0,1.0],[0.5,1.0],[1.0,0.5],[0.5,0.0],[0.0,0.0]],"+ "[[0.1,0.7],[0.3,0.7],[0.3,0.4],[0.1,0.4],[0.1,0.7]]],"+ " \"spatialReference\":{\"wkid\":4326}}";MapGeometry mapGeom = OperatorImportFromJson.local().execute(Geometry.Type.Polygon, jsonString);return (Polygon)mapGeom.getGeometry();
}

3.from GeoJSON

static Polygon createPolygonFromGeoJson() throws JsonParseException, IOException
{String geoJsonString = "{\"type\":\"MultiPolygon\","+ "\"coordinates\":[[[[0.0,0.0],[-0.5,0.5],[0.0,1.0],[0.5,1.0],[1.0,0.5],[0.5,0.0],[0.0,0.0]],"+ "[[0.5,0.2],[0.6,0.5],[0.2,0.9],[-0.2,0.5],[0.1,0.2],[0.2,0.3],[0.5,0.2]]],"+ "[[[0.1,0.7],[0.3,0.7],[0.3,0.4],[0.1,0.4],[0.1,0.7]]]],"+ "\"crs\":\"EPSG:4326\"}";MapGeometry mapGeom = OperatorImportFromGeoJson.local().execute(GeoJsonImportFlags.geoJsonImportDefaults, Geometry.Type.Polygon, geoJsonString, null);return (Polygon)mapGeom.getGeometry();
}

4.from WKT

static Polygon createPolygonFromWKT() throws JsonParseException, IOException
{String wktString = "MULTIPOLYGON (((0.1 0.7, 0.1 0.4, 0.3 0.4, 0.3 0.7, 0.1 0.7)),"+ "((0 0, 0.5 0, 1 0.5, 0.5 1, 0 1, -0.5 0.5, 0 0),"+ "(0.5 0.2, 0.2 0.3, 0.1 0.2, -0.2 0.5, 0.2 0.9, 0.6 0.5, 0.5 0.2)))";Geometry geom = OperatorImportFromWkt.local().execute(WktImportFlags.wktImportDefaults, Geometry.Type.Polygon, wktString, null);return (Polygon)geom;

Geometry点线面的初始化相关推荐

  1. python的tkinter窗口位置\坐标\大小等知识(自用笔记)

    大家都知道tkinter库中有很多控件和主窗口,因此这些控件和主窗口都有对应的屏幕坐标的信息.因此我们可以分别进行介绍. 他是以电脑屏幕的左上角为原点,向右是x,向下是y的这样的一个坐标系 一.关于主 ...

  2. Three.js入门指南

    1.threejs导入3d模型到web端,3d模型的文件格式可以找个建模软件转化为threejs所支持的格式,如.dae .obj .mtl stl gld等 harp.gl 3D地图渲染引擎 key ...

  3. 【计算机图形学】结课大作业——光照模型(3D场景)

    效果 >_< 技术栈 [前端]HTML / CSS / JavaScript [图形学]WebGL / Three.js 思路 three.js开发一般是比较套路的--init() + a ...

  4. Threejs实现穿越云层动效

    上文说到,我对<你的性格主导色>活动中最感兴趣的部分就是通过 Three.js 实现穿越云层动效了,据作者说每朵云出现的位置都是随机的,效果很好,下图是我实现的版本. 在线 Demo 首先 ...

  5. 【GeoTools】geotools-20 读取、写入shape文件

    shape文件至少包含shp.dbf.shx文件,否则会报错.shp文件存储地理空间信息:dbf文件存储属性信息:shx文件存储索引信息. 注意:关于import org.locationtech.j ...

  6. ArcGIS API for JavaScript web前端应用

    ArcGIS API for JavaScript 文档查看地址: https://developers.arcgis.com/javascript/latest/ 现在分未3.x和4.x两种版本,对 ...

  7. BingMap(必应地图)学习一

    密钥申请 http://www.bingmap.cn/guide/db765008-dafe-11e8-a995-d46d6d978bfa?module=doc 申请完毕,查看密钥 案例/API ht ...

  8. Vue+Openlayer中测距测面和绘制点线面组件-LjMeasureDraw4326和LjMeasureDraw3857

    地理坐标系4326 效果图: 首先下载turf.js: cnpm i -S @turf/turf 全局引入turf.js //引入turf.js import * as turf from '@tur ...

  9. GIS开源库GEOS库学习教程(二):geos中的几何图形(Geometry)

    前言   上一节我们学过了GEOS库的介绍和环境编译及示例代码,在这一节我们将了解一下geos中的各种几何图形类,它们大部分都是从Geometry类派生的.而几何图形(Geometry)是geos里面 ...

最新文章

  1. iOS中 加强日志输出 开发技术总结
  2. 温州大学《机器学习》课程课件(一)
  3. wxWidgets:wxThread类用法
  4. C语言面试题分享(6)
  5. Redis:02---安装Redis(Linux+Windows+Docker)
  6. 汤姆大叔 深入理解JavaScript系列(20):《你真懂JavaScript吗?》答案详解 后六道题答案...
  7. 用于最优控制的简单软件
  8. Objective--C的Foundation frame之NSMutableDictionary代码
  9. 修改笔记-批量去除附件售价
  10. 读取.properties配置文件(转载)
  11. Linux 无线网卡驱动安装 Dell Inspiron R14-N4010 笔记本
  12. silk lobe资源公众号_【好设计资源库】公众号素材获取方式说明
  13. SSL证书申请流程,中文域名如何申请证书?
  14. win10电脑wifi服务器未响应,win10系统点电脑无线图标没反应的解决方法
  15. 干货来袭!!!3天0基础Python实战项目快速学会人工智能必学数学基础全套(含源码)(第1天)线性代数篇:矩阵、向量及python实战
  16. 输出二叉树中从每个叶子结点到根结点的路径
  17. 格理论与密码学(二)
  18. Webshell文件上传漏洞
  19. 算法基础(二):master公式
  20. 计算机硬件工程师需要学哪些,嵌入式硬件工程师要求是什么?需要掌握哪些内容...

热门文章

  1. 如何自动识别文字并提取?这三个方法教你搞定识别文字
  2. Linux 启动时间优化实战,2.41 秒启动应用!
  3. 单独聊一聊CTWing软硬交互
  4. 叭叭一下Servlet的虚拟路径的映射
  5. 丰富的层次感,打造190㎡现代简约居住空间
  6. 你阳了吗?可以接种最新加强针疫苗了!
  7. 微信商家收款码和个人收款码区别,你知道吗?
  8. 贴片电解电容正负极区分
  9. 什么叫首充?关于流量卡首充的说明!
  10. Box3 代码教程 (一)