本文整理汇总了Java中com.vividsolutions.jts.geom.LineSegment.pointAlongOffset方法的典型用法代码示例。如果您正苦于以下问题:Java LineSegment.pointAlongOffset方法的具体用法?Java LineSegment.pointAlongOffset怎么用?Java LineSegment.pointAlongOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.vividsolutions.jts.geom.LineSegment
的用法示例。
在下文中一共展示了LineSegment.pointAlongOffset方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addLimitedMitreJoin
import com.vividsolutions.jts.geom.LineSegment; //导入方法依赖的package包/类
/**
* Adds a limited mitre join connecting the two reflex offset segments.
* A limited mitre is a mitre which is beveled at the distance
* determined by the mitre ratio limit.
*
* @param offset0 the first offset segment
* @param offset1 the second offset segment
* @param distance the offset distance
* @param mitreLimit the mitre limit ratio
*/
private void addLimitedMitreJoin(
LineSegment offset0,
LineSegment offset1,
double distance,
double mitreLimit) {
Coordinate basePt = this.seg0.p1;
double ang0 = Angle.angle(basePt, this.seg0.p0);
double ang1 = Angle.angle(basePt, this.seg1.p1);
// oriented angle between segments
double angDiff = Angle.angleBetweenOriented(this.seg0.p0, basePt, this.seg1.p1);
// half of the interior angle
double angDiffHalf = angDiff / 2;
// angle for bisector of the interior angle between the segments
double midAng = Angle.normalize(ang0 + angDiffHalf);
// rotating this by PI gives the bisector of the reflex angle
double mitreMidAng = Angle.normalize(midAng + Math.PI);
// the miterLimit determines the distance to the mitre bevel
double mitreDist = mitreLimit * distance;
// the bevel delta is the difference between the buffer distance
// and half of the length of the bevel segment
double bevelDelta = mitreDist * Math.abs(Math.sin(angDiffHalf));
double bevelHalfLen = distance - bevelDelta;
// compute the midpoint of the bevel segment
double bevelMidX = basePt.x + mitreDist * Math.cos(mitreMidAng);
double bevelMidY = basePt.y + mitreDist * Math.sin(mitreMidAng);
Coordinate bevelMidPt = new Coordinate(bevelMidX, bevelMidY);
// compute the mitre midline segment from the corner point to the bevel segment midpoint
LineSegment mitreMidLine = new LineSegment(basePt, bevelMidPt);
// finally the bevel segment endpoints are computed as offsets from
// the mitre midline
Coordinate bevelEndLeft = mitreMidLine.pointAlongOffset(1.0, bevelHalfLen);
Coordinate bevelEndRight = mitreMidLine.pointAlongOffset(1.0, -bevelHalfLen);
if (this.side == Position.LEFT) {
this.segList.addPt(bevelEndLeft);
this.segList.addPt(bevelEndRight);
} else {
this.segList.addPt(bevelEndRight);
this.segList.addPt(bevelEndLeft);
}
}
示例2: addLimitedMitreJoin
import com.vividsolutions.jts.geom.LineSegment; //导入方法依赖的package包/类
/**
* Adds a limited mitre join connecting the two reflex offset segments.
* A limited mitre is a mitre which is beveled at the distance
* determined by the mitre ratio limit.
*
* @param offset0 the first offset segment
* @param offset1 the second offset segment
* @param distance the offset distance
* @param mitreLimit the mitre limit ratio
*/
private void addLimitedMitreJoin(
LineSegment offset0,
LineSegment offset1,
double distance,
double mitreLimit) {
Coordinate basePt = seg0.p1;
double ang0 = Angle.angle(basePt, seg0.p0);
double ang1 = Angle.angle(basePt, seg1.p1);
// oriented angle between segments
double angDiff = Angle.angleBetweenOriented(seg0.p0, basePt, seg1.p1);
// half of the interior angle
double angDiffHalf = angDiff / 2;
// angle for bisector of the interior angle between the segments
double midAng = Angle.normalize(ang0 + angDiffHalf);
// rotating this by PI gives the bisector of the reflex angle
double mitreMidAng = Angle.normalize(midAng + Math.PI);
// the miterLimit determines the distance to the mitre bevel
double mitreDist = mitreLimit * distance;
// the bevel delta is the difference between the buffer distance
// and half of the length of the bevel segment
double bevelDelta = mitreDist * Math.abs(Math.sin(angDiffHalf));
double bevelHalfLen = distance - bevelDelta;
// compute the midpoint of the bevel segment
double bevelMidX = basePt.x + mitreDist * Math.cos(mitreMidAng);
double bevelMidY = basePt.y + mitreDist * Math.sin(mitreMidAng);
Coordinate bevelMidPt = new Coordinate(bevelMidX, bevelMidY);
// compute the mitre midline segment from the corner point to the bevel segment midpoint
LineSegment mitreMidLine = new LineSegment(basePt, bevelMidPt);
// finally the bevel segment endpoints are computed as offsets from
// the mitre midline
Coordinate bevelEndLeft = mitreMidLine.pointAlongOffset(1.0, bevelHalfLen);
Coordinate bevelEndRight = mitreMidLine.pointAlongOffset(1.0, -bevelHalfLen);
if (side == Position.LEFT) {
segList.addPt(bevelEndLeft);
segList.addPt(bevelEndRight);
} else {
segList.addPt(bevelEndRight);
segList.addPt(bevelEndLeft);
}
}
示例3: getSectionsFromCoordinates
import com.vividsolutions.jts.geom.LineSegment; //导入方法依赖的package包/类
/**
* Extracts traversal sections of a given with from the supplied {@link Coordinate}s.
*
* @param coordinates the list of coordinates.
* @param width the total with of the sections.
* @return the list of {@link LineString sections}.
*/
public static List<LineString> getSectionsFromCoordinates( List<Coordinate> coordinates, double width ) {
if (coordinates.size() < 3) {
throw new IllegalArgumentException("This method works only on lines with at least 3 coordinates.");
}
double halfWidth = width / 2.0;
List<LineString> linesList = new ArrayList<LineString>();
// first section
Coordinate centerCoordinate = coordinates.get(0);
LineSegment l1 = new LineSegment(centerCoordinate, coordinates.get(1));
Coordinate leftCoordinate = l1.pointAlongOffset(0.0, halfWidth);
Coordinate rightCoordinate = l1.pointAlongOffset(0.0, -halfWidth);
LineString lineString = geomFactory.createLineString(new Coordinate[]{leftCoordinate, centerCoordinate, rightCoordinate});
linesList.add(lineString);
for( int i = 1; i < coordinates.size() - 1; i++ ) {
Coordinate previous = coordinates.get(i - 1);
Coordinate current = coordinates.get(i);
Coordinate after = coordinates.get(i + 1);
double firstAngle = azimuth(current, previous);
double secondAngle = azimuth(current, after);
double a1 = min(firstAngle, secondAngle);
double a2 = max(firstAngle, secondAngle);
double centerAngle = a1 + (a2 - a1) / 2.0;
AffineTransformation rotationInstance = AffineTransformation.rotationInstance(-toRadians(centerAngle), current.x,
current.y);
LineString vertical = geomFactory.createLineString(new Coordinate[]{new Coordinate(current.x, current.y + halfWidth),
current, new Coordinate(current.x, current.y - halfWidth)});
Geometry transformed = rotationInstance.transform(vertical);
linesList.add((LineString) transformed);
}
// last section
centerCoordinate = coordinates.get(coordinates.size() - 1);
LineSegment l2 = new LineSegment(centerCoordinate, coordinates.get(coordinates.size() - 2));
leftCoordinate = l2.pointAlongOffset(0.0, halfWidth);
rightCoordinate = l2.pointAlongOffset(0.0, -halfWidth);
lineString = geomFactory.createLineString(new Coordinate[]{leftCoordinate, centerCoordinate, rightCoordinate});
linesList.add(lineString);
return linesList;
}
示例4: addLimitedMitreJoin
import com.vividsolutions.jts.geom.LineSegment; //导入方法依赖的package包/类
/**
* Adds a limited mitre join connecting the two reflex offset segments.
* A limited mitre is a mitre which is beveled at the distance
* determined by the mitre ratio limit.
*
* @param offset0 the first offset segment
* @param offset1 the second offset segment
* @param distance the offset distance
* @param mitreLimit the mitre limit ratio
*/
private void addLimitedMitreJoin(
LineSegment offset0,
LineSegment offset1,
double distance,
double mitreLimit)
{
Coordinate basePt = seg0.p1;
double ang0 = Angle.angle(basePt, seg0.p0);
double ang1 = Angle.angle(basePt, seg1.p1);
// oriented angle between segments
double angDiff = Angle.angleBetweenOriented(seg0.p0, basePt, seg1.p1);
// half of the interior angle
double angDiffHalf = angDiff / 2;
// angle for bisector of the interior angle between the segments
double midAng = Angle.normalize(ang0 + angDiffHalf);
// rotating this by PI gives the bisector of the reflex angle
double mitreMidAng = Angle.normalize(midAng + Math.PI);
// the miterLimit determines the distance to the mitre bevel
double mitreDist = mitreLimit * distance;
// the bevel delta is the difference between the buffer distance
// and half of the length of the bevel segment
double bevelDelta = mitreDist * Math.abs(Math.sin(angDiffHalf));
double bevelHalfLen = distance - bevelDelta;
// compute the midpoint of the bevel segment
double bevelMidX = basePt.x + mitreDist * Math.cos(mitreMidAng);
double bevelMidY = basePt.y + mitreDist * Math.sin(mitreMidAng);
Coordinate bevelMidPt = new Coordinate(bevelMidX, bevelMidY);
// compute the mitre midline segment from the corner point to the bevel segment midpoint
LineSegment mitreMidLine = new LineSegment(basePt, bevelMidPt);
// finally the bevel segment endpoints are computed as offsets from
// the mitre midline
Coordinate bevelEndLeft = mitreMidLine.pointAlongOffset(1.0, bevelHalfLen);
Coordinate bevelEndRight = mitreMidLine.pointAlongOffset(1.0, -bevelHalfLen);
if (side == Position.LEFT) {
segList.addPt(bevelEndLeft);
segList.addPt(bevelEndRight);
}
else {
segList.addPt(bevelEndRight);
segList.addPt(bevelEndLeft);
}
}