本文整理汇总了Java中com.vividsolutions.jts.operation.distance.DistanceOp.distance方法的典型用法代码示例。如果您正苦于以下问题:Java DistanceOp.distance方法的具体用法?Java DistanceOp.distance怎么用?Java DistanceOp.distance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vividsolutions.jts.operation.distance.DistanceOp
的用法示例。
在下文中一共展示了DistanceOp.distance方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findClosestPoint
import com.vividsolutions.jts.operation.distance.DistanceOp; //导入方法依赖的package包/类
public void findClosestPoint(String wktA, String wktB) {
System.out.println("-------------------------------------");
try {
Geometry A = wktRdr.read(wktA);
Geometry B = wktRdr.read(wktB);
System.out.println("Geometry A: " + A);
System.out.println("Geometry B: " + B);
DistanceOp distOp = new DistanceOp(A, B);
double distance = distOp.distance();
System.out.println("Distance = " + distance);
Coordinate[] closestPt = distOp.nearestPoints();
LineString closestPtLine = fact.createLineString(closestPt);
System.out.println("Closest points: " + closestPtLine
+ " (distance = " + closestPtLine.getLength() + ")");
} catch (Exception ex) {
ex.printStackTrace();
}
}
示例2: checkMinimumDistance
import com.vividsolutions.jts.operation.distance.DistanceOp; //导入方法依赖的package包/类
/**
* Checks that two geometries are at least a minumum distance apart.
*
* @param g1 a geometry
* @param g2 a geometry
* @param minDist the minimum distance the geometries should be separated by
*/
private void checkMinimumDistance(Geometry g1, Geometry g2, double minDist) {
DistanceOp distOp = new DistanceOp(g1, g2, minDist);
minDistanceFound = distOp.distance();
if (minDistanceFound < minDist) {
isValid = false;
Coordinate[] pts = distOp.nearestPoints();
errorLocation = distOp.nearestPoints()[1];
errorIndicator = g1.getFactory().createLineString(pts);
errMsg = "Distance between buffer curve and input is too small "
+ "(" + minDistanceFound
+ " at " + WKTWriter.toLineString(pts[0], pts[1]) + " )";
}
}
示例3: checkMinimumDistance
import com.vividsolutions.jts.operation.distance.DistanceOp; //导入方法依赖的package包/类
/**
* Checks that two geometries are at least a minumum distance apart.
*
* @param g1 a geometry
* @param g2 a geometry
* @param minDist the minimum distance the geometries should be separated by
*/
private void checkMinimumDistance(Geometry g1, Geometry g2, double minDist) {
DistanceOp distOp = new DistanceOp(g1, g2, minDist);
this.minDistanceFound = distOp.distance();
if (this.minDistanceFound < minDist) {
this.isValid = false;
Coordinate[] pts = distOp.nearestPoints();
this.errorLocation = distOp.nearestPoints()[1];
this.errorIndicator = g1.getFactory().createLineString(pts);
this.errMsg = "Distance between buffer curve and input is too small "
+ "(" + this.minDistanceFound
+ " at " + WKTWriter.toLineString(pts[0], pts[1]) + " )";
}
}
示例4: checkSupFormIntersection
import com.vividsolutions.jts.operation.distance.DistanceOp; //导入方法依赖的package包/类
private LineString checkSupFormIntersection( Point centerPoint, Coordinate origC, LineString newOneSideSegment ) {
if (preparedSupFormGeom.intersects(newOneSideSegment) && !preparedSupFormGeom.covers(newOneSideSegment)) {
Geometry intersection1 = preparedSupFormGeom.getGeometry().intersection(newOneSideSegment);
if (intersection1 instanceof LineString) {
newOneSideSegment = (LineString) intersection1;
} else if (intersection1 instanceof MultiLineString) {
newOneSideSegment = null;
MultiLineString multiLineIntersected = (MultiLineString) intersection1;
double minDistance = Double.POSITIVE_INFINITY;
for( int i = 0; i < multiLineIntersected.getNumGeometries(); i++ ) {
LineString tmpLine = (LineString) multiLineIntersected.getGeometryN(i);
double distance = DistanceOp.distance(tmpLine, centerPoint);
if (distance < minDistance) {
minDistance = distance;
newOneSideSegment = tmpLine;
}
}
if (newOneSideSegment == null) {
throw new RuntimeException();
}
} else {
throw new RuntimeException("Geometry found: " + intersection1);
}
}
Point checkPoint = newOneSideSegment.getStartPoint();
if (centerPoint.equals(checkPoint)) {
// need to check since we are not sure about the order after intersection
checkPoint = newOneSideSegment.getEndPoint();
}
if (centerPoint.distance(checkPoint) < centerPoint.getCoordinate().distance(origC)) {
// the new line segment is smaller, that is not allowed
newOneSideSegment = gf.createLineString(new Coordinate[]{centerPoint.getCoordinate(), origC});
}
return newOneSideSegment;
}
示例5: distance
import com.vividsolutions.jts.operation.distance.DistanceOp; //导入方法依赖的package包/类
/**
* Returns the minimum distance between this <code>Geometry</code>
* and another <code>Geometry</code>.
*
* @param g the <code>Geometry</code> from which to compute the distance
* @return 0 if either input geometry is empty
* @throws IllegalArgumentException if g is null
*/
public double distance(Geometry g) {
return DistanceOp.distance(this, g);
}
示例6: distance
import com.vividsolutions.jts.operation.distance.DistanceOp; //导入方法依赖的package包/类
/**
* Returns the minimum distance between this <code>Geometry</code>
* and another <code>Geometry</code>.
*
* @param g the <code>Geometry</code> from which to compute the distance
* @return the distance between the geometries
* @return 0 if either input geometry is empty
* @throws IllegalArgumentException if g is null
*/
public double distance(Geometry g)
{
return DistanceOp.distance(this, g);
}