GeoTools应用-JTS(Geometry之间的关系)
2012-04-05 20:48
375 查看
GeoTools应用-JTS(Geometry之间的关系)
转载自:/article/2107437.html
几何信息和拓扑关系是地理信息系统中描述地理要素的空间位置和空间关系的不可缺少的基本信息。其中几何信息主要涉及几何目标的坐标位置、方向、角度、距离和面积等信息,它通常用解析几何的方法来分析。而空间关系信息主要涉及几何关系的“相连”、“相邻”、“包含”等信息,它通常用拓扑关系或拓扑结构的方法来分析。拓扑关系是明确定的
下面的例子介绍了 equals、disjoint、intersects 的用法
代码段:
Geometry 叠加操作
在GIS中,缓冲(buffering)是一种用于计算包含在一个几何图形(Geometry)特定距离区域内所有点的的操作。在数学术语中,这被称为通过一个与缓冲区相等的圆的半径去计算几何图形的闵可夫斯基(Minkowski)总和。发现正的(positive)和负的(negative)缓冲,有时与操作的腐蚀(erosion)和膨胀(dilation)有关。在CAD/CAM,缓冲曲线被称为偏移曲线(offset
curves)。你可以使用JTS,通过Geometry buffer方法或者Bufferop类,去计算一个图形的缓冲区。缓冲操作所输入的Geometry可以是任何类别(包括任意的Geometry集合)。缓冲操作的结果通常是一种区域类型(area type)(多边形或者多多边形)。结果也可能为空[例如,一条线(linestring)的负缓冲。]
转载自:/article/2107437.html
几何信息和拓扑关系是地理信息系统中描述地理要素的空间位置和空间关系的不可缺少的基本信息。其中几何信息主要涉及几何目标的坐标位置、方向、角度、距离和面积等信息,它通常用解析几何的方法来分析。而空间关系信息主要涉及几何关系的“相连”、“相邻”、“包含”等信息,它通常用拓扑关系或拓扑结构的方法来分析。拓扑关系是明确定的
相等(Equals): | 几何形状拓扑上相等。 |
脱节(Disjoint): | 几何形状没有共有的点。 |
相交(Intersects): | 几何形状至少有一个共有点(区别于脱节) |
接触(Touches): | 几何形状有至少一个公共的边界点,但是没有内部点。 |
交叉(Crosses): | 几何形状共享一些但不是所有的内部点。 |
内含(Within): | 几何形状A的线都在几何形状B内部。 |
包含(Contains): | 几何形状B的线都在几何形状A内部(区别于内含) |
重叠(Overlaps): | 几何形状共享一部分但不是所有的公共点,而且相交处有他们自己相同的区域。 |
代码段:
package 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.GeometryFactory; import com.vividsolutions.jts.geom.LineString; import com.vividsolutions.jts.geom.Point; import com.vividsolutions.jts.io.ParseException; import com.vividsolutions.jts.io.WKTReader; /** * Class GeometryRelated.java * Description 二元比较集合。二元比较以两个几何对象作为参数,返回一个Boolean类型的值, * 来指明这两个几何对象是否具有指定的空间关系。支持的空间关系包括: * equals、disjoint、intersects, touches, crosses, within, contains, overlaps * Company mapbar * author Chenll E-mail: Chenll@mapbar.com * Version 1.0 * Date 2012-2-17 下午06:17:01 */ public class GeometryRelated { private GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory( null ); public Point createPoint(String lon,String lat){ Coordinate coord = new Coordinate(Double.parseDouble(lon), Double.parseDouble(lat)); Point point = geometryFactory.createPoint( coord ); return point; } /** * will return true as the two line strings define exactly the same shape. * 两个几何对象是否是重叠的 * @return * @throws ParseException */ public boolean equalsGeo() throws ParseException{ WKTReader reader = new WKTReader( geometryFactory ); LineString geometry1 = (LineString) reader.read("LINESTRING(0 0, 2 0, 5 0)"); LineString geometry2 = (LineString) reader.read("LINESTRING(5 0, 0 0)"); // return geometry1 ==geometry2; false //check if two geometries are exactly equal; right down to the coordinate level. // return geometry1.equalsExact(geometry2); false return geometry1.equals(geometry2);//true } /** * The geometries have no points in common * 几何对象没有交点(相邻) * @return * @throws ParseException */ public boolean disjointGeo() throws ParseException{ WKTReader reader = new WKTReader( geometryFactory ); LineString geometry1 = (LineString) reader.read("LINESTRING(0 0, 2 0, 5 0)"); LineString geometry2 = (LineString) reader.read("LINESTRING(0 1, 0 2)"); return geometry1.disjoint(geometry2); } /** * The geometries have at least one point in common. * 至少一个公共点(相交) * @return * @throws ParseException */ public boolean intersectsGeo() throws ParseException{ WKTReader reader = new WKTReader( geometryFactory ); LineString geometry1 = (LineString) reader.read("LINESTRING(0 0, 2 0, 5 0)"); LineString geometry2 = (LineString) reader.read("LINESTRING(0 0, 0 2)"); Geometry interPoint = geometry1.intersection(geometry2);//相交点 System.out.println(interPoint.toText());//输出 POINT (0 0) return geometry1.intersects(geometry2); } /** * @param args * @throws ParseException */ public static void main(String[] args) throws ParseException { GeometryRelated gr = new GeometryRelated(); System.out.println(gr.equalsGeo()); System.out.println(gr.disjointGeo()); System.out.println(gr.intersectsGeo()); } }
Geometry 叠加操作
缓冲区分析(Buffer) | 包含所有的点在一个指定距离内的多边形和多多边形 |
凸壳分析(ConvexHull) | 包含几何形体的所有点的最小凸壳多边形(外包多边形) |
交叉分析(Intersection) | 交叉操作就是多边形AB中所有共同点的集合。 |
联合分析(Union) | AB的联合操作就是AB所有点的集合。 |
差异分析(Difference) | AB形状的差异分析就是A里有B里没有的所有点的集合。 |
对称差异分析(SymDifference) | AB形状的对称差异分析就是位于A中或者B中但不同时在AB中的所有点的集合 |
curves)。你可以使用JTS,通过Geometry buffer方法或者Bufferop类,去计算一个图形的缓冲区。缓冲操作所输入的Geometry可以是任何类别(包括任意的Geometry集合)。缓冲操作的结果通常是一种区域类型(area type)(多边形或者多多边形)。结果也可能为空[例如,一条线(linestring)的负缓冲。]
相关文章推荐
- GeoTools应用-JTS(Geometry之间的关系)
- GeoTools应用-JTS(Geometry之间的关系)
- GeoTools应用-JTS(Geometry)
- GeoTools应用-(JTS Geometry Operations)(二)
- JTS Geometry之间的关系
- GeoTools是什么,以及与JTS和GeoAPI之间的关系如何?
- GeoTools应用-(JTS Geometry Operations)
- GeoTools应用-(JTS Geometry Operations)(一)
- 架构语言ArchiMate - 业务层、应用层和技术层之间的关系
- 本文是笔者根据数据库编程经验,利用C++语言的模板、继承、授权、多态等面向对象特性,借鉴命令模式,实现了对象在关系数据中的存储,降低应用系统与数据库之间的耦合,提高开发效率。
- HTML页和ashx之间关系的一点小应用
- LINUX目录和文件各自的权限说明,以及目录和文件权限之间的关系(应用:配置linux下上传图片的存储目录)
- Handler,Message和Looper之间关系和应用
- 打开天窗:应用大脑科学提升两性之间的职场关系
- 架构语言ArchiMate - 业务层、应用层和技术层之间的关系
- Spring4的知识应用总结(三)——Bean之间的关系和作用域
- 打开天窗:应用大脑科学提升两性之间的职场关系
- HTML页和ashx之间关系的一点小应用
- R在线性回归中的应用--分析豆瓣评分与票房之间关系的案例研究
- geotools中的空间关系(Geometry Relationships)和空间操作(Geometry Operations)