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


Java DistanceOp.distance方法代码示例

本文整理汇总了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();
    }
}
 
开发者ID:Semantive,项目名称:jts,代码行数:21,代码来源:ClosestPointExample.java

示例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]) + " )";
    }
}
 
开发者ID:Semantive,项目名称:jts,代码行数:23,代码来源:BufferDistanceValidator.java

示例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]) + " )";
    }
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:22,代码来源:BufferDistanceValidator.java

示例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;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:38,代码来源:OmsLW08_NetworkBufferWidthCalculator.java

示例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);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:12,代码来源:Geometry.java

示例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);
}
 
开发者ID:GitHubDroid,项目名称:geodroid_master_update,代码行数:14,代码来源:Geometry.java


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