本文整理汇总了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()]);
}
示例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)));
}
示例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);
}
示例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);
}
示例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();
}