当前位置: 首页>>代码示例>>Java>>正文


Java Coordinate.distance方法代码示例

本文整理汇总了Java中com.vividsolutions.jts.geom.Coordinate.distance方法的典型用法代码示例。如果您正苦于以下问题:Java Coordinate.distance方法的具体用法?Java Coordinate.distance怎么用?Java Coordinate.distance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.vividsolutions.jts.geom.Coordinate的用法示例。


在下文中一共展示了Coordinate.distance方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createBezierSpline

import com.vividsolutions.jts.geom.Coordinate; //导入方法依赖的package包/类
public static Coordinate[] createBezierSpline(Coordinate p1, Coordinate p2, Coordinate p3, Coordinate p4, double dist) {
	ArrayList<Coordinate> ret = new ArrayList<Coordinate>();
	double t = 0.0;
	Coordinate prevCoord = p1;
	ret.add(prevCoord);
	do {
		Coordinate coord = cubicBezier(p1, p2, p3, p4, t);
		if (prevCoord.distance(coord) >= dist) {
			ret.add(coord);
			prevCoord = coord;
		}
		t += 0.01;
	}
	while (t < 1.0);
	if (ret.get(ret.size()-1).distance(p4) > dist/4.0) ret.add(p4);
	return ret.toArray(new Coordinate[ret.size()]);
}
 
开发者ID:FedericoPecora,项目名称:coordination_oru,代码行数:18,代码来源:BezierSplineFactory.java

示例2: distancePointLine

import com.vividsolutions.jts.geom.Coordinate; //导入方法依赖的package包/类
/**
 * Computes the distance from a point p to a line segment AB
 * 
 * Note: NON-ROBUST!
 * 
 * @param p
 *            the point to compute the distance for
 * @param A
 *            one point of the line
 * @param B
 *            another point of the line (must be different to A)
 * @return the distance from p to line segment AB
 */
public static double distancePointLine(Coordinate p, Coordinate A, Coordinate B) {
	// if start==end, then use pt distance
	if (A.equals(B))
		return p.distance(A);

	// otherwise use comp.graphics.algorithms Frequently Asked Questions
	// method
	/*
	 * (1) AC dot AB r = --------- ||AB||^2 r has the following meaning: r=0
	 * P = A r=1 P = B r<0 P is on the backward extension of AB r>1 P is on
	 * the forward extension of AB 0<r<1 P is interior to AB
	 */

	double r = ((p.x - A.x) * (B.x - A.x) + (p.y - A.y) * (B.y - A.y))
			/ ((B.x - A.x) * (B.x - A.x) + (B.y - A.y) * (B.y - A.y));

	if (r <= 0.0)
		return p.distance(A);
	if (r >= 1.0)
		return p.distance(B);

	/*
	 * (2) (Ay-Cy)(Bx-Ax)-(Ax-Cx)(By-Ay) s = -----------------------------
	 * L^2
	 * 
	 * Then the distance from C to P = |s|*L.
	 */

	double s = ((A.y - p.y) * (B.x - A.x) - (A.x - p.x) * (B.y - A.y))
			/ ((B.x - A.x) * (B.x - A.x) + (B.y - A.y) * (B.y - A.y));

	return Math.abs(s) * Math.sqrt(((B.x - A.x) * (B.x - A.x) + (B.y - A.y) * (B.y - A.y)));
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:47,代码来源:CoordTools.java

示例3: computeDistance

import com.vividsolutions.jts.geom.Coordinate; //导入方法依赖的package包/类
private double computeDistance(Coordinate point1, Coordinate point2, Coordinate point3, Coordinate point4) {
    return point1.distance(point2)
            + point2.distance(point3)
            + point3.distance(point4);
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:6,代码来源:EditGeometryVectorLayer.java

示例4: validateMinSegmentLength

import com.vividsolutions.jts.geom.Coordinate; //导入方法依赖的package包/类
private boolean validateMinSegmentLength(final Coordinate coordinate1, final Coordinate coordinate2) {
	return (coordinate1.distance(coordinate2) >= MIN_SEGMENT_LENGTH);
}
 
开发者ID:geowe,项目名称:sig-seguimiento-vehiculos,代码行数:4,代码来源:GeometryValidator.java

示例5: getProportion

import com.vividsolutions.jts.geom.Coordinate; //导入方法依赖的package包/类
private double getProportion(Coordinate coord, LineString ls) {
        // coord is a point in line ls
        Coordinate[] ends = ls.getCoordinates();
        return coord.distance(ends[0]) / ls.getLength();
}
 
开发者ID:GIScience,项目名称:openrouteservice,代码行数:6,代码来源:FrechetDistance.java


注:本文中的com.vividsolutions.jts.geom.Coordinate.distance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。