本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}