jar 坐标系转换工具_JTS(Geometry)(转)

本文详细介绍了JTS Geometry模型,包括空间数据类型、接口和关键类,如Point、LineString、Polygon等。此外,还展示了如何使用GeometryFactory创建和读取WKT表示的几何对象,如点、线、多边形。文章还提到了WKT(Well-known text)的概念,它是表示矢量几何对象、空间参照系统转换的文本格式。
摘要由CSDN通过智能技术生成

空间数据模型

(1)、JTS Geometry model

(2)、ISO Geometry model (Geometry Plugin and JTS Wrapper Plugin)

GeoTools has two implementations of these interfaces:

Geometry Plugin a port of JTS 1.7 to the ISO Geometry interfaces

JTS Wrapper Plugin an implementation that delegates all the work to JTS

JTS包结构

系(linearref包)、计算交点(noding包)、几何图形操作(operation包)、平面图(planargraph包)、多边形化(polygnize包)、精度(precision)、工具(util包)

重点理解JTS Geometry model

(1) JTS提供了如下的空间数据类型

Point

MultiPoint

LineString

LinearRing  封闭的线条

MultiLineString    多条线

Polygon

MultiPolygon

GeometryCollection  包括点,线,面

(2) 支持接口

Coordinate

Coordinate(坐标)是用来存储坐标的轻便的类。它不同于点,点是Geometry的子类。不像模范Point的对象(包含额外的信息,例如一个信包,一个精确度模型和空间参考系统信息),Coordinate只包含纵座标值和存取方法。

Envelope(矩形)

一个具体的类,包含一个最大和最小的x 值和y 值。

GeometryFactory

GeometryFactory提供一系列的有效方法用来构造来自Coordinate类的Geometry对象。支持接口

importorg.geotools.geometry.jts.JTSFactoryFinder;importcom.vividsolutions.jts.geom.Coordinate;importcom.vividsolutions.jts.geom.Envelope;importcom.vividsolutions.jts.geom.Geometry;importcom.vividsolutions.jts.geom.GeometryCollection;importcom.vividsolutions.jts.geom.GeometryFactory;importcom.vividsolutions.jts.geom.LineString;importcom.vividsolutions.jts.geom.LinearRing;importcom.vividsolutions.jts.geom.Point;importcom.vividsolutions.jts.geom.Polygon;importcom.vividsolutions.jts.geom.MultiPolygon;importcom.vividsolutions.jts.geom.MultiLineString;importcom.vividsolutions.jts.geom.MultiPoint;importcom.vividsolutions.jts.io.ParseException;importcom.vividsolutions.jts.io.WKTReader;/*** Class GeometryDemo.java

* Description Geometry 几何实体的创建,读取操作

* Company mapbar

* author Chenll E-mail: Chenll@mapbar.com

* Version 1.0

* Date 2012-2-17 上午11:08:50*/

public classGeometryDemo {private GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory( null);/*** create a point

*@return

*/

publicPoint createPoint(){

Coordinate coord= new Coordinate(109.013388, 32.715519);

Point point=geometryFactory.createPoint( coord );returnpoint;

}/*** create a rectangle(矩形)

*@return

*/

publicEnvelope createEnvelope(){

Envelope envelope= new Envelope(0,1,0,2);returnenvelope;

}/*** create a point by WKT

*@return*@throwsParseException*/

public Point createPointByWKT() throwsParseException{

WKTReader reader= newWKTReader( geometryFactory );

Point point= (Point) reader.read("POINT (109.013388 32.715519)");returnpoint;

}/*** create multiPoint by wkt

*@return

*/

public MultiPoint createMulPointByWKT()throwsParseEx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值