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


Java LineSegment.distance方法代码示例

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


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

示例1: findFurthestPoint

import com.vividsolutions.jts.geom.LineSegment; //导入方法依赖的package包/类
private int findFurthestPoint(Coordinate[] pts, int i, int j, double[] maxDistance) {
    LineSegment seg = new LineSegment();
    seg.p0 = pts[i];
    seg.p1 = pts[j];
    double maxDist = -1.0;
    int maxIndex = i;
    for (int k = i + 1; k < j; k++) {
        Coordinate midPt = pts[k];
        double distance = seg.distance(midPt);
        if (distance > maxDist) {
            maxDist = distance;
            maxIndex = k;
        }
    }
    maxDistance[0] = maxDist;
    return maxIndex;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:18,代码来源:TaggedLineStringSimplifier.java

示例2: indexOfFromStart

import com.vividsolutions.jts.geom.LineSegment; //导入方法依赖的package包/类
private double indexOfFromStart(Coordinate inputPt, double minIndex) {
    double minDistance = Double.MAX_VALUE;

    double ptMeasure = minIndex;
    double segmentStartMeasure = 0.0;
    LineSegment seg = new LineSegment();
    LinearIterator it = new LinearIterator(this.linearGeom);
    while (it.hasNext()) {
        if (!it.isEndOfLine()) {
            seg.p0 = it.getSegmentStart();
            seg.p1 = it.getSegmentEnd();
            double segDistance = seg.distance(inputPt);
            double segMeasureToPt = this.segmentNearestMeasure(seg, inputPt, segmentStartMeasure);
            if (segDistance < minDistance
                    && segMeasureToPt > minIndex) {
                ptMeasure = segMeasureToPt;
                minDistance = segDistance;
            }
            segmentStartMeasure += seg.getLength();
        }
        it.next();
    }
    return ptMeasure;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:25,代码来源:LengthIndexOfPoint.java

示例3: indexOfFromStart

import com.vividsolutions.jts.geom.LineSegment; //导入方法依赖的package包/类
private double indexOfFromStart(Coordinate inputPt, double minIndex) {
    double minDistance = Double.MAX_VALUE;

    double ptMeasure = minIndex;
    double segmentStartMeasure = 0.0;
    LineSegment seg = new LineSegment();
    LinearIterator it = new LinearIterator(linearGeom);
    while (it.hasNext()) {
        if (!it.isEndOfLine()) {
            seg.p0 = it.getSegmentStart();
            seg.p1 = it.getSegmentEnd();
            double segDistance = seg.distance(inputPt);
            double segMeasureToPt = segmentNearestMeasure(seg, inputPt, segmentStartMeasure);
            if (segDistance < minDistance
                    && segMeasureToPt > minIndex) {
                ptMeasure = segMeasureToPt;
                minDistance = segDistance;
            }
            segmentStartMeasure += seg.getLength();
        }
        it.next();
    }
    return ptMeasure;
}
 
开发者ID:Semantive,项目名称:jts,代码行数:25,代码来源:LengthIndexOfPoint.java

示例4: isSnapped

import com.vividsolutions.jts.geom.LineSegment; //导入方法依赖的package包/类
private boolean isSnapped(Coordinate v, Coordinate p0, Coordinate p1)
{
  if (v.equals2D(p0)) return true;
  if (v.equals2D(p1)) return true;
  LineSegment seg = new LineSegment(p0, p1);
  double dist = seg.distance(v);
  if (dist < SNAP_TOLERANCE / 2.05) return false;
  return true;
}
 
开发者ID:Semantive,项目名称:jts,代码行数:10,代码来源:SnapRoundingTest.java

示例5: indexOfFromStart

import com.vividsolutions.jts.geom.LineSegment; //导入方法依赖的package包/类
private LinearLocation indexOfFromStart(Coordinate inputPt, LinearLocation minIndex) {
    double minDistance = Double.MAX_VALUE;
    int minComponentIndex = 0;
    int minSegmentIndex = 0;
    double minFrac = -1.0;

    LineSegment seg = new LineSegment();
    for (LinearIterator it = new LinearIterator(this.linearGeom);
         it.hasNext(); it.next()) {
        if (!it.isEndOfLine()) {
            seg.p0 = it.getSegmentStart();
            seg.p1 = it.getSegmentEnd();
            double segDistance = seg.distance(inputPt);
            double segFrac = seg.segmentFraction(inputPt);

            int candidateComponentIndex = it.getComponentIndex();
            int candidateSegmentIndex = it.getVertexIndex();
            if (segDistance < minDistance) {
                // ensure after minLocation, if any
                if (minIndex == null ||
                        minIndex.compareLocationValues(
                                candidateComponentIndex, candidateSegmentIndex, segFrac)
                                < 0
                        ) {
                    // otherwise, save this as new minimum
                    minComponentIndex = candidateComponentIndex;
                    minSegmentIndex = candidateSegmentIndex;
                    minFrac = segFrac;
                    minDistance = segDistance;
                }
            }
        }
    }
    if (minDistance == Double.MAX_VALUE) {
        // no minimum was found past minLocation, so return it
        return new LinearLocation(minIndex);
    }
    // otherwise, return computed location
    LinearLocation loc = new LinearLocation(minComponentIndex, minSegmentIndex, minFrac);
    return loc;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:42,代码来源:LocationIndexOfPoint.java

示例6: indexOfFromStart

import com.vividsolutions.jts.geom.LineSegment; //导入方法依赖的package包/类
private LinearLocation indexOfFromStart(Coordinate inputPt, LinearLocation minIndex) {
    double minDistance = Double.MAX_VALUE;
    int minComponentIndex = 0;
    int minSegmentIndex = 0;
    double minFrac = -1.0;

    LineSegment seg = new LineSegment();
    for (LinearIterator it = new LinearIterator(linearGeom);
         it.hasNext(); it.next()) {
        if (!it.isEndOfLine()) {
            seg.p0 = it.getSegmentStart();
            seg.p1 = it.getSegmentEnd();
            double segDistance = seg.distance(inputPt);
            double segFrac = seg.segmentFraction(inputPt);

            int candidateComponentIndex = it.getComponentIndex();
            int candidateSegmentIndex = it.getVertexIndex();
            if (segDistance < minDistance) {
                // ensure after minLocation, if any
                if (minIndex == null ||
                        minIndex.compareLocationValues(
                                candidateComponentIndex, candidateSegmentIndex, segFrac)
                                < 0
                        ) {
                    // otherwise, save this as new minimum
                    minComponentIndex = candidateComponentIndex;
                    minSegmentIndex = candidateSegmentIndex;
                    minFrac = segFrac;
                    minDistance = segDistance;
                }
            }
        }
    }
    if (minDistance == Double.MAX_VALUE) {
        // no minimum was found past minLocation, so return it
        return new LinearLocation(minIndex);
    }
    // otherwise, return computed location
    LinearLocation loc = new LinearLocation(minComponentIndex, minSegmentIndex, minFrac);
    return loc;
}
 
开发者ID:Semantive,项目名称:jts,代码行数:42,代码来源:LocationIndexOfPoint.java


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