/** * Verifies invariants for the given envelope after each test. * This method is overridden by {@link SubEnvelopeTest}. */ void verifyInvariants(final GeneralEnvelope envelope) { assertSame(WGS84, envelope.getCoordinateReferenceSystem()); }
/** * Return true if the bounding box contain the line. * i.e. the two point of the line are inside the box. * * @param boundingBox An envelope. * @param line A line2D * * @return True if the envelope contain the line. */ public static boolean contains(final GeneralEnvelope boundingBox, final Line2D line) { final CoordinateReferenceSystem crs = boundingBox.getCoordinateReferenceSystem(); final GeneralDirectPosition tempPoint1 = new GeneralDirectPosition(line.getX1(), line.getY1()); tempPoint1.setCoordinateReferenceSystem(crs); final GeneralDirectPosition tempPoint2 = new GeneralDirectPosition(line.getX2(), line.getY2()); tempPoint2.setCoordinateReferenceSystem(crs); if ((boundingBox.contains(tempPoint1) && boundingBox.contains(tempPoint2))) return true; return false; }
ArgumentChecks.ensureNonNull("destination envelope", destination); final CoordinateReferenceSystem sourceCRS = source.getCoordinateReferenceSystem(); final CoordinateReferenceSystem destCRS = destination.getCoordinateReferenceSystem();
for (int i=0; i<count; i++) { final GeneralEnvelope previous = reduced[i]; if (Utilities.equalsIgnoreMetadata(crs, previous.getCoordinateReferenceSystem())) { reduce(previous, envelope); continue merge; for (int i=0; i<count; i++) { final GeneralEnvelope e = reduced[i]; crs[i] = e.getCoordinateReferenceSystem(); if (converter.setBounds(e, more, true) != null) { // See above comment about logging. if (bbox == null) {
/** * Return true if the line crosses the envelope. * i.e. one point is inside the box, one is outside. * * @param boundingBox An envelope. * @param line A line2D * * @return True if the line crosses the envelope. */ public static boolean crosses(final GeneralEnvelope boundingBox, final Line2D line) { final CoordinateReferenceSystem crs = boundingBox.getCoordinateReferenceSystem(); final GeneralDirectPosition tempPoint1 = new GeneralDirectPosition(line.getX1(), line.getY1()); tempPoint1.setCoordinateReferenceSystem(crs); final GeneralDirectPosition tempPoint2 = new GeneralDirectPosition(line.getX2(), line.getY2()); tempPoint2.setCoordinateReferenceSystem(crs); // for this case we look if the line have a point inside and a point outside if ((boundingBox.contains(tempPoint1) && !boundingBox.contains(tempPoint2)) || (!boundingBox.contains(tempPoint1) && boundingBox.contains(tempPoint2)) ) return true; return false; }
/** * Return the shortest distance between a line and a boundingBox. * If the line intersect or is contains by the bounding box it return 0; * * @param line A line2D. * @param boundingBox A bounding box in the same CRS than the line * @param units The units in which the distance will be expressed. * @return The shortest distance between the bounding box and the line. */ public static double lineToBBoxDistance(final Line2D line, final GeneralEnvelope boundingBox, final String units) { final CoordinateReferenceSystem crs = boundingBox.getCoordinateReferenceSystem(); final GeneralDirectPosition tempPoint1 = new GeneralDirectPosition(line.getX1(), line.getY1()); tempPoint1.setCoordinateReferenceSystem(crs); final GeneralDirectPosition tempPoint2 = new GeneralDirectPosition(line.getX2(), line.getY2()); tempPoint2.setCoordinateReferenceSystem(crs); if (boundingBox.contains(tempPoint1) || boundingBox.contains(tempPoint2)) return 0; final List<Line2D> border = getBorder(boundingBox); double distance = Double.MAX_VALUE; for (Line2D l: border) { if (l.intersectsLine(line)) return 0; double tempDistance = lineTolineDistance(l, line, units); if (tempDistance < distance) distance = tempDistance; } return distance; }
if (env.getCoordinateReferenceSystem() == null) { env.setCoordinateReferenceSystem(sourceCRS);