两个面之间的最短距离算法(记录)
2016-09-21 11:14
120 查看
使用了 geotools3.5.2.jar 包,创建两个几何图形,通过JAR方法,返回两个面之间的最短距离。
import com.vividsolutions.jts.geom.*; import com.vividsolutions.jts.io.ParseException; import com.vividsolutions.jts.io.WKTReader; import com.vividsolutions.jts.operation.distance.DistanceOp; import org.geotools.geometry.jts.JTSFactoryFinder; /** * Created by 18621 on 2016/8/31. */ public class GeoToolsTest { public static void main(String args []){ String wktPoly = "POLYGON ((121.58078350879 30.804800706056, 121.6261021123 30.460104661134, 122.14108624316 30.469717698243, 121.88290753222 30.833639817384,121.88290753222 30.833639817384,121.58078350879 30.804800706056))"; //请自行搜素了解wkt格式 String wktPoly1 = "POLYGON ((121.8719212041 31.117911057618, 121.94607891894 30.936636643556, 122.29764141894 30.840506272462,122.29489483691 31.237387375978 ,122.04632916308 31.106924729493,121.8719212041 31.117911057618))"; WKTReader reader = new WKTReader(); //GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory(null); try { Geometry poly = reader.read(wktPoly); Geometry poly1 = reader.read(wktPoly1); DistanceOp t = new DistanceOp(poly,poly1); Coordinate[] a = t.nearestPoints(); System.out.println(a[0]+":"+a[1]+"distance:"+poly.distance(poly1)); //geometryFactory.createPolygon(wktPoly); } catch (ParseException e) { e.printStackTrace(); } //geometry.intersects(geometry); //geometry.setUserData(""); } }
相关文章推荐
- java通过经纬度计算两个点的之间的距离的算法
- (算法)两个单词的最短距离
- java通过经纬度计算两个点的之间的距离的算法 (单位:米)
- 两个字符串之间的最短编辑距离
- Floyd算法,求图中两个点之间的最短距离
- 计算两个经纬度之间的距离(python算法)
- 【数据结构与算法】二叉树给定两个节点的最短距离(C++实现)
- java通过经纬度计算两个点的之间的距离的算法
- java通过经纬度计算两个点的之间的距离的算法
- 给出两个单词,找到它们的最短距离 (以它们之间隔了多少个单词计数)。
- 弗洛伊德算法得到图中任意两个顶点之间的最短路径
- The minimum distance between two convex polygons---两个凸包之间的最短距离---旋转卡壳法
- 计算两个坐标点之间走最短距离有多少种走法
- PAT程序设计练习——甲级1003(任意两个城市最短距离、Floyd最短路径算法)
- 城市之间的最短总距离(最小生成树算法)
- 两个单词之间的最短距离
- LCA算法求任意两个节点之间的最小公共祖先(最短路径)
- 计算两个日期之间所间隔天数的快速算法
- 最大流ISAP(距离标号最短增广路算法)模板
- MySQL如何查询两个日期之间的记录