| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
package org.locationtech.jts.triangulate; |
| 14 |
|
| 15 |
|
| 16 |
import org.locationtech.jts.geom.Coordinate; |
| 17 |
|
| 18 |
/** |
| 19 |
* A simple split point finder which returns the midpoint of the split segment. This is a default |
| 20 |
* strategy only. Usually a more sophisticated strategy is required to prevent repeated splitting. |
| 21 |
* Other points which could be used are: |
| 22 |
* <ul> |
| 23 |
* <li>The projection of the encroaching point on the segment |
| 24 |
* <li>A point on the segment which will produce two segments which will not be further encroached |
| 25 |
* <li>The point on the segment which is the same distance from an endpoint as the encroaching |
| 26 |
* point |
| 27 |
* </ul> |
| 28 |
* |
| 29 |
* @author Martin Davis |
| 30 |
*/ |
| 31 |
public class MidpointSplitPointFinder implements ConstraintSplitPointFinder { |
| 32 |
/** |
| 33 |
* Gets the midpoint of the split segment |
| 34 |
*/ |
| 35 |
public Coordinate findSplitPoint(Segment seg, Coordinate encroachPt) { |
| 36 |
Coordinate p0 = seg.getStart(); |
| 37 |
Coordinate p1 = seg.getEnd(); |
| 38 |
return new Coordinate((p0.x + p1.x) / 2, (p0.y + p1.y) / 2); |
| 39 |
} |
| 40 |
|
| 41 |
} |
| 42 |
|