




已阅读5页,还剩1页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
JTS(Geometry)空间数据模型(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 interfacesJTS Wrapper Plugin an implementation that delegates all the work to JTSJTS包结构系(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对象。支持接口java view plain copypackage com.mapbar.geo.jts; import org.geotools.geometry.jts.JTSFactoryFinder; import com.vividsolutions.jts.geom.Coordinate; import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.GeometryCollection; import com.vividsolutions.jts.geom.GeometryFactory; import com.vividsolutions.jts.geom.LineString; import com.vividsolutions.jts.geom.LinearRing; import com.vividsolutions.jts.geom.Point; import com.vividsolutions.jts.geom.Polygon; import com.vividsolutions.jts.geom.MultiPolygon; import com.vividsolutions.jts.geom.MultiLineString; import com.vividsolutions.jts.geom.MultiPoint; import com.vividsolutions.jts.io.ParseException; import com.vividsolutions.jts.io.WKTReader; /* * Class GeometryDemo.java * Description Geometry 几何实体的创建,读取操作 * Company mapbar * author Chenll E-mail: C * Version 1.0 * Date 2012-2-17 上午11:08:50 */ public class GeometryDemo private GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory( null ); /* * create a point * return */ public Point createPoint() Coordinate coord = new Coordinate(109.013388, 32.715519); Point point = geometryFactory.createPoint( coord ); return point; /* * create a point by WKT * return * throws ParseException */ public Point createPointByWKT() throws ParseException WKTReader reader = new WKTReader( geometryFactory ); Point point = (Point) reader.read(POINT (109.013388 32.715519); return point; /* * create multiPoint by wkt * return */ public MultiPoint createMulPointByWKT()throws ParseException WKTReader reader = new WKTReader( geometryFactory ); MultiPointmpoint=(MultiPoint)reader.read (MULTIPOINT(109.013388 32.715519,119.32488 31.435678); return mpoint; /* * * create a line * return */ public LineString createLine() Coordinate coords = new Coordinate new Coordinate(2, 2), new Coordinate(2, 2); LineString line = geometryFactory.createLineString(coords); return line; /* * create a line by WKT * return * throws ParseException */ public LineString createLineByWKT() throws ParseException WKTReader reader = new WKTReader( geometryFactory ); LineString line = (LineString) reader.read(LINESTRING(0 0, 2 0); return line; /* * create multiLine * return */ public MultiLineString createMLine() Coordinate coords1 = new Coordinate new Coordinate(2, 2), new Coordinate(2, 2); LineString line1 = geometryFactory.createLineString(coords1); Coordinate coords2 = new Coordinate new Coordinate(2, 2), new Coordinate(2, 2); LineString line2 = geometryFactory.createLineString(coords2); LineString lineStrings = new LineString2; lineStrings0= line1; lineStrings1 = line2; MultiLineString ms = geometryFactory.createMultiLineString(lineStrings); return ms; /* * create multiLine by WKT * return * throws ParseException */ public MultiLineString createMLineByWKT()throws ParseException WKTReader reader = new WKTReader( geometryFactory ); MultiLineString line = (MultiLineString) reader.read(MULTILINESTRING(0 0, 2 0),(1 1,2 2); return line; /* * create a polygon(多边形) by WKT * return * throws ParseException */ public Polygon createPolygonByWKT() throws ParseException WKTReader reader = new WKTReader( geometryFactory ); Polygon polygon = (Polygon) reader.read(POLYGON(20 10, 30 0, 40 10, 30 20, 20 10); return polygon; /* * create multi polygon by wkt * return * throws ParseException */ public MultiPolygon createMulPolygonByWKT() throws ParseException WKTReader reader = new WKTReader( geometryFactory ); MultiPolygon mpolygon = (MultiPolygon) reader.read(MULTIPOLYGON(40 10, 30 0, 40 10, 30 20, 40 10),(30 10, 30 0, 40 10, 30 20, 30 10); return mpolygon; /* * create GeometryCollection contain point or multiPoint or line or multiLine or polygon or multiPolygon * return * throws ParseException */ public GeometryCollection createGeoCollect() throws ParseException LineString line = createLine(); Polygon poly = createPolygonByWKT(); Geometry g1 = geometryFactory.createGeometry(line); Geometry g2 = geometryFactory.createGeometry(poly); Geometry garray = new Geometryg1,g2; GeometryCollection gc = geometryFactory.createGeometryCollection(garray); return gc; /* * create a Circle 创建一个圆,圆心(x,y) 半径RADIUS * param x * param y * param RADIUS * return */ public Polygon createCircle(double x, double y, final double RADIUS) final int SIDES = 32;/圆上面的点个数 Coordinate coords = new CoordinateSIDES+1; for( int i = 0; i SIDES; i+) double angle = (double) i / (double) SIDES) * Math.PI * 2.0; double dx = Math.cos( angle ) * RADIUS; double dy = Math.sin( angle ) * RADIUS; coordsi = new Coordinate( (double) x + dx, (double) y + dy ); coordsSIDES = coords0; LinearRing ring = geometryFactory.createLinearRing( coords ); Polygon polygon = geometryFactory.createPolygon( ring, null ); return polygon; /* * pa
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 武汉体育学院体育科技学院《食用真菌学》2023-2024学年第二学期期末试卷
- 山西省朔州市怀仁市重点中学2025届高三下学期联合物理试题含解析
- 认识新规范 争做文明人
- 2025商业店铺租赁保证金合同样本
- 2025农产品买卖合同
- 2025标的物买卖合同标准格式
- 2025国际租赁合同 标准版 模板
- 规划7路技术标
- 2025农副产品采购招标合同范本
- 2025年普法知识竞赛题库及答案(共70题)
- 智商情商哪个更重要 辩论赛
- 高中课本剧-鸿门宴剧本
- 考研英语大纲词汇(完美打印版)
- 深圳南山区建设工程施工围挡改造提升
- YS/T 1161.3-2016拟薄水铝石分析方法第3部分:孔容和比表面积的测定氮吸附法
- GB/T 3906-20203.6 kV~40.5 kV交流金属封闭开关设备和控制设备
- GB/T 2930.11-2001牧草种子检验规程检验报告
- GB/T 13465.7-2009不透性石墨增重率和填孔率试验方法
- GB/T 12939-2015工业车辆轮辋规格系列
- 跨越学习高原期-高中心理健康主题班会
- 土地污染及其防治课件
评论
0/150
提交评论