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


Java CGAlgorithms.distanceLineLine方法代码示例

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


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

示例1: computeLineLineDistance

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
private double computeLineLineDistance(FacetSequence facetSeq) {
    // both linear - compute minimum segment-segment distance
    double minDistance = Double.MAX_VALUE;

    for (int i = this.start; i < this.end - 1; i++) {
        for (int j = facetSeq.start; j < facetSeq.end - 1; j++) {
            this.pts.getCoordinate(i, this.p0);
            this.pts.getCoordinate(i + 1, this.p1);
            facetSeq.pts.getCoordinate(j, this.q0);
            facetSeq.pts.getCoordinate(j + 1, this.q1);

            double dist = CGAlgorithms.distanceLineLine(this.p0, this.p1, this.q0, this.q1);
            if (dist == 0.0) {
                return 0.0;
            }
            if (dist < minDistance) {
                minDistance = dist;
            }
        }
    }
    return minDistance;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:23,代码来源:FacetSequence.java

示例2: computeMinDistance

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
private void computeMinDistance(LineString line0, LineString line1,
                                GeometryLocation[] locGeom) {
    if (line0.getEnvelopeInternal().distance(line1.getEnvelopeInternal())
            > minDistance)
        return;
    Coordinate[] coord0 = line0.getCoordinates();
    Coordinate[] coord1 = line1.getCoordinates();
    // brute force approach!
    for (int i = 0; i < coord0.length - 1; i++) {
        for (int j = 0; j < coord1.length - 1; j++) {
            double dist = CGAlgorithms.distanceLineLine(
                    coord0[i], coord0[i + 1],
                    coord1[j], coord1[j + 1]);
            if (dist < minDistance) {
                minDistance = dist;
                LineSegment seg0 = new LineSegment(coord0[i], coord0[i + 1]);
                LineSegment seg1 = new LineSegment(coord1[j], coord1[j + 1]);
                Coordinate[] closestPt = seg0.closestPoints(seg1);
                locGeom[0] = new GeometryLocation(line0, i, closestPt[0]);
                locGeom[1] = new GeometryLocation(line1, j, closestPt[1]);
            }
            if (minDistance <= terminateDistance) return;
        }
    }
}
 
开发者ID:Semantive,项目名称:jts,代码行数:26,代码来源:DistanceOp.java

示例3: computeLineLineDistance

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
private double computeLineLineDistance(FacetSequence facetSeq) {
    // both linear - compute minimum segment-segment distance
    double minDistance = Double.MAX_VALUE;

    for (int i = start; i < end - 1; i++) {
        for (int j = facetSeq.start; j < facetSeq.end - 1; j++) {
            pts.getCoordinate(i, p0);
            pts.getCoordinate(i + 1, p1);
            facetSeq.pts.getCoordinate(j, q0);
            facetSeq.pts.getCoordinate(j + 1, q1);

            double dist = CGAlgorithms.distanceLineLine(p0, p1, q0, q1);
            if (dist == 0.0)
                return 0.0;
            if (dist < minDistance) {
                minDistance = dist;
            }
        }
    }
    return minDistance;
}
 
开发者ID:Semantive,项目名称:jts,代码行数:22,代码来源:FacetSequence.java

示例4: testRandomDisjointCollinearSegments

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
public void testRandomDisjointCollinearSegments() throws Exception
{
  int n = 1000000;
  int failCount = 0;
  for (int i = 0; i < n; i++) {
    //System.out.println(i);
    Coordinate[] seg = randomDisjointCollinearSegments();
    if (0 == CGAlgorithms.distanceLineLine(seg[0], seg[1], seg[2], seg[3])) {
      /*
      System.out.println("FAILED! - "
          + WKTWriter.toLineString(seg[0], seg[1]) + "  -  "
          + WKTWriter.toLineString(seg[2], seg[3]));
          */
      failCount++;
    }
  }
  System.out.println("# failed = " + failCount + " out of " + n);
}
 
开发者ID:Semantive,项目名称:jts,代码行数:19,代码来源:DistanceLineLineStressTest.java

示例5: computeLineLineDistance

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
private double computeLineLineDistance(FacetSequence facetSeq)
{
  // both linear - compute minimum segment-segment distance
  double minDistance = Double.MAX_VALUE;

  for (int i = start; i < end - 1; i++) {
    for (int j = facetSeq.start; j < facetSeq.end - 1; j++) {
      pts.getCoordinate(i, p0);
      pts.getCoordinate(i + 1, p1);
      facetSeq.pts.getCoordinate(j, q0);
      facetSeq.pts.getCoordinate(j + 1, q1);
      
      double dist = CGAlgorithms.distanceLineLine(p0, p1, q0, q1);
      if (dist == 0.0) 
        return 0.0;
      if (dist < minDistance) {
        minDistance = dist;
      }
    }
  }
  return minDistance;
}
 
开发者ID:GitHubDroid,项目名称:geodroid_master_update,代码行数:23,代码来源:FacetSequence.java

示例6: computeMinDistance

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
private void computeMinDistance(LineString line0, LineString line1,
                                GeometryLocation[] locGeom) {
    if (line0.getEnvelopeInternal().distance(line1.getEnvelopeInternal())
            > this.minDistance) {
        return;
    }
    Coordinate[] coord0 = line0.getCoordinates();
    Coordinate[] coord1 = line1.getCoordinates();
    // brute force approach!
    for (int i = 0; i < coord0.length - 1; i++) {
        for (int j = 0; j < coord1.length - 1; j++) {
            double dist = CGAlgorithms.distanceLineLine(
                    coord0[i], coord0[i + 1],
                    coord1[j], coord1[j + 1]);
            if (dist < this.minDistance) {
                this.minDistance = dist;
                LineSegment seg0 = new LineSegment(coord0[i], coord0[i + 1]);
                LineSegment seg1 = new LineSegment(coord1[j], coord1[j + 1]);
                Coordinate[] closestPt = seg0.closestPoints(seg1);
                locGeom[0] = new GeometryLocation(line0, i, closestPt[0]);
                locGeom[1] = new GeometryLocation(line1, j, closestPt[1]);
            }
            if (this.minDistance <= this.terminateDistance) {
                return;
            }
        }
    }
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:29,代码来源:DistanceOp.java

示例7: edgesIntersect

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
public static boolean edgesIntersect(
		final Edge e1,
		final Edge e2 ) {
	return CGAlgorithms.distanceLineLine(
			e1.start,
			e1.end,
			e2.start,
			e2.end) <= 0.0;
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:10,代码来源:GeometryHullTool.java

示例8: distance

import com.vividsolutions.jts.algorithm.CGAlgorithms; //导入方法依赖的package包/类
/**
 * Computes the distance between this line segment and another segment.
 *
 * @return the distance to the other segment
 */
public double distance(LineSegment ls) {
    return CGAlgorithms.distanceLineLine(this.p0, this.p1, ls.p0, ls.p1);
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:9,代码来源:LineSegment.java


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