use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class RobustLineIntersector method intersectionWithNormalization.
private Point intersectionWithNormalization(final double line1x1, final double line1y1, final double line1x2, final double line1y2, final double line2x1, final double line2y1, final double line2x2, final double line2y2) {
final double minX0 = line1x1 < line1x2 ? line1x1 : line1x2;
final double minY0 = line1y1 < line1y2 ? line1y1 : line1y2;
final double maxX0 = line1x1 > line1x2 ? line1x1 : line1x2;
final double maxY0 = line1y1 > line1y2 ? line1y1 : line1y2;
final double minX1 = line2x1 < line2x2 ? line2x1 : line2x2;
final double minY1 = line2y1 < line2y2 ? line2y1 : line2y2;
final double maxX1 = line2x1 > line2x2 ? line2x1 : line2x2;
final double maxY1 = line2y1 > line2y2 ? line2y1 : line2y2;
final double intMinX = minX0 > minX1 ? minX0 : minX1;
final double intMaxX = maxX0 < maxX1 ? maxX0 : maxX1;
final double intMinY = minY0 > minY1 ? minY0 : minY1;
final double intMaxY = maxY0 < maxY1 ? maxY0 : maxY1;
final double normX = (intMinX + intMaxX) / 2.0;
final double normY = (intMinY + intMaxY) / 2.0;
final Point intPt = safeHCoordinatesIntersection(//
line1x1 - normX, //
line1y1 - normY, //
line1x2 - normX, //
line1y2 - normY, //
line2x1 - normX, //
line2y1 - normY, line2x2 - normX, line2y2 - normY);
final double x = intPt.getX() + normX;
final double y = intPt.getY() + normY;
return new PointDoubleXY(x, y);
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class InteriorPointLine method add.
private void add(final double x, final double y) {
final double dist = MathUtil.distance(this.centroid.getX(), this.centroid.getY(), x, y);
if (dist < this.minDistance) {
this.interiorPoint = new PointDoubleXY(x, y);
this.minDistance = dist;
}
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class Point method convertPoint2d.
default Point convertPoint2d(final GeometryFactory geometryFactory) {
if (isEmpty()) {
return this;
} else {
final CoordinatesOperation coordinatesOperation = getGeometryFactory().getCoordinatesOperation(geometryFactory);
if (coordinatesOperation == null) {
return this;
} else {
final double sourceX = getX();
final double sourceY = getY();
final double[] targetCoordinates = new double[] { sourceX, sourceY };
coordinatesOperation.perform(2, targetCoordinates, 2, targetCoordinates);
final double targetX = targetCoordinates[X];
final double targetY = targetCoordinates[Y];
return new PointDoubleXY(targetX, targetY);
}
}
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class CoordinatesUtil method pointNotInList.
/**
* Return the first point of points1 not in points2
* @param points1
* @param points2
* @return
*/
static Point pointNotInList(final LineString line1, final LineString line2) {
final int vertexCount = line1.getVertexCount();
for (int vertexIndex = 0; vertexIndex < vertexCount; vertexIndex++) {
final double x = line1.getX(vertexIndex);
final double y = line1.getY(vertexIndex);
if (!line2.hasVertex(x, y)) {
return new PointDoubleXY(x, y);
}
}
return null;
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class EdgeCleanCloseVerticesVisitor method accept.
// TODO look at the angles with the previous and next segments to decide
// which coordinate to remove. If there is a right angle in a building then
// it should probably not be removed. This would be confirmed by the angles
// of the next and previous segments.
/**
* Visit the edge performing any required cleanup.
*
* @param edge The edge to visit.
* @return true If further edges should be processed.
*/
@Override
public void accept(final Edge<T> edge) {
final String typePath = edge.getTypeName();
final LineString line = edge.getLineString();
final int vertexCount = line.getVertexCount();
if (vertexCount > 2) {
final GeometryFactory geometryFactory = line.getGeometryFactory();
final LinkedHashSet<Integer> removeIndicies = new LinkedHashSet<>();
double x1 = line.getX(0);
double y1 = line.getY(0);
for (int i = 1; i < vertexCount; i++) {
final double x2 = line.getX(i);
final double y2 = line.getY(i);
final double distance = MathUtil.distance(x1, y1, x2, y2);
if (distance < this.minDistance) {
final double previousAngle = getAngle(edge, line, i - 1);
final double angle = getAngle(edge, line, i);
final double nextAngle = getAngle(edge, line, i + 1);
boolean fixed = false;
if (angle > previousAngle) {
if (angle > nextAngle) {
if (angle > Math.toRadians(160)) {
fixed = true;
}
}
} else if (previousAngle > nextAngle) {
}
if (fixed) {
this.coordinateListeners.coordinateEvent(new PointDoubleXY(x2, y2), typePath, "Short Segment", "Fixed", distance + " " + Math.toDegrees(previousAngle) + " " + Math.toDegrees(angle) + " " + Math.toDegrees(nextAngle));
} else {
this.coordinateListeners.coordinateEvent(new PointDoubleXY(x2, y2), typePath, "Short Segment", "Review", distance + " " + Math.toDegrees(previousAngle) + " " + Math.toDegrees(angle) + " " + Math.toDegrees(nextAngle));
}
}
x1 = x2;
y1 = y2;
}
if (!removeIndicies.isEmpty()) {
final int axisCount = line.getAxisCount();
final double[] newCoordinates = new double[(vertexCount - removeIndicies.size()) * axisCount];
int k = 0;
for (int j = 0; j < vertexCount; j++) {
if (!removeIndicies.contains(j)) {
CoordinatesListUtil.setCoordinates(newCoordinates, axisCount, k, line, j);
k++;
}
}
final LineString newLine = geometryFactory.lineString(axisCount, newCoordinates);
final Edge<T> newEdge = this.graph.replaceEdge(edge, newLine);
this.edgeListeners.edgeEvent(newEdge, "Edge close indicies", EdgeEvent.EDGE_CHANGED, null);
}
}
}
Aggregations