com.hazelcast.shaded.org.locationtech.jts.triangulate.MidpointSplitPointFinder Maven / Gradle / Ivy
/*
* Copyright (c) 2016 Vivid Solutions.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* and Eclipse Distribution License v. 1.0 which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v20.html
* and the Eclipse Distribution License is available at
*
* http://www.eclipse.org/org/documents/edl-v10.php.
*/
package com.hazelcast.shaded.org.locationtech.jts.triangulate;
import com.hazelcast.shaded.org.locationtech.jts.geom.Coordinate;
/**
* A simple split point finder which returns the midpoint of the split segment. This is a default
* strategy only. Usually a more sophisticated strategy is required to prevent repeated splitting.
* Other points which could be used are:
*
* - The projection of the encroaching point on the segment
*
- A point on the segment which will produce two segments which will not be further encroached
*
- The point on the segment which is the same distance from an endpoint as the encroaching
* point
*
*
* @author Martin Davis
*/
public class MidpointSplitPointFinder implements ConstraintSplitPointFinder {
/**
* Gets the midpoint of the split segment
*/
public Coordinate findSplitPoint(Segment seg, Coordinate encroachPt) {
Coordinate p0 = seg.getStart();
Coordinate p1 = seg.getEnd();
return new Coordinate((p0.x + p1.x) / 2, (p0.y + p1.y) / 2);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy