@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); }
/** * 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; }
LatLonPoint lrpt = projToLatLon(bb.getLowerRightPoint(), new LatLonPointImpl()); LatLonPoint urpt = projToLatLon(bb.getUpperRightPoint(), new LatLonPointImpl()); LatLonPoint ulpt = projToLatLon(bb.getUpperLeftPoint(), new LatLonPointImpl());
LatLonPoint lrpt = projToLatLon(bb.getLowerRightPoint(), new LatLonPointImpl()); LatLonPoint urpt = projToLatLon(bb.getUpperRightPoint(), new LatLonPointImpl()); LatLonPoint ulpt = projToLatLon(bb.getUpperLeftPoint(), new LatLonPointImpl());
LatLonPointImpl lrpt = (LatLonPointImpl) projToLatLon(bb.getLowerRightPoint(), new LatLonPointImpl()); LatLonPointImpl urpt = (LatLonPointImpl) projToLatLon(bb.getUpperRightPoint(), new LatLonPointImpl()); LatLonPointImpl ulpt = (LatLonPointImpl) projToLatLon(bb.getUpperLeftPoint(), new LatLonPointImpl());
LatLonPointImpl lrpt = (LatLonPointImpl) projToLatLon(bb.getLowerRightPoint(), new LatLonPointImpl()); LatLonPointImpl urpt = (LatLonPointImpl) projToLatLon(bb.getUpperRightPoint(), new LatLonPointImpl()); LatLonPointImpl ulpt = (LatLonPointImpl) projToLatLon(bb.getUpperLeftPoint(), new LatLonPointImpl());
LatLonPointImpl lrpt = (LatLonPointImpl) proj.projToLatLon(bb.getLowerRightPoint(), new LatLonPointImpl()); LatLonPointImpl urpt = (LatLonPointImpl) proj.projToLatLon(bb.getUpperRightPoint(), new LatLonPointImpl()); LatLonPointImpl ulpt = (LatLonPointImpl) proj.projToLatLon(bb.getUpperLeftPoint(), new LatLonPointImpl());
LatLonPointImpl lrpt = (LatLonPointImpl) proj.projToLatLon(bb.getLowerRightPoint(), new LatLonPointImpl()); LatLonPointImpl urpt = (LatLonPointImpl) proj.projToLatLon(bb.getUpperRightPoint(), new LatLonPointImpl()); LatLonPointImpl ulpt = (LatLonPointImpl) proj.projToLatLon(bb.getUpperLeftPoint(), new LatLonPointImpl());
LatLonPointImpl lrpt = (LatLonPointImpl) proj.projToLatLon(bb.getLowerRightPoint(), new LatLonPointImpl()); LatLonPointImpl urpt = (LatLonPointImpl) proj.projToLatLon(bb.getUpperRightPoint(), new LatLonPointImpl()); LatLonPointImpl ulpt = (LatLonPointImpl) proj.projToLatLon(bb.getUpperLeftPoint(), new LatLonPointImpl());
LatLonPointImpl lrpt = (LatLonPointImpl) dataProjection.projToLatLon(bb.getLowerRightPoint(), new LatLonPointImpl()); LatLonPointImpl urpt = (LatLonPointImpl) dataProjection.projToLatLon(bb.getUpperRightPoint(), new LatLonPointImpl()); LatLonPointImpl ulpt = (LatLonPointImpl) dataProjection.projToLatLon(bb.getUpperLeftPoint(), new LatLonPointImpl());