use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class PointQuadTreeNode method findEntriesWithin.
public void findEntriesWithin(final List<Entry<Point, T>> results, final BoundingBox envelope) {
final double minX = envelope.getMinX();
final double maxX = envelope.getMaxX();
final double minY = envelope.getMinY();
final double maxY = envelope.getMaxY();
if (envelope.covers(this.x, this.y)) {
final Point point = new PointDoubleXY(this.x, this.y);
results.add(new SimpleImmutableEntry<>(point, this.value));
}
final boolean minXLess = isLessThanX(minX);
final boolean maxXLess = isLessThanX(maxX);
final boolean minYLess = isLessThanY(minY);
final boolean maxYLess = isLessThanY(maxY);
if (this.southWest != null && minXLess && minYLess) {
this.southWest.findEntriesWithin(results, envelope);
}
if (this.northWest != null && minXLess && !maxYLess) {
this.northWest.findEntriesWithin(results, envelope);
}
if (this.southEast != null && !maxXLess && minYLess) {
this.southEast.findEntriesWithin(results, envelope);
}
if (this.northEast != null && !maxXLess && !maxYLess) {
this.northEast.findEntriesWithin(results, envelope);
}
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class CentralEndpointIntersector method getIntersection.
public static Point getIntersection(final double... coordinates) {
final double averageX = average(0, coordinates);
final double averageY = average(1, coordinates);
double intersectionX = Double.NaN;
double intersectionY = Double.NaN;
double minDistance = Double.POSITIVE_INFINITY;
final int vertexCount = coordinates.length / 2;
int coordinateIndex = 0;
for (int vertexIndex = 0; vertexIndex < vertexCount; vertexIndex++) {
final double x = coordinates[coordinateIndex++];
final double y = coordinates[coordinateIndex++];
final double distance = MathUtil.distance(averageX, averageY, x, y);
if (distance < minDistance) {
minDistance = distance;
intersectionX = x;
intersectionY = y;
}
}
return new PointDoubleXY(intersectionX, intersectionY);
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class CoordinatesUtil method translate.
static Point translate(final Point point, final double angle, final double length) {
final double x = point.getX();
final double y = point.getY();
final double newX = Trig.adjacent(x, angle, length);
final double newY = Trig.opposite(y, angle, length);
final Point newPoint = new PointDoubleXY(newX, newY);
return newPoint;
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class CoordinatesUtil method offset.
static Point offset(final Point coordinate, final double angle, final double distance) {
final double newX = coordinate.getX() + distance * Math.cos(angle);
final double newY = coordinate.getY() + distance * Math.sin(angle);
final Point newCoordinate = new PointDoubleXY(newX, newY);
return newCoordinate;
}
use of com.revolsys.geometry.model.impl.PointDoubleXY in project com.revolsys.open by revolsys.
the class IsValidOp method findPtNotNode.
/**
* Find a point from the list of testCoords
* that is NOT a node in the edge for the list of searchCoords
*
* @return the point found, or <code>null</code> if none found
*/
public static Point findPtNotNode(final LineString testLine, final LinearRing searchRing, final GeometryGraph graph) {
// find edge corresponding to searchRing.
final Edge searchEdge = graph.findEdge(searchRing);
// find a point in the testCoords which is not a node of the searchRing
final EdgeIntersectionList eiList = searchEdge.getEdgeIntersectionList();
// somewhat inefficient - is there a better way? (Use a node map, for
// instance?)
final int vertexCount = testLine.getVertexCount();
for (int vertexIndex = 0; vertexIndex < vertexCount; vertexIndex++) {
final double x = testLine.getX(vertexIndex);
final double y = testLine.getY(vertexIndex);
if (!eiList.isIntersection(x, y)) {
return new PointDoubleXY(x, y);
}
}
return null;
}
Aggregations