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


Java Coordinate.equals方法代码示例

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


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

示例1: checkRepeatedPoints2d

import com.vividsolutions.jts.geom.Coordinate; //导入方法依赖的package包/类
private static int checkRepeatedPoints2d(LineString lineString) {
  int repeatedPoints = 0;

  final CoordinateSequence coordSeq = lineString.getCoordinateSequence();
  Coordinate nextCoord = null;
  Coordinate prevCoord;
  for (int i = 0; i < coordSeq.size(); ++i) {
    prevCoord = nextCoord;
    nextCoord = coordSeq.getCoordinate(i);
    if (nextCoord.equals(prevCoord)) {
      ++repeatedPoints;
    }
  }

  return repeatedPoints;
}
 
开发者ID:OrdnanceSurvey,项目名称:vt-support,代码行数:17,代码来源:JtsGeomStats.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


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