Skip to content

Commit 1108aff

Browse files
committed
Rename CoordinateSequenceLocation
1 parent 889d949 commit 1108aff

File tree

4 files changed

+20
-15
lines changed

4 files changed

+20
-15
lines changed

modules/core/src/main/java/org/locationtech/jts/algorithm/distance/DirectedHausdorffDistance.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.locationtech.jts.geom.Location;
2727
import org.locationtech.jts.geom.Point;
2828
import org.locationtech.jts.io.WKTWriter;
29-
import org.locationtech.jts.operation.distance.FacetLocation;
29+
import org.locationtech.jts.operation.distance.CoordinateSequenceLocation;
3030
import org.locationtech.jts.operation.distance.IndexedFacetDistance;
3131

3232
/**
@@ -367,8 +367,8 @@ private Coordinate[] computeAtEdges(Geometry geomA, double tolerance, double max
367367
}
368368

369369
private boolean isSameOrCollinear(DHDSegment seg) {
370-
FacetLocation f0 = distanceToB.nearestLocation(seg.p0);
371-
FacetLocation f1 = distanceToB.nearestLocation(seg.p1);
370+
CoordinateSequenceLocation f0 = distanceToB.nearestLocation(seg.p0);
371+
CoordinateSequenceLocation f1 = distanceToB.nearestLocation(seg.p1);
372372
return f0.isSameSegment(f1);
373373
}
374374

@@ -520,7 +520,7 @@ public TargetDistance(Geometry geom) {
520520
}
521521
}
522522

523-
public FacetLocation nearestLocation(Coordinate p) {
523+
public CoordinateSequenceLocation nearestLocation(Coordinate p) {
524524
return distanceToFacets.nearestLocation(p);
525525
}
526526

modules/core/src/main/java/org/locationtech/jts/operation/distance/FacetLocation.java renamed to modules/core/src/main/java/org/locationtech/jts/operation/distance/CoordinateSequenceLocation.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,36 @@
1616
import org.locationtech.jts.geom.CoordinateSequences;
1717

1818
/**
19+
* A location on a {@link FacetSequence}.
1920
*
2021
* Location indexes are always the index of a sequence segment.
21-
* This means they are always less than the number of vertices
22+
* Thus they are always less than the number of vertices
2223
* in the sequence. The endpoint in a sequence
2324
* has the index of the final segment in the sequence.
24-
* if the sequence is a ring, the imdex of the final endpoint is
25+
* if the sequence is a ring, the index of the final endpoint is
2526
* normalized to 0.
2627
*
2728
* @author mdavis
2829
*
2930
*/
30-
public class FacetLocation {
31+
public class CoordinateSequenceLocation {
3132
private CoordinateSequence seq;
3233
private int index;
3334
private Coordinate pt;
3435

35-
public FacetLocation(CoordinateSequence seq, int index, Coordinate pt) {
36+
public CoordinateSequenceLocation(CoordinateSequence seq, int index, Coordinate pt) {
3637
this.seq = seq;
3738
this.pt = pt;
3839
this.index = index;
3940
if (index >= seq.size())
4041
this.index = seq.size() - 1;
4142
}
4243

43-
public boolean isSameSegment(FacetLocation f) {
44+
public Coordinate getCoordinate() {
45+
return pt;
46+
}
47+
48+
public boolean isSameSegment(CoordinateSequenceLocation f) {
4449
if (seq != f.seq)
4550
return false;
4651
if (index == f.index)

modules/core/src/main/java/org/locationtech/jts/operation/distance/FacetSequence.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,15 @@ else if (isPointOther) {
152152
return locs;
153153
}
154154

155-
public FacetLocation nearestLocation(Coordinate p)
155+
public CoordinateSequenceLocation nearestLocation(Coordinate p)
156156
{
157157
if (isPoint()) {
158-
return new FacetLocation(pts, 0, pts.getCoordinate(0));
158+
return new CoordinateSequenceLocation(pts, 0, pts.getCoordinate(0));
159159
}
160160
return nearestLocationOnLine(p);
161161
}
162162

163-
private FacetLocation nearestLocationOnLine(Coordinate pt)
163+
private CoordinateSequenceLocation nearestLocationOnLine(Coordinate pt)
164164
{
165165
double minDistance = Double.MAX_VALUE;
166166
int index = -1;
@@ -187,7 +187,7 @@ private FacetLocation nearestLocationOnLine(Coordinate pt)
187187
break;
188188
}
189189
}
190-
return new FacetLocation(pts, index, nearestPt);
190+
return new CoordinateSequenceLocation(pts, index, nearestPt);
191191
}
192192

193193
private static int normalize(CoordinateSequence pts, int index) {

modules/core/src/main/java/org/locationtech/jts/operation/distance/IndexedFacetDistance.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public Coordinate[] nearestPoints(Geometry g)
139139
return fs1.nearestLocations(fs2);
140140
}
141141

142-
public FacetLocation nearestLocation(Coordinate p) {
142+
public CoordinateSequenceLocation nearestLocation(Coordinate p) {
143143
CoordinateSequence seq = new CoordinateArraySequence(new Coordinate[] { p });
144144
FacetSequence fs = new FacetSequence(seq, 0);
145145
Object nearest = cachedTree.nearestNeighbour(fs.getEnvelope(), fs, FACET_SEQ_DIST);
@@ -161,7 +161,7 @@ public Coordinate nearestPoint(Coordinate p)
161161
FacetSequence fs = new FacetSequence(seq, 0);
162162
Object nearest = cachedTree.nearestNeighbour(fs.getEnvelope(), fs, FACET_SEQ_DIST);
163163
FacetSequence fsN = (FacetSequence) nearest;
164-
return fsN.nearestLocations(fs)[0];
164+
return fsN.nearestLocation(p).getCoordinate();
165165
}
166166

167167
/**

0 commit comments

Comments
 (0)