use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class ScaledIntegerGriddedDigitalElevationModelFile method createNewFile.
protected void createNewFile() throws IOException {
Paths.createParentDirectories(this.path);
this.channel = FileChannel.open(this.path, Paths.OPEN_OPTIONS_READ_WRITE_SET, this.fileAttributes);
try (final ChannelWriter writer = new ChannelWriter(this.channel)) {
final int gridWidth = getGridWidth();
final int gridHeight = getGridHeight();
final double gridCellSize = getGridCellSize();
final BoundingBox boundingBox = getBoundingBox();
final GeometryFactory geometryFactory = getGeometryFactory();
ScaledIntegerGriddedDigitalElevationModelWriter.writeHeader(writer, boundingBox, geometryFactory, gridWidth, gridHeight, (int) gridCellSize);
final int count = gridWidth * gridHeight;
for (int i = 0; i < count; i++) {
writer.putInt(Integer.MIN_VALUE);
}
}
}
use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class ConformingDelaunayTriangulator method findNonGabrielPoint.
/**
* Given a set of points stored in the kd-tree and a line segment defined by
* two points in this set, finds a {@link Coordinates} in the circumcircle of
* the line segment, if one exists. This is called the Gabriel point - if none
* exists then the segment is said to have the Gabriel condition. Uses the
* heuristic of finding the non-Gabriel point closest to the midpoint of the
* segment.
*
* @param p
* start of the line segment
* @param q
* end of the line segment
* @return a point which is non-Gabriel
* or null if no point is non-Gabriel
*/
private Point findNonGabrielPoint(final LineSegmentDoubleData seg) {
final Point p = seg.getPoint(0);
final Point q = seg.getPoint(1);
// Find the mid point on the line and compute the radius of enclosing circle
final Point midPt = new PointDoubleXY((p.getX() + q.getX()) / 2.0, (p.getY() + q.getY()) / 2.0);
final double segRadius = p.distancePoint(midPt);
// compute envelope of circumcircle
final BoundingBox env = midPt.getBoundingBox().expand(segRadius);
// Find all points in envelope
final List result = this.pointIndex.getItems(env);
// For each point found, test if it falls strictly in the circle
// find closest point
Point closestNonGabriel = null;
double minDist = Double.MAX_VALUE;
for (final Iterator i = result.iterator(); i.hasNext(); ) {
final KdNode nextNode = (KdNode) i.next();
final Point testPt = nextNode;
// ignore segment endpoints
if (testPt.equals(2, p) || testPt.equals(2, q)) {
continue;
}
final double testRadius = midPt.distancePoint(testPt);
if (testRadius < segRadius) {
// double testDist = seg.distance(testPt);
final double testDist = testRadius;
if (closestNonGabriel == null || testDist < minDist) {
closestNonGabriel = testPt;
minDist = testDist;
}
}
}
return closestNonGabriel;
}
use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class Graph method getNodes.
public List<Node<T>> getNodes(final Predicate<Node<T>> filter, final Geometry geometry, final double maxDistance) {
final BoundingBox boundingBox = geometry.getBoundingBox().expand(maxDistance);
final Predicate<Node<T>> distanceFilter = (node) -> {
return filter.test(node) && node.distance(geometry) <= maxDistance;
};
return getNodes(boundingBox, distanceFilter, null);
}
use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class Graph method getEdges.
public List<Edge<T>> getEdges(final Point point, final double maxDistance) {
if (point == null) {
return Collections.emptyList();
} else {
BoundingBox boundingBox = point.getBoundingBox();
boundingBox = boundingBox.expand(maxDistance);
final double x = point.getX();
final double y = point.getY();
final Predicate<Edge<T>> filter = (edge) -> {
final LineString line = edge.getLineString();
final double distance = line.distance(x, y);
if (distance <= maxDistance) {
return true;
} else {
return false;
}
};
return BoundingBox.newArraySorted(this::forEachEdge, boundingBox, filter);
}
}
use of com.revolsys.geometry.model.BoundingBox in project com.revolsys.open by revolsys.
the class RectangleXY method isWithinDistance.
@Override
public boolean isWithinDistance(Geometry geometry, final double distance) {
geometry = geometry.as2d(this);
final BoundingBox boundingBox2 = geometry.getBoundingBox();
final double bboxDistance = boundingBox2.distance(this.minX, this.minY, this.maxX, this.maxY);
if (bboxDistance > distance) {
return false;
} else {
final double geometryDistance = this.distance(geometry);
return geometryDistance <= distance;
}
}
Aggregations