/** * Returns {@code true} if this rectangle is nearly equal to {@code other}. The "near equality" of corners is * determined using {@link ProjectionPoint#nearlyEquals(ProjectionPoint, double)}, with the specified maxRelDiff. * * @param other the other rectangle to check. * @param maxRelDiff the maximum {@link Misc#relativeDifference relative difference} that two corners may have. * @return {@code true} if this rectangle is nearly equal to {@code other}. */ public boolean nearlyEquals(ProjectionRect other, double maxRelDiff) { return this.getLowerLeftPoint() .nearlyEquals(other.getLowerLeftPoint(), maxRelDiff) && this.getUpperRightPoint().nearlyEquals(other.getUpperRightPoint(), maxRelDiff); } }
/** * Returns the points at which {@code projBB} intersects the map edge. * * @param projBB defines a bounding box that may intersect the map edge, in projection coordinates. * @return the points at which {@code projBB} intersects the map edge. May be empty. */ public List<ProjectionPoint> getMapEdgeIntercepts(ProjectionRect projBB) { List<ProjectionPoint> intercepts = new LinkedList<>(); for (ProjectionPoint topIntercept : getMapEdgeInterceptsAtY(projBB.getUpperRightPoint().getY())) { if (pointIsBetween(topIntercept, projBB.getUpperLeftPoint(), projBB.getUpperRightPoint())) { intercepts.add(topIntercept); } } for (ProjectionPoint rightIntercept : getMapEdgeInterceptsAtX(projBB.getUpperRightPoint().getX())) { if (pointIsBetween(rightIntercept, projBB.getUpperRightPoint(), projBB.getLowerRightPoint())) { intercepts.add(rightIntercept); } } for (ProjectionPoint bottomIntercept : getMapEdgeInterceptsAtY(projBB.getLowerLeftPoint().getY())) { if (pointIsBetween(bottomIntercept, projBB.getLowerLeftPoint(), projBB.getLowerRightPoint())) { intercepts.add(bottomIntercept); } } for (ProjectionPoint leftIntercept : getMapEdgeInterceptsAtX(projBB.getLowerLeftPoint().getX())) { if (pointIsBetween(leftIntercept, projBB.getLowerLeftPoint(), projBB.getUpperLeftPoint())) { intercepts.add(leftIntercept); } } return intercepts; }
/** * Returns the points at which {@code projBB} intersects the map edge. * * @param projBB defines a bounding box that may intersect the map edge, in projection coordinates. * @return the points at which {@code projBB} intersects the map edge. May be empty. */ public List<ProjectionPoint> getMapEdgeIntercepts(ProjectionRect projBB) { List<ProjectionPoint> intercepts = new LinkedList<>(); for (ProjectionPoint topIntercept : getMapEdgeInterceptsAtY(projBB.getUpperRightPoint().getY())) { if (pointIsBetween(topIntercept, projBB.getUpperLeftPoint(), projBB.getUpperRightPoint())) { intercepts.add(topIntercept); } } for (ProjectionPoint rightIntercept : getMapEdgeInterceptsAtX(projBB.getUpperRightPoint().getX())) { if (pointIsBetween(rightIntercept, projBB.getUpperRightPoint(), projBB.getLowerRightPoint())) { intercepts.add(rightIntercept); } } for (ProjectionPoint bottomIntercept : getMapEdgeInterceptsAtY(projBB.getLowerLeftPoint().getY())) { if (pointIsBetween(bottomIntercept, projBB.getLowerLeftPoint(), projBB.getLowerRightPoint())) { intercepts.add(bottomIntercept); } } for (ProjectionPoint leftIntercept : getMapEdgeInterceptsAtX(projBB.getLowerLeftPoint().getX())) { if (pointIsBetween(leftIntercept, projBB.getLowerLeftPoint(), projBB.getUpperLeftPoint())) { intercepts.add(leftIntercept); } } return intercepts; }
@Override public LatLonRect projToLatLonBB(ProjectionRect projBB) { List<ProjectionPoint> pointsOfInterest = new LinkedList<>(); ProjectionPoint northPole = latLonToProj(new LatLonPointImpl(90, 0)); if (projBB.contains(northPole)) { pointsOfInterest.add(northPole); } ProjectionPoint southPole = latLonToProj(new LatLonPointImpl(-90, 0)); if (projBB.contains(southPole)) { pointsOfInterest.add(southPole); } if (pointsOfInterest.size() == 2) { // projBB contains both north and south poles, and thus, the entire map. return new LatLonRect(new LatLonPointImpl(-90, -180), new LatLonPointImpl(90, 180)); } List<ProjectionPoint> corners = Arrays.asList(projBB.getLowerLeftPoint(), projBB.getLowerRightPoint(), projBB.getUpperLeftPoint(), projBB.getUpperRightPoint()); for (ProjectionPoint corner : corners) { if (projToLatLon(corner) != INVALID) { pointsOfInterest.add(corner); } } pointsOfInterest.addAll(getMapEdgeIntercepts(projBB)); return makeLatLonRect(pointsOfInterest); }
@Override public LatLonRect projToLatLonBB(ProjectionRect projBB) { List<ProjectionPoint> pointsOfInterest = new LinkedList<>(); ProjectionPoint northPole = latLonToProj(new LatLonPointImpl(90, 0)); if (projBB.contains(northPole)) { pointsOfInterest.add(northPole); } ProjectionPoint southPole = latLonToProj(new LatLonPointImpl(-90, 0)); if (projBB.contains(southPole)) { pointsOfInterest.add(southPole); } if (pointsOfInterest.size() == 2) { // projBB contains both north and south poles, and thus, the entire map. return new LatLonRect(new LatLonPointImpl(-90, -180), new LatLonPointImpl(90, 180)); } List<ProjectionPoint> corners = Arrays.asList(projBB.getLowerLeftPoint(), projBB.getLowerRightPoint(), projBB.getUpperLeftPoint(), projBB.getUpperRightPoint()); for (ProjectionPoint corner : corners) { if (projToLatLon(corner) != INVALID) { pointsOfInterest.add(corner); } } pointsOfInterest.addAll(getMapEdgeIntercepts(projBB)); return makeLatLonRect(pointsOfInterest); }
ProjectionPoint upperRigth = projRect.getUpperRightPoint(); double minX = lowerLeft.getX(); double minY = lowerLeft.getY();
ProjectionPoint upperRigth = projRect.getUpperRightPoint(); double minX = lowerLeft.getX(); double minY = lowerLeft.getY();
ProjectionPoint upperRigth = projRect.getUpperRightPoint(); double minx = lowerLeft.getX(); double miny = lowerLeft.getY();
ProjectionPoint upperRigth = projRect.getUpperRightPoint(); double minx = lowerLeft.getX(); double miny = lowerLeft.getY();
@Test public void testGetUpperRightPoint() { ProjectionPoint geturp = projectionRect.getUpperRightPoint(); double llx = projectionRect.getMinX(); double lly = projectionRect.getMinY(); double urx = projectionRect.getMaxX(); double ury = projectionRect.getMaxY(); assertEquals(urx, geturp.getX(), 0); assertEquals(ury, geturp.getY(), 0); assertNotEquals(llx, geturp.getX()); assertNotEquals(lly, geturp.getY()); }
ProjectionPoint upperRigth = llbb.getUpperRightPoint(); double minx = lowerLeft.getX(); double miny = lowerLeft.getY();
LatLonPointImpl urpt = (LatLonPointImpl) projToLatLon(bb.getUpperRightPoint(), new LatLonPointImpl()); LatLonPointImpl ulpt = (LatLonPointImpl) projToLatLon(bb.getUpperLeftPoint(), new LatLonPointImpl());
LatLonPoint urpt = projToLatLon(bb.getUpperRightPoint(), new LatLonPointImpl()); LatLonPoint ulpt = projToLatLon(bb.getUpperLeftPoint(), new LatLonPointImpl());
LatLonPoint urpt = projToLatLon(bb.getUpperRightPoint(), new LatLonPointImpl()); LatLonPoint ulpt = projToLatLon(bb.getUpperLeftPoint(), new LatLonPointImpl());
LatLonPointImpl urpt = (LatLonPointImpl) projToLatLon(bb.getUpperRightPoint(), new LatLonPointImpl()); LatLonPointImpl ulpt = (LatLonPointImpl) projToLatLon(bb.getUpperLeftPoint(), new LatLonPointImpl());
LatLonPointImpl urpt = (LatLonPointImpl) proj.projToLatLon(bb.getUpperRightPoint(), new LatLonPointImpl()); LatLonPointImpl ulpt = (LatLonPointImpl) proj.projToLatLon(bb.getUpperLeftPoint(), new LatLonPointImpl());
LatLonPointImpl urpt = (LatLonPointImpl) proj.projToLatLon(bb.getUpperRightPoint(), new LatLonPointImpl()); LatLonPointImpl ulpt = (LatLonPointImpl) proj.projToLatLon(bb.getUpperLeftPoint(), new LatLonPointImpl());
LatLonPointImpl urpt = (LatLonPointImpl) proj.projToLatLon(bb.getUpperRightPoint(), new LatLonPointImpl()); LatLonPointImpl ulpt = (LatLonPointImpl) proj.projToLatLon(bb.getUpperLeftPoint(), new LatLonPointImpl());
LatLonPointImpl urpt = (LatLonPointImpl) dataProjection.projToLatLon(bb.getUpperRightPoint(), new LatLonPointImpl()); LatLonPointImpl ulpt = (LatLonPointImpl) dataProjection.projToLatLon(bb.getUpperLeftPoint(), new LatLonPointImpl());