Search in sources :

Example 1 with BoundingBoxDoubleXYGeometryFactory

use of com.revolsys.geometry.model.impl.BoundingBoxDoubleXYGeometryFactory in project com.revolsys.open by revolsys.

the class GeometryFactory method newBoundingBox.

public BoundingBox newBoundingBox(final Iterable<? extends Point> points) {
    double minX = Double.POSITIVE_INFINITY;
    double maxX = Double.NEGATIVE_INFINITY;
    double minY = Double.POSITIVE_INFINITY;
    double maxY = Double.NEGATIVE_INFINITY;
    for (final Point point : points) {
        final double x = point.getX();
        final double y = point.getY();
        if (x < minX) {
            minX = x;
        }
        if (y < minY) {
            minY = y;
        }
        if (x > maxX) {
            maxX = x;
        }
        if (y > maxY) {
            maxY = y;
        }
    }
    final boolean nullX = minX > maxX;
    final boolean nullY = minY > maxY;
    if (nullX) {
        if (nullY) {
            return this.boundingBoxEmpty;
        } else {
            return new BoundingBoxDoubleXYGeometryFactory(this, Double.NEGATIVE_INFINITY, minY, Double.POSITIVE_INFINITY, maxY);
        }
    } else {
        if (nullY) {
            return new BoundingBoxDoubleXYGeometryFactory(this, minX, Double.NEGATIVE_INFINITY, maxX, Double.POSITIVE_INFINITY);
        } else {
            return new BoundingBoxDoubleXYGeometryFactory(this, minX, minY, maxX, maxY);
        }
    }
}
Also used : AbstractPoint(com.revolsys.geometry.model.impl.AbstractPoint) BoundingBoxDoubleXYGeometryFactory(com.revolsys.geometry.model.impl.BoundingBoxDoubleXYGeometryFactory)

Aggregations

AbstractPoint (com.revolsys.geometry.model.impl.AbstractPoint)1 BoundingBoxDoubleXYGeometryFactory (com.revolsys.geometry.model.impl.BoundingBoxDoubleXYGeometryFactory)1